Bug 1512197 - Temporary fix for incorrect sharing of MozPromiseHolder in MediaManager. r=jya
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 05 Dec 2018 21:46:51 +0000
changeset 508699 73f92838946aac0aab5760bada1a1e8e2218a3e1
parent 508698 c88d2cb951ca8b2622ed90f921194902bd4bb712
child 508700 3f5a132b7e4f7579209ca906f9ec79059e426f26
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1512197
milestone65.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 1512197 - Temporary fix for incorrect sharing of MozPromiseHolder in MediaManager. r=jya Differential Revision: https://phabricator.services.mozilla.com/D13847
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1118,18 +1118,24 @@ class GetUserMediaStreamRunnable : publi
           mWindowID(aWindowID),
           mGraph(aTrack->GraphImpl()),
           mStream(new nsMainThreadPtrHolder<DOMMediaStream>(
               "TracksCreatedListener::mStream", aStream)),
           mTrack(new nsMainThreadPtrHolder<MediaStreamTrack>(
               "TracksCreatedListener::mTrack", aTrack)) {}
 
     ~TracksCreatedListener() {
-      mHolder.RejectIfExists(
-          MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError), __func__);
+      RejectIfExists(MakeRefPtr<MediaMgrError>(MediaMgrError::Name::AbortError),
+                     __func__);
+    }
+
+    // TODO: The need for this should be removed by an upcoming refactor.
+    void RejectIfExists(RefPtr<MediaMgrError>&& aError,
+                        const char* aMethodName) {
+      mHolder.RejectIfExists(std::move(aError), aMethodName);
     }
 
     void NotifyOutput(MediaStreamGraph* aGraph,
                       StreamTime aCurrentTrackTime) override {
       // It's enough to know that one of the tracks have output, as both tracks
       // are guaranteed to be created in the graph at this point.
 
       if (mDispatchedTracksCreated) {
@@ -1379,30 +1385,30 @@ class GetUserMediaStreamRunnable : publi
               ("GetUserMediaStreamRunnable::Run: starting success callback "
                "following InitializeAsync()"));
           // Initiating and starting devices succeeded.
           track->AddListener(tracksCreatedListener);
           windowListener->ChromeAffectingStateChanged();
           manager->SendPendingGUMRequest();
         },
         [manager = mManager, windowID = mWindowID,
-         holder = std::move(mHolder)](RefPtr<MediaMgrError>&& aError) mutable {
+         tracksCreatedListener](RefPtr<MediaMgrError>&& aError) {
           MOZ_ASSERT(NS_IsMainThread());
           LOG(
               ("GetUserMediaStreamRunnable::Run: starting failure callback "
                "following InitializeAsync()"));
           // Initiating and starting devices failed.
 
           // Only run if the window is still active for our window listener.
           if (!(manager->IsWindowStillActive(windowID))) {
             return;
           }
           // This is safe since we're on main-thread, and the windowlist can
           // only be invalidated from the main-thread (see OnNavigation)
-          holder.Reject(std::move(aError), __func__);
+          tracksCreatedListener->RejectIfExists(std::move(aError), __func__);
         });
 
     if (!IsPincipalInfoPrivate(mPrincipalInfo)) {
       // Call GetPrincipalKey again, this time w/persist = true, to promote
       // deviceIds to persistent, in case they're not already. Fire'n'forget.
       media::GetPrincipalKey(mPrincipalInfo, true)
           ->Then(GetCurrentThreadSerialEventTarget(), __func__,
                  [](const PrincipalKeyPromise::ResolveOrRejectValue& aValue) {