bug 1092932 detach MediaSource before initiating MDStateMachine shutdown r=bholley
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 04 Nov 2014 17:24:52 +1300
changeset 230165 b6420c451f452ad458d0935de5da170aff3d34c8
parent 230164 7bb233454a290eec9b9fafdf0f13db120b62dd5e
child 230166 0b298d91fbddcf915f25c3ac3daebfa3a22f9393
push id7326
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:58:42 +0000
treeherdermozilla-aurora@d3a3b2a0f2f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1092932
milestone36.0a1
bug 1092932 detach MediaSource before initiating MDStateMachine shutdown r=bholley to avoid races between the detach process and decoder task queue shutdown.
dom/media/mediasource/MediaSourceDecoder.cpp
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -90,21 +90,23 @@ MediaSourceDecoder::GetSeekable(dom::Tim
   MSE_DEBUG("MediaSourceDecoder(%p)::GetSeekable ranges=%s", this, DumpTimeRanges(aSeekable).get());
   return NS_OK;
 }
 
 void
 MediaSourceDecoder::Shutdown()
 {
   MSE_DEBUG("MediaSourceDecoder(%p)::Shutdown", this);
-  MediaDecoder::Shutdown();
-
+  // Detach first so that TrackBuffers are unused on the main thread when
+  // shut down on the decode task queue.
   if (mMediaSource) {
     mMediaSource->Detach();
   }
+
+  MediaDecoder::Shutdown();
   // Kick WaitForData out of its slumber.
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
   mon.NotifyAll();
 }
 
 /*static*/
 already_AddRefed<MediaResource>
 MediaSourceDecoder::CreateResource(nsIPrincipal* aPrincipal)