Closed Bug 614136 Opened 11 years ago Closed 11 years ago

Hang in sa_stream_write on shutdown when IPC enabled due to stream being paused

Categories

(Core :: Audio/Video, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: kinetik, Unassigned)

References

Details

I just hit a shutdown hang where we're stuck in sa_stream_write where snd_pcm_writei returns 0 frames written.  The stream has previously been paused, and the don't-write-if-paused assertions in nsAudioStream.cpp fired.  It looks like having mPaused in the remote/child process is not sufficient to avoid this.
Easy to reproduce: pause and unpause a few times, eventually you'll hit the assertion.  The browser will hang in shutdown after this.

The problem is that the Write events are requeued on gAudioPlaybackThread after being received over IPC on the main thread.  Pause/Resume requests (because they're not blocking), run directly from the main thread.  So the following ordering causes this problem:

Remote: Send Write
Remote: Send Pause
Local: Recv Write
  -> Queue WriteEvent
Local: Recv Pause
 -> Local: Pause
Local: Write

We can fix this by shunting all of the Local Receives to gAudioPlaybackThread, or by having the Local::Write return an error if mPaused is already set.  The same event reordering problem happens for shutdown, but Local::Write is protected by mInError for that case already.
Depends on: 614160
Bug 614160 contains a minimal fix for this: shunt pause/resume calls to the same thread used for write.
This was fixed by bug 614160.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Is there a way I can verify this bug?
In Fennec, start a video element playing, then click play/pause repeatedly, then close the browser.  Verify that the browser has shutdown completely.
Verified using the desktop simulator.  I don't have a fennec-capable device; someone might want to verify it that way.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.