Bug 1304948 - beta: 1.Check the target cue belongs to corresponding TextTrack. 2. Don't run TimeMarchesOn when shutdown. r=rillian, a=ritu
authorbechen <bechen@mozilla.com>
Mon, 03 Oct 2016 11:19:08 +0800
changeset 350748 69c68bce430d468037bc82223acb9ea4155dbc7d
parent 350747 fa0189889818d142c9e7161f72419c9a6c501adf
child 350749 9f719285cd161a538446d0601162b474914e8a14
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian, ritu
bugs1304948
milestone50.0
Bug 1304948 - beta: 1.Check the target cue belongs to corresponding TextTrack. 2. Don't run TimeMarchesOn when shutdown. r=rillian, a=ritu
dom/html/TextTrackManager.cpp
dom/media/TextTrack.cpp
--- a/dom/html/TextTrackManager.cpp
+++ b/dom/html/TextTrackManager.cpp
@@ -555,18 +555,18 @@ TextTrackManager::DispatchTimeMarchesOn(
 // https://html.spec.whatwg.org/multipage/embedded-content.html#time-marches-on
 void
 TextTrackManager::TimeMarchesOn()
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   mTimeMarchesOnDispatched = false;
 
-  // Early return if we don't have any TextTracks.
-  if (!mTextTracks || mTextTracks->Length() == 0) {
+  // Early return if we don't have any TextTracks or shutting down.
+  if (!mTextTracks || mTextTracks->Length() == 0 || mShutdown) {
     return;
   }
 
   nsISupports* parentObject =
     mMediaElement->OwnerDoc()->GetParentObject();
   if (NS_WARN_IF(!parentObject)) {
     return;
   }
--- a/dom/media/TextTrack.cpp
+++ b/dom/media/TextTrack.cpp
@@ -145,19 +145,22 @@ TextTrack::AddCue(TextTrackCue& aCue)
     }
   }
   SetDirty();
 }
 
 void
 TextTrack::RemoveCue(TextTrackCue& aCue, ErrorResult& aRv)
 {
+  // Bug1304948, check the aCue belongs to the TextTrack.
+  mCueList->RemoveCue(aCue, aRv);
+  if (aRv.Failed()) {
+    return;
+  }
   aCue.SetActive(false);
-
-  mCueList->RemoveCue(aCue, aRv);
   aCue.SetTrack(nullptr);
   if (mTextTrackList) {
     HTMLMediaElement* mediaElement = mTextTrackList->GetMediaElement();
     if (mediaElement) {
       mediaElement->NotifyCueRemoved(aCue);
     }
   }
   SetDirty();