-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VUMeter example uses AudioWorkletProcessor's port in a way that can't work per spec #1973
Comments
I believe that's our original intention. We don't want to expose the port as an argument of the constructor. So we need to fix:
|
For the reference, this is what Worker spec does (link):
Perhaps we should completely remove the notion of |
I tackled it from a bit different angle: we can have a step that describes some implicit initialization in the |
Please see #2021 |
https://webaudio.github.io/web-audio-api/#vu-meter-mode has this bit:
but this can't possibly work. Indeed, let's consider what happens when
new VUMeterNode
is called on the control thread. That lands in https://webaudio.github.io/web-audio-api/#instantiation-of-AudioWorkletNode-and-AudioWorkletProcessor the "In order to process a control message for the construction of an AudioWorkletProcessor" steps, right?Now step 4 does
Construct(processorCtor, options)
, whereprocessorCtor
is in this case the class declaration above. That will invoke theconstructor
function defined above. Thesuper(options)
call lands in https://webaudio.github.io/web-audio-api/#dom-audioworkletprocessor-audioworkletprocessor which does not initialize the "port" member in any way as far as I can tell. That initialization happens in step 5 of the "process a control message for the construction of an AudioWorkletProcessor" steps, which is after the scripted constructor has already returned.So what happens when the script then does
this.port
? https://webaudio.github.io/web-audio-api/#AudioWorkletProcessor-attributes seems to assume that the port is always initialized when the getter can be called, but that's clearly not the case.The only way I see to make this (that is, being able to use the port in constructors of subclasses of
AudioWorkletProcessor
) work is to make the port a required argument to theAudioWorkletProcessor
constructor, either directly or via the existing options object. Then the constructor could set up the port, and there would be no issue here.@padenot @karlt
P.S. I looked at what Chrome implements, and it simply looks nothing like the spec. What they do is effectively store the port in a slot on the global right before step 4 of "process a control message for the construction of an AudioWorkletProcessor" and putt it out of there in the
AudioWorkletProcessor
constructor, so it's initialized by the time thesuper()
call returns. If the expectation is that UAs need to do that, then the spec should say so instead of saying something totally different.The text was updated successfully, but these errors were encountered: