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 166 forks source link

[audioworklet] AudioWorkletProcessor ondata should just be a callback rather than an EventHandler #1194

Closed bfgeek closed 7 years ago

bfgeek commented 7 years ago

I believe the intention here was to specifically deliver any ondata's sent from the main thread directly before the process method is called for that node?

If so AudioWorkletProcessor shouldn't have ondata being a EventHandler just a callback similar to process.

annevk commented 7 years ago

So if we go down that road we need to:

  1. Change DOM to expose Event and EventTarget in worklets.
  2. Change HTML to expose MessageEvent, MessagePort, and MessageChannel in worklets.

And presumably only audio worklets. I can help with the specification-side of that, but to land changes in those standards we'll also need to have web-platform-tests that I'd prefer someone else to take on.

domenic commented 7 years ago

Technically no need for MessageChannel.

hoch commented 7 years ago

@bfgeek @nhiroki It seems like we have several things to consider in terms of the Worklet infra. (comment, comment) WDYT?

joeberkovitz commented 7 years ago

I've been following this silently so far and I'm all for investigating the use of MessagePort. I just want to throw out an opinion that in terms of frequency, this kind of messaging will typically occur only when the application wants to change an attribute or invoke an operation on a node. It doesn't happen on every render quantum. I am not sure if the concerns about GC are taking this usage profile into account, but maybe it's a legit concern even if the messaging is not so frequent.

padenot commented 7 years ago

If something is possible, it will be abused.

In any case, we have been chatting about this in https://github.com/w3c/css-houdini-drafts/issues/380, and it validates the plan laid out in https://github.com/WebAudio/web-audio-api/issues/1194#issuecomment-294177022.

joeberkovitz commented 7 years ago

From WG call today: @hoch is going to pursue the MessagePort/postMessage approach since it leverages existing spec work. If there are performance problems from GC, they can emerge and be measured.