Bug 1593739 - Shut down the watch manager during Unlink to prevent future notify tasks. r=bryce
☠☠ backed out by d215b3534e04 ☠ ☠
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 15 Nov 2019 09:39:15 +0000
changeset 502153 0f20566c7b2fa7b1204e432828940fd81ab2a197
parent 502152 2f87baa2ba544e90dacc26eb46afd5b636806b26
child 502154 8157c99955b178839710ca42af23925478a680b2
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbryce
bugs1593739
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1593739 - Shut down the watch manager during Unlink to prevent future notify tasks. r=bryce Differential Revision: https://phabricator.services.mozilla.com/D51906
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1687,16 +1687,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSelectedVideoStreamTrack)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingPlayPromises)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSeekDOMPromise)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSetMediaKeysDOMPromise)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement,
                                                 nsGenericHTMLElement)
+  tmp->mWatchManager.Shutdown();
   tmp->RemoveMutationObserver(tmp);
   if (tmp->mSrcStream) {
     // Need to EndMediaStreamPlayback to clear mSrcStream and make sure
     // everything gets unhooked correctly.
     tmp->EndSrcMediaStreamPlayback();
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mSrcAttrStream)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mMediaSource)
@@ -5069,27 +5070,30 @@ void HTMLMediaElement::EndSrcMediaStream
   }
   if (mFirstFrameListener) {
     mSelectedVideoStreamTrack->RemoveVideoOutput(mFirstFrameListener);
   }
   mSelectedVideoStreamTrack = nullptr;
   mFirstFrameListener = nullptr;
 
   if (mMediaStreamRenderer) {
-    mWatchManager.Unwatch(mPaused,
-                          &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
-    mWatchManager.Unwatch(mReadyState,
-                          &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
-    mWatchManager.Unwatch(mSrcStreamPlaybackEnded,
-                          &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
-    mWatchManager.Unwatch(
-        mSrcStreamPlaybackEnded,
-        &HTMLMediaElement::UpdateSrcStreamReportPlaybackEnded);
-    mWatchManager.Unwatch(mMediaStreamRenderer->CurrentGraphTime(),
-                          &HTMLMediaElement::UpdateSrcStreamTime);
+    if (!mWatchManager.IsShutdown()) {
+      mWatchManager.Unwatch(
+          mPaused, &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
+      mWatchManager.Unwatch(
+          mReadyState, &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
+      mWatchManager.Unwatch(
+          mSrcStreamPlaybackEnded,
+          &HTMLMediaElement::UpdateSrcStreamPotentiallyPlaying);
+      mWatchManager.Unwatch(
+          mSrcStreamPlaybackEnded,
+          &HTMLMediaElement::UpdateSrcStreamReportPlaybackEnded);
+      mWatchManager.Unwatch(mMediaStreamRenderer->CurrentGraphTime(),
+                            &HTMLMediaElement::UpdateSrcStreamTime);
+    }
     mMediaStreamRenderer->Shutdown();
     mMediaStreamRenderer = nullptr;
   }
 
   mSrcStream->UnregisterTrackListener(mMediaStreamTrackListener.get());
   mMediaStreamTrackListener = nullptr;
   mSrcStreamPlaybackEnded = false;
   mSrcStreamReportPlaybackEnded = false;