Bug 1275554: clear mImage aggressively when no longer needed r=perhsons a=gchang
authorRandell Jesup <rjesup@jesup.org>
Wed, 21 Sep 2016 15:49:38 -0400
changeset 341011 6bd4900e44d64e0fc3f87494b0e0952f42a2ae19
parent 341010 92fbce5dc3e03cce6a2ffc881630baa5e6992d3d
child 341012 51b57560770b0d733148460981683fc1aeb0d284
push id10280
push userrjesup@wgate.com
push dateSun, 13 Nov 2016 04:12:39 +0000
treeherdermozilla-aurora@51b57560770b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersperhsons, gchang
bugs1275554
milestone51.0a2
Bug 1275554: clear mImage aggressively when no longer needed r=perhsons a=gchang MozReview-Commit-ID: GNU7p3CyzjH
dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -202,16 +202,20 @@ nsresult
 MediaEngineRemoteVideoSource::Stop(mozilla::SourceMediaStream* aSource,
                                    mozilla::TrackID aID)
 {
   LOG((__PRETTY_FUNCTION__));
   AssertIsOnOwningThread();
   {
     MonitorAutoLock lock(mMonitor);
 
+    // Drop any cached image so we don't start with a stale image on next
+    // usage
+    mImage = nullptr;
+
     size_t i = mSources.IndexOf(aSource);
     if (i == mSources.NoIndex) {
       // Already stopped - this is allowed
       return NS_OK;
     }
 
     MOZ_ASSERT(mSources.Length() == mPrincipalHandles.Length());
     mSources.RemoveElementAt(i);
@@ -222,19 +226,16 @@ MediaEngineRemoteVideoSource::Stop(mozil
     if (!mSources.IsEmpty()) {
       return NS_OK;
     }
     if (mState != kStarted) {
       return NS_ERROR_FAILURE;
     }
 
     mState = kStopped;
-    // Drop any cached image so we don't start with a stale image on next
-    // usage
-    mImage = nullptr;
   }
 
   mozilla::camera::GetChildAndCall(
     &mozilla::camera::CamerasChild::StopCapture,
     mCapEngine, mCaptureIndex);
 
   return NS_OK;
 }