WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.05k stars 167 forks source link

Lifetime of pending processor construction data and exceptions in instantiation of AudioWorkletProcessor when AudioWorkletProcessor() constructor is not invoked #2119

Closed karlt closed 3 years ago

karlt commented 4 years ago

The instantiation of AudioWorkletProcessor algorithm sets the node reference and transferred port of the AudioWorkletGlobalScope's pending processor construction data.

Only the AudioWorkletProcessor() constructor arranges for this data to be cleared, but "Construct a callback function" in the instantiation of AudioWorkletProcessor does not necessarily invoke the AudioWorkletProcessor() constructor.

I assume that steps to "Empty the pending processor construction data slot" and "queue a task to the control thread to fire an event named processorerror" should be moved from the AudioWorkletProcessor() constructor to the instantiation of AudioWorkletProcessor algorithm?

Some more details are in https://github.com/WebAudio/web-audio-api/issues/2096, but perhaps all the details there occluded the core of the issue.

guest271314 commented 4 years ago

If gather this issue correctly this means there is a significant difference in processing between

constructor() {
  this.port.onmessage = e => {
    // messages, data transferred immediately upon AudioWorkletNode()
  }
}

and

constructor() {
  this.port.onmessage = this.handMessage.bind(this);
}
handleMessage(e) {
  // do stuff
}

as to when process() is contructed begins processing inputs, outputs?