Bug 1436341 - Fix assertion for when a device operation fails. r=jib
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 07 Mar 2018 12:42:58 +0100
changeset 462019 101b62aa7767367d3d2126ae900018992ac4dcfe
parent 462018 8fb4ddab47308f7daf4442cb8f65471eb67ba422
child 462020 752ad36df388d99d4296d14fc8ee02cde3d49afa
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1436341, 1299515
milestone60.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 1436341 - Fix assertion for when a device operation fails. r=jib The previous assertion was from an earlier developer stage which changed during development of bug 1299515. It assumed that mDeviceEnabled was updated only after passing the assert. In the final version of bug 1299515 that is no longer true, and both the failed and the successful device operation asserts can now be unified to one. MozReview-Commit-ID: KMdnIs0UgPr
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -4096,16 +4096,18 @@ SourceListener::SetEnabledFor(TrackID aT
           (MozPromiseHolder<DeviceOperationPromise>& h) {
             h.Resolve(aEnable ? device->Start() : device->Stop(), __func__);
           });
     }, []() {
       // Timer was canceled by us. We signal this with NS_ERROR_ABORT.
       return DeviceOperationPromise::CreateAndResolve(NS_ERROR_ABORT, __func__);
     })->Then(GetMainThreadSerialEventTarget(), __func__,
     [self, this, &state, aTrackID, aEnable](nsresult aResult) mutable {
+      MOZ_ASSERT_IF(aResult != NS_ERROR_ABORT,
+                    state.mDeviceEnabled == aEnable);
       MOZ_ASSERT(state.mOperationInProgress);
       state.mOperationInProgress = false;
 
       if (state.mStopped) {
         // Device was stopped on main thread during the operation. Nothing to do.
         return;
       }
 
@@ -4115,19 +4117,16 @@ SourceListener::SetEnabledFor(TrackID aT
            aTrackID == kAudioTrack ? "audio" : "video",
            aTrackID,
            NS_SUCCEEDED(aResult) ? "succeeded" : "failed"));
 
       if (NS_FAILED(aResult) && aResult != NS_ERROR_ABORT) {
         // This path handles errors from starting or stopping the device.
         // NS_ERROR_ABORT are for cases where *we* aborted. They need graceful
         // handling.
-        MOZ_ASSERT(state.mDeviceEnabled != aEnable,
-                   "If operating the device failed, the device's `enabled` "
-                   "state must remain at its old value");
         if (aEnable) {
           // Starting the device failed. Stopping the track here will make the
           // MediaStreamTrack end after a pass through the MediaStreamGraph.
           StopTrack(aTrackID);
         } else {
           // Stopping the device failed. This is odd, but not fatal.
           MOZ_ASSERT_UNREACHABLE("The device should be stoppable");
 
@@ -4137,17 +4136,16 @@ SourceListener::SetEnabledFor(TrackID aT
         }
         return;
       }
 
       // This path is for a device operation aResult that was success or
       // NS_ERROR_ABORT (*we* canceled the operation).
       // At this point we have to follow up on the intended state, i.e., update
       // the device state if the track state changed in the meantime.
-      MOZ_ASSERT_IF(NS_SUCCEEDED(aResult), state.mDeviceEnabled == aEnable);
 
       if (state.mTrackEnabled == state.mDeviceEnabled) {
         // Intended state is same as device's current state.
         // Nothing more to do.
         return;
       }
 
       // Track state changed during this operation. We'll start over.