Bug 1121692 - Fix potential race condition with mWaitingForSeekData. r=mattwoodrow, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Fri, 16 Jan 2015 10:58:00 -0800
changeset 240197 d84cc3f47d9455ccf3a627b5374ef114f2ad77c3
parent 240196 c8c80f89364d439923f8f4a4fbb7389e15c57c92
child 240198 dcd2e226ad99ba7bbd8e28f62f543666089032f5
push id7494
push userryanvm@gmail.com
push dateTue, 20 Jan 2015 16:27:23 +0000
treeherdermozilla-aurora@1b311ea59722 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, sledru
bugs1121692
milestone37.0a2
Bug 1121692 - Fix potential race condition with mWaitingForSeekData. r=mattwoodrow, a=sledru mWaitingForSeekData is modified in NotifyTimeRangesChanged, which is invoked on the main thread. One would hope that all of these other members are only touched on the decode task queue.
dom/media/mediasource/MediaSourceReader.cpp
--- a/dom/media/mediasource/MediaSourceReader.cpp
+++ b/dom/media/mediasource/MediaSourceReader.cpp
@@ -670,16 +670,17 @@ MediaSourceReader::AttemptSeek()
 {
   // Make sure we don't hold the monitor while calling into the reader
   // Seek methods since it can deadlock.
   {
     ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     if (!mWaitingForSeekData || !TrackBuffersContainTime(mPendingSeekTime)) {
       return;
     }
+    mWaitingForSeekData = false;
   }
 
   ResetDecode();
   for (uint32_t i = 0; i < mTrackBuffers.Length(); ++i) {
     mTrackBuffers[i]->ResetDecode();
   }
 
   // Decoding discontinuity upon seek, reset last times to seek target.
@@ -692,21 +693,16 @@ MediaSourceReader::AttemptSeek()
     mVideoReader->Seek(mPendingSeekTime, 0)
                 ->Then(GetTaskQueue(), __func__, this,
                        &MediaSourceReader::OnVideoSeekCompleted,
                        &MediaSourceReader::OnSeekFailed);
     MSE_DEBUG("MediaSourceReader(%p)::Seek video reader=%p", this, mVideoReader.get());
   } else {
     OnVideoSeekCompleted(mPendingSeekTime);
   }
-
-  {
-    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
-    mWaitingForSeekData = false;
-  }
 }
 
 nsresult
 MediaSourceReader::GetBuffered(dom::TimeRanges* aBuffered)
 {
   ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   MOZ_ASSERT(aBuffered->Length() == 0);
   if (mTrackBuffers.IsEmpty()) {