Bug 1454625 - Schedule settings update before setting mImage. r=padenot
authorAndreas Pehrson <pehrsons@mozilla.com>
Tue, 17 Apr 2018 11:14:19 +0200
changeset 414307 197abd266c8b2b6ba61ebbe9fefa6e72a8b5e273
parent 414306 4b6f77cfd686930e3be525c51d10b825549c5eae
child 414308 a3c07c7bfce3ca859fafdf7fc194c23ba1f67fc9
push id33865
push userbtara@mozilla.com
push dateWed, 18 Apr 2018 22:35:14 +0000
treeherdermozilla-central@e4c4c8159924 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot
bugs1454625
milestone61.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 1454625 - Schedule settings update before setting mImage. r=padenot MozReview-Commit-ID: 9IasAgJImuI
dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
dom/media/webrtc/MediaEngineRemoteVideoSource.h
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -616,35 +616,32 @@ MediaEngineRemoteVideoSource::DeliverFra
   static uint32_t frame_num = 0;
   LOGFRAME(("frame %d (%dx%d)->(%dx%d); rotation %d, timeStamp %u, "
             "ntpTimeMs %" PRIu64 ", renderTimeMs %" PRIu64,
             frame_num++, aProps.width(), aProps.height(), dst_width, dst_height,
             aProps.rotation(), aProps.timeStamp(), aProps.ntpTimeMs(),
             aProps.renderTimeMs()));
 #endif
 
-  bool sizeChanged = false;
-  {
-    MutexAutoLock lock(mMutex);
-    // implicitly releases last image
-    sizeChanged = (!mImage && image) ||
-                  (mImage && image && mImage->GetSize() != image->GetSize());
-    mImage = image.forget();
-    mImageSize = mImage->GetSize();
-  }
-
-  if (sizeChanged) {
+  if (mImageSize.width != dst_width || mImageSize.height != dst_height) {
     NS_DispatchToMainThread(NS_NewRunnableFunction(
         "MediaEngineRemoteVideoSource::FrameSizeChange",
         [settings = mSettings, dst_width, dst_height]() mutable {
       settings->mWidth.Value() = dst_width;
       settings->mHeight.Value() = dst_height;
     }));
   }
 
+  {
+    MutexAutoLock lock(mMutex);
+    // implicitly releases last image
+    mImage = image.forget();
+    mImageSize = mImage->GetSize();
+  }
+
   // We'll push the frame into the MSG on the next Pull. This will avoid
   // swamping the MSG with frames should it be taking longer than normal to run
   // an iteration.
 
   return 0;
 }
 
 uint32_t
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.h
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.h
@@ -219,17 +219,17 @@ private:
   RefPtr<layers::Image> mImage;
 
   // A buffer pool used to manage the temporary buffer used when rescaling
   // incoming images. Cameras IPC thread only.
   webrtc::I420BufferPool mRescalingBufferPool;
 
   // The intrinsic size of the latest captured image, so we can feed black
   // images of the same size while stopped.
-  // Set under mMutex on the owning thread. Accessed under one of the two.
+  // Set under mMutex on the Cameras IPC thread. Accessed under one of the two.
   gfx::IntSize mImageSize = gfx::IntSize(0, 0);
 
   // The current settings of this source.
   // Note that these may be different from the settings of the underlying device
   // since we scale frames to avoid fingerprinting.
   // Members are main thread only.
   const RefPtr<media::Refcountable<dom::MediaTrackSettings>> mSettings;