Bug 1329075 - Fix assertion failure in debug build. r?jesup draft
authorAndreas Pehrson <pehrsons@gmail.com>
Mon, 09 Jan 2017 16:36:00 +0100
changeset 457696 686e02514fe8db51ab8d819579636f2c3a2384d8
parent 454520 87efd66165ddaa1b97608b92cd651b73c11aca6f
child 457697 d81ece733839b4bd17f32e5054119f7b8f963036
push id40870
push userbmo:pehrson@telenordigital.com
push dateMon, 09 Jan 2017 18:13:44 +0000
reviewersjesup
bugs1329075
milestone53.0a1
Bug 1329075 - Fix assertion failure in debug build. r?jesup With the attached test case I was failing an assert in a debug build because NotifyMediaTrackEnabled exited early due to `mReadyState == HAVE_NOTHING` but NotifyMediaTrackDisabled didn't. The latter would fail an assert. MozReview-Commit-ID: 7Frpj62s0Bc
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2015,16 +2015,22 @@ void HTMLMediaElement::NotifyMediaTrackD
       VideoFrameContainer* container = GetVideoFrameContainer();
       if (mSrcStreamIsPlaying && container) {
         mSelectedVideoStreamTrack->RemoveVideoOutput(container);
       }
       mSelectedVideoStreamTrack = nullptr;
     }
   }
 
+  if (mReadyState == HAVE_NOTHING) {
+    // No MediaStreamTracks are captured until we have metadata, and code
+    // below doesn't do anything for captured decoders.
+    return;
+  }
+
   for (OutputMediaStream& ms : mOutputStreams) {
     if (ms.mCapturingDecoder) {
       MOZ_ASSERT(!ms.mCapturingMediaStream);
       continue;
     }
     MOZ_ASSERT(ms.mCapturingMediaStream);
     for (int32_t i = ms.mTrackPorts.Length() - 1; i >= 0; --i) {
       if (ms.mTrackPorts[i].first() == aTrack->GetId()) {