Bug 1454625 - Schedule settings update before setting mImage. r?padenot
MozReview-Commit-ID: 9IasAgJImuI
--- 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;