Bug 1351053. P2 - fix data race in accessing mAudioDemuxer/mVideoDemuxer, r=jya, a=jcristau
authorJW Wang <jwwang@mozilla.com>
Thu, 13 Apr 2017 15:42:52 +0800
changeset 395888 3c96fce8a837db568f7fd3104f95cde396857e54
parent 395887 34ba7c94dc4c178b480831940af036b9ade8726f
child 395889 8b44c61e2e5a38f9d67c475834f4c16f0ae019a3
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, jcristau
bugs1351053
milestone54.0a2
Bug 1351053. P2 - fix data race in accessing mAudioDemuxer/mVideoDemuxer, r=jya, a=jcristau 1. http://searchfox.org/mozilla-central/rev/944f87c575e8a0bcefc1ed8efff10b34cf7a5169/dom/media/MediaFormatReader.cpp#755 mAudioDemuxer is modified on the task queue thread of MFR in Shutdown() called by MFR::Shutdown(). 2. http://searchfox.org/mozilla-central/rev/944f87c575e8a0bcefc1ed8efff10b34cf7a5169/dom/media/MediaFormatReader.cpp#1082 mAudioDemuxer is read on the task queue thread of DemuxerProxy in DemuxerProxy::NotifyDataArrived(). MozReview-Commit-ID: 8qLAzNKjuzb
dom/media/MediaFormatReader.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -747,25 +747,25 @@ public:
 
   ~DemuxerProxy()
   {
     MOZ_COUNT_DTOR(DemuxerProxy);
   }
 
   RefPtr<ShutdownPromise> Shutdown()
   {
-    mData->mAudioDemuxer = nullptr;
-    mData->mVideoDemuxer = nullptr;
     RefPtr<Data> data = mData.forget();
     return InvokeAsync(mTaskQueue, __func__, [data]() {
       // We need to clear our reference to the demuxer now. So that in the event
       // the init promise wasn't resolved, such as what can happen with the
       // mediasource demuxer that is waiting on more data, it will force the
       // init promise to be rejected.
       data->mDemuxer = nullptr;
+      data->mAudioDemuxer = nullptr;
+      data->mVideoDemuxer = nullptr;
       return ShutdownPromise::CreateAndResolve(true, __func__);
     });
   }
 
   RefPtr<MediaDataDemuxer::InitPromise> Init();
 
   Wrapper*
   GetTrackDemuxer(TrackType aTrack, uint32_t aTrackNumber)