It seems we currently allow various houdini registration happen after worklet module is loaded.
The current specs allow this AFAICT, but our implementation does not really support this correctly and it is not clear if we should.
Consider this example that registers a new painter inside first paint of another painter.
registerPaint("one", class MyPaint {
paint(ctx, size, styleMap) {
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, size.width, size.height);
registerPaint("two", class Two {
paint(ctx){
ctx.fillStyle = 'blue';
ctx.fillRect(0, 0, size.width, size.height);
}
});
}
});
Due to scope switching behavior of PaintWorklet, currently I believe the second painter only gets registered in the active global scope at the time of painting the first one. So second painter is flaky. See: https://jsbin.com/xoziwodoce/1/edit?html,js,console,output
Another example is AudioWorklet where it only syncs its "registered processors" only once after modules load is complete thus making the assumption there is no registeration post load. See https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/webaudio/audio_worklet_object_proxy.cc?type=cs&sq=package:chromium&g=0&l=31
I like us to decide if post load registration is supported or not. Is there any usecase for it?
Absence of usecases, I suggest we ban this and have logic to throw if one tries to register post load.
Comment 1 by majidvp@chromium.org
, Jan 11