Open Bug 1209408 Opened 10 years ago Updated 3 years ago

NotifyStoppedPlayback/NotifyStartedPlayback races with suspended AudioDestinationNode

Categories

(Core :: Web Audio, defect, P3)

43 Branch
defect

Tracking

()

People

(Reporter: karlt, Unassigned)

References

Details

AudioDestinationNode triggers NotifyStartedPlaying/NotifyStoppedPlaying from two different threads which makes it difficult to keep the notifications in order. The following scenario appears possible: 1. An AudioContext is started on the main thread with an audio node to provide sound to the context. 2. suspend() is called on the audio context (main thread). This triggers NotifyStoppedPlayback() and sends a message to the rendering thread to suspend. 3. The rendering thread processes sound from the audio node and DestinationNodeEngine::ProcessBlock() dispatches InputMutedRunnable(). 4. The rendering thread receives the suspend message and blocks/suspends the stream. ProcessBlock() is not called again for this thread. 5. The main thread processes the InputMutedRunnable() and calls NotifyStartedPlayback(). The last notification is NotifyStartedPlayback, even though the stream is suspended.
(In reply to Ehsan Akhgari (don't ask for review please) from bug 1198386 comment #547) > Do you mind filing a bug with some details on how the stream can get > suspended? When a stream is suspended, it is removed from the mStreams array: https://hg.mozilla.org/mozilla-central/annotate/031db40e2b558c7e4dd0b4c565db4a992c1627c8/dom/media/MediaStreamGraph.cpp#l2846 Processing of streams occurs only for streams in that array: https://hg.mozilla.org/mozilla-central/annotate/031db40e2b558c7e4dd0b4c565db4a992c1627c8/dom/media/MediaStreamGraph.cpp#l975 The mechanism was somewhat different before bug 1189506 landed, but the behavior was similar AIUI.
Hmm, do we receive a notification on the main thread when a stream gets suspended? What can cause this to happen?
The graph doesn't provide any stream-specific notification, but there is a StateChangeTask for the AudioContext, in reply to the message generated in ApplyAudioContextOperation(). https://hg.mozilla.org/mozilla-central/annotate/acdb22976ff86539dc10413c5f366e1fb429a680/dom/media/MediaStreamGraph.cpp#l2903
Rank: 25
Priority: -- → P2
Mass change P2->P3 to align with new Mozilla triage process.
Priority: P2 → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.