-
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
Device-related error reporting via AudioContext.onerror #2567
Comments
Teleconf:
More thoughts:
|
More details on the teleconf discussion 02/08:
The expected spec change:
|
I propose suspending the |
There are 2 major scenarios that an error may occur:
Falling back to the default sink ID is also a possibility. So here is the list of proposals by far:
|
Teleconference 3/7: This change is only relevant to the device selection via the AudioContext constructor:
AudioContext.onerror can also be dispatched:
The following spec text needs to be removed:
This means that the creation of AudioContext can't be failed. It will succeed no matter what, but invalid config options (e.g. invalid sinkId) will put the context in a suspended status with an error message via the onerror event handler. |
Some expected changes: partial interface AudioContext : BaseAudioContext {
attribute EventHandler onerror;
}
Here we need to queue a task to dispatch an event to WDYT? @padenot @chrisguttandin @mjwilson-google @gsinafirooz |
I think the acquire system resources section is part of the setSinkId() method, correct? So we would also need additional text in:
|
No, the location I meant was the second half of the AudioContext constructor.
I think we have two options:
The second one is my preference, but would love to hear what others think. |
I see it now. Thank you. We probably should be explicit that onError is for device / sink problems, and not other types of errors.
This would be in https://webaudio.github.io/web-audio-api/#rendering-loop, correct? It would be a more explicit specification, which should increase consistency across implementers but will give less flexibility. The rendering loop is one of the more performance-critical sections, so I would prefer to not put anything in it that's not strictly necessary.
This would give implementers more flexibility. However, I'm worried that if we underspecify it we could have interoperability problems. Could we write it as a normative SHOULD? |
As long as there's defined ordering between |
Based on the discussion so far, The rendering loop algorithm 4.1 already checks the rendering state flag: Re padenot@'s thought:
One thing I am not so sure is that 1) might not called from the WebAudio's render thread. It could be a platform's own I/O thread. I'll have to dig into Chromium code to confirm this. |
Indeed, it can also be both the thread on which the real-time callbacks are called, or some other non-realtime thread on the same platform (sometimes it differs depending on the version or settings). Generally we see the following breakdown:
In all cases Gecko doesn't assume anything about the thread and immediately dispatches an event to a known thread it has, for uniform handling. |
Chromium will dispatch the event to WebAudio rendering thread or the main thread. WebAudio never interacts with platform audio threads directly. We can ensure that the event always arrives on the main thread if it's preferred. |
@padenot Thanks for looking into that. That confirms my suspicions. @o1ka Thanks for jumping in! The discussion above is not about In Chromium, I believe this is called from AOD::NotifyRenderCallbackOfError() and this is the browser's I/O thread - please correct me if I am mistaken - not the WebAudio render thread. Hence the question: how do we describe this with the current spec text (without introducing new concepts/terms) when we don't define browser's I/O thread anywhere? |
@hoch thanks for pointing to that one. Why do we need to describe the behavior in terms of threads? Isn't it an implementation detail? As I see it: the error can occur during construction, during setSinkId() processing, or during rendering. The sources of error may be: invalid sink id (by mistake, or a sink is removed, or no permissions) or device malfunction/system malfunction (ex: CoreAudio crash). |
That's because unlike other audio-related APIs on the web, the Web Audio API spec exposes the notion of the control thread and the render thread. The problem is that we want to stop the render loop by setting (This is what @padenot meant by "We can spec that no process can happen after onerror has been triggered from the backend", which I agree)
I agree that it is something obvious, but we still need to explain how that's guaranteed. One thing we have not discussed so far is the interaction between |
And also setSinkId() processing
I don't quire understand the question - what does interrupt mean here?
Yes, this makes sense. And also this seems to be enough? How error events are shuffled between internal threads inside, let's say, chromium, and what additional threads (IO or other) are involved are implementation details. For example, IO thread is involved when AudioContext starts/stops rendering - this is not surfaced anywhere. |
For example, can the audio render thread (AudioOutputDevice in Chromium) can invoke an error notification (e.g.
If you look into the Web Audio API specification in details, you'll see we acknowledge the existence of the audio render thread and some algorithms are executed on that thread. So I kinda agree with you that we can get away with the "implementation detail" argument for some parts, but there are other parts we need to specify clearly. I won't know for sure until I start writing an actual PR. (which is my next step) |
There were several requests in the past to expose an event handler for device-related error reporting.
Currently AudioContext does not expose this type of error; it just silently fails and falls back to browser-specific default. The spec says:
One proposal would be having
onrendererror
under AudioContext. This can be used for cases like:The text was updated successfully, but these errors were encountered: