You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[audioworklet] Error handling in AudioWorkletGlobalScope #1282
Currently the Worklet infrastructure does not define the error handling clearly. (issue) AudioWorkletGlobalScope can do its own error handling, but it is likely to cause the layering problem when the Worklet infra introduces the error handling later.
When this is addressed by the Worklet infra, downstream the fix to AudioWorkletGlobalScope.
It seems to me it's somewhat tied to worklets that expose messaging capabilities. And thus far only audio worklets have that.
Though I suppose the benefit for worklets with no messaging capabilities is that they could use it as some kind of error handling fallback? Not entirely sure what the use cases for that would be.
(If all worklets need it though, we should just use EventTarget throughout and port the various window.onerror and corresponding promise handlers to worklets.)
The messaging capabilities is limited to the pair of AudioWorkletNode/AudioWorkletProcessor. The WorkletGlobalScope itself does not have any messaging channel. Wouldn't it be simpler to have the identical setup with the worker global scope?
I meant that if you cannot message that exceptions happened to the parent process, it's rather unclear to me what the benefit of a catchall error handler is.
I agree this is confusing. I would like to hear from @bfgeek (probably in w3c/css-houdini-drafts#433) what the intent is for worklets and errors. Typically large sites like to have some mechanism of catching errors and reporting them to the server, but indeed most worklets don't have enough communication capabilities to do that.
The rough plan for paintWorklet was to do a reporting API similar to the Content-Security-Policy-Report-Only header for that usecase. (For paintWorklet we don't want a back communication channel from worklet->main).
How would you prevent the paint worklet leaking data that way? (At least I thought part of the concern was breaking the same-origin policy, but I haven't followed closely.)
The primary concern for paintWorklet is people encoding paint assumptions into their code, e.g. what a specific browsers pre-paint window is, and attempting to react to it (e.g. a infinite list using this data). With a reporting uri (which I'm not advocating we do now, but when people start asking for it), this data could be batched, and out of band.
@mdjp I think you should keep this open. While a generic variant for all worklets might not be feasible, given that audio worklets have message passing we could do something here. It's fine to wait for a resolution there, but it seems good to keep this for tracking purposes.
Is this implementation detail related with the present issue?
If it is, why an Event (and not an ErrorEvent) is returned? I guess the main use of catching errors in the parent script is logging them; with no lineno, message or fileName, catching errors is pretty useless.
ErrorEvent is not exposed to the worklet system yet. So technically the WorkletGlobalScope is not capable of creating an ErrorEvent object to throw. This is why the current Chrome impl does not have that yet.
Technically we should use OnErrorEventHandler for the proper error handling. In that sense, the regular EventHandler receiving the Event is not a wrong behavior.
The error handling of Worklet infra is still under the discussion, so I prefer to wait to have more spec work on the error handling mechanism before we design the WebAudio specific one.
I believe this is why we pushed this issue to V2 and sorry if this was not clear.
Sure. I think the best bet is the associated Houdini issue. @annevk, @domenic and @bfgeek have better idea what needs to be done here. My preference is to expose ErrorEvent in the WorkletGlobalScope rather than AudioWorkletGlobalScope, but other folks might think otherwise.
Also we might have to escalate the issue in the AudioWG to mark this as a "v1 blocker".
onprocessorerror provides a minimal notification of error when an error is associated with a node or its processor, but there is no notification of exceptions during "Run a module script", which is w3c/css-houdini-drafts#407
I think rejecting the promise from .addModule() might be an obvious solution, but that's not up to us. This is an external dependency and it should be downstreamed when Hoduini group fixes the script loading mechanism.
In that sense, onprocessorerror makes sense because it is specifically for the Audio Worklet operation.
Activity
annevk commentedon Aug 6, 2017
It seems to me it's somewhat tied to worklets that expose messaging capabilities. And thus far only audio worklets have that.
Though I suppose the benefit for worklets with no messaging capabilities is that they could use it as some kind of error handling fallback? Not entirely sure what the use cases for that would be.
(If all worklets need it though, we should just use
EventTargetthroughout and port the variouswindow.onerrorand corresponding promise handlers to worklets.)cc @domenic
hoch commentedon Aug 7, 2017
The messaging capabilities is limited to the pair of AudioWorkletNode/AudioWorkletProcessor. The WorkletGlobalScope itself does not have any messaging channel. Wouldn't it be simpler to have the identical setup with the worker global scope?
annevk commentedon Aug 8, 2017
I meant that if you cannot message that exceptions happened to the parent process, it's rather unclear to me what the benefit of a catchall error handler is.
domenic commentedon Aug 8, 2017
I agree this is confusing. I would like to hear from @bfgeek (probably in w3c/css-houdini-drafts#433) what the intent is for worklets and errors. Typically large sites like to have some mechanism of catching errors and reporting them to the server, but indeed most worklets don't have enough communication capabilities to do that.
bfgeek commentedon Aug 9, 2017
The rough plan for paintWorklet was to do a reporting API similar to the Content-Security-Policy-Report-Only header for that usecase. (For paintWorklet we don't want a back communication channel from worklet->main).
e.g. a bad proposal
For those worklets that can have this backchannel, those that want it can extend and do a similar thing to workers? E.g.
And get Worklet to inherit from EventTarget for these?
annevk commentedon Aug 9, 2017
How would you prevent the paint worklet leaking data that way? (At least I thought part of the concern was breaking the same-origin policy, but I haven't followed closely.)
bfgeek commentedon Aug 9, 2017
The primary concern for paintWorklet is people encoding paint assumptions into their code, e.g. what a specific browsers pre-paint window is, and attempting to react to it (e.g. a infinite list using this data). With a reporting uri (which I'm not advocating we do now, but when people start asking for it), this data could be batched, and out of band.
joeberkovitz commentedon Sep 27, 2017
Since we don't have info from the Worklet folks yet, we propose deferring this. Its absence doesn't compromise the API or cause future problems.
4 remaining items
annevk commentedon Mar 28, 2018
@mdjp I think you should keep this open. While a generic variant for all worklets might not be feasible, given that audio worklets have message passing we could do something here. It's fine to wait for a resolution there, but it seems good to keep this for tracking purposes.
hoch commentedon Apr 5, 2018
Reopening this issue per feedback from @annevk and @domenic.
cristiano-belloni commentedon Apr 24, 2018
Excuse me if I'm not getting this, but implementation-wise (in Chrome 66),
AudioWorkletNodes have aonprocessorerrorcallback, which has anEventofprocessorerrortype as only argument (pretty useless, since it has nolinenoormessage). There is even an example of catching errors from Audio Worklets in the GoogleChromeLabs worklet samples.Event(and not anErrorEvent) is returned? I guess the main use of catching errors in the parent script is logging them; with nolineno,messageorfileName, catching errors is pretty useless.hoch commentedon Apr 25, 2018
In short, someone needs to do the spec work.
https://html.spec.whatwg.org/multipage/webappapis.html#the-errorevent-interface
ErrorEventis not exposed to the worklet system yet. So technically theWorkletGlobalScopeis not capable of creating anErrorEventobject to throw. This is why the current Chrome impl does not have that yet.https://html.spec.whatwg.org/multipage/workers.html#workerglobalscope
Technically we should use
OnErrorEventHandlerfor the proper error handling. In that sense, the regularEventHandlerreceiving theEventis not a wrong behavior.The error handling of Worklet infra is still under the discussion, so I prefer to wait to have more spec work on the error handling mechanism before we design the WebAudio specific one.
I believe this is why we pushed this issue to V2 and sorry if this was not clear.
cristiano-belloni commentedon Apr 25, 2018
Thanks, @hoch.
Since I care a lot for this feature, is there any things I can do to help / any other place where you'd like me to post about this?
hoch commentedon Apr 25, 2018
Sure. I think the best bet is the associated Houdini issue. @annevk, @domenic and @bfgeek have better idea what needs to be done here. My preference is to expose
ErrorEventin theWorkletGlobalScoperather thanAudioWorkletGlobalScope, but other folks might think otherwise.Also we might have to escalate the issue in the AudioWG to mark this as a "v1 blocker".
annevk commentedon Apr 26, 2018
It seems problematic that Chrome has implemented something here without a specification backing it...
cristiano-belloni commentedon Apr 26, 2018
Just please don't take it away :)
ErrorEventis better thanEvent, butEventis much better than nothing.hoch commentedon Apr 26, 2018
@annevk Chrome implemented the spec as it is now. Can you clarify?
annevk commentedon Apr 26, 2018
@hoch my bad, I thought defining error handling in general was deferred until we figured out what it should look like.
karlt commentedon Sep 21, 2018
onprocessorerror provides a minimal notification of error when an error is associated with a node or its processor, but there is no notification of exceptions during "Run a module script", which is
w3c/css-houdini-drafts#407
hoch commentedon Sep 21, 2018
I think rejecting the promise from
.addModule()might be an obvious solution, but that's not up to us. This is an external dependency and it should be downstreamed when Hoduini group fixes the script loading mechanism.In that sense,
onprocessorerrormakes sense because it is specifically for the Audio Worklet operation.mdjp commentedon Sep 17, 2019
Closing as duplicate https://github.com/WebAudio/web-audio-api-v2/issues/29 in V2