From 4fc05e8374e65a815d279e8c6b96a0a72c41b19a Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 4 Aug 2022 18:52:30 -0700 Subject: [PATCH] browser(firefox): run callbacks inside critical section (#16282) Pretty-diff: yury-s/gecko-dev@688b4a7 --- browser_patches/firefox-beta/BUILD_NUMBER | 4 ++-- .../firefox-beta/patches/bootstrap.diff | 21 +++++++++++-------- browser_patches/firefox/BUILD_NUMBER | 4 ++-- .../firefox/patches/bootstrap.diff | 11 ++++++---- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/browser_patches/firefox-beta/BUILD_NUMBER b/browser_patches/firefox-beta/BUILD_NUMBER index 320f038256..c543861d3c 100644 --- a/browser_patches/firefox-beta/BUILD_NUMBER +++ b/browser_patches/firefox-beta/BUILD_NUMBER @@ -1,2 +1,2 @@ -1341 -Changed: yurys@chromium.org Tue Aug 2 13:48:43 PDT 2022 +1342 +Changed: yurys@chromium.org Thu Aug 4 18:33:22 PDT 2022 diff --git a/browser_patches/firefox-beta/patches/bootstrap.diff b/browser_patches/firefox-beta/patches/bootstrap.diff index 95a92f001a..e3356a8ad8 100644 --- a/browser_patches/firefox-beta/patches/bootstrap.diff +++ b/browser_patches/firefox-beta/patches/bootstrap.diff @@ -1422,7 +1422,7 @@ index c16b813f29d8a519673129bb7debaaec0430145a..6f82922ac7e889e55beda7d43da3ebe6 /** Synthesize a touch event. The event types supported are: * touchstart, touchend, touchmove, and touchcancel diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.cc -index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..70150e9271720a562fd646a50d30369965d8521a 100644 +index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..f955c7bace3cedfe0469e59a5e8c5824158c4d50 100644 --- a/dom/media/systemservices/video_engine/desktop_capture_impl.cc +++ b/dom/media/systemservices/video_engine/desktop_capture_impl.cc @@ -123,10 +123,11 @@ int32_t ScreenDeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, @@ -1494,14 +1494,17 @@ index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..70150e9271720a562fd646a50d303699 int32_t DesktopCaptureImpl::StopCaptureIfAllClientsClose() { if (_dataCallBacks.empty()) { return StopCapture(); -@@ -636,6 +656,12 @@ void DesktopCaptureImpl::OnCaptureResult(DesktopCapturer::Result result, +@@ -636,6 +656,15 @@ void DesktopCaptureImpl::OnCaptureResult(DesktopCapturer::Result result, frameInfo.height = frame->size().height(); frameInfo.videoType = VideoType::kARGB; + size_t videoFrameStride = + frameInfo.width * DesktopFrame::kBytesPerPixel; -+ for (auto rawFrameCallback : _rawFrameCallbacks) { -+ rawFrameCallback->OnRawFrame(videoFrame, videoFrameStride, frameInfo); ++ { ++ rtc::CritScope cs(&_apiCs); ++ for (auto rawFrameCallback : _rawFrameCallbacks) { ++ rawFrameCallback->OnRawFrame(videoFrame, videoFrameStride, frameInfo); ++ } + } + size_t videoFrameLength = @@ -2638,7 +2641,7 @@ diff --git a/widget/cocoa/NativeKeyBindings.mm b/widget/cocoa/NativeKeyBindings. index d3e5983259053175584254e7ac01ca9ce024f33a..97f5b851c402fea5477c0ee57af451c62b016eec 100644 --- a/widget/cocoa/NativeKeyBindings.mm +++ b/widget/cocoa/NativeKeyBindings.mm -@@ -492,6 +492,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, +@@ -492,6 +492,13 @@ break; case KEY_NAME_INDEX_ArrowLeft: if (aEvent.IsAlt()) { @@ -2652,7 +2655,7 @@ index d3e5983259053175584254e7ac01ca9ce024f33a..97f5b851c402fea5477c0ee57af451c6 break; } if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) { -@@ -512,6 +519,13 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, +@@ -512,6 +519,13 @@ break; case KEY_NAME_INDEX_ArrowRight: if (aEvent.IsAlt()) { @@ -2666,7 +2669,7 @@ index d3e5983259053175584254e7ac01ca9ce024f33a..97f5b851c402fea5477c0ee57af451c6 break; } if (aEvent.IsMeta() || (aEvent.IsControl() && aEvent.IsShift())) { -@@ -532,6 +546,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, +@@ -532,6 +546,10 @@ break; case KEY_NAME_INDEX_ArrowUp: if (aEvent.IsControl()) { @@ -2677,7 +2680,7 @@ index d3e5983259053175584254e7ac01ca9ce024f33a..97f5b851c402fea5477c0ee57af451c6 break; } if (aEvent.IsMeta()) { -@@ -541,7 +559,7 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, +@@ -541,7 +559,7 @@ instance->AppendEditCommandsForSelector( !aEvent.IsShift() ? ToObjcSelectorPtr(@selector(moveToBeginningOfDocument:)) @@ -2686,7 +2689,7 @@ index d3e5983259053175584254e7ac01ca9ce024f33a..97f5b851c402fea5477c0ee57af451c6 aCommands); break; } -@@ -564,6 +582,10 @@ void NativeKeyBindings::GetEditCommandsForTests(NativeKeyBindingsType aType, +@@ -564,6 +582,10 @@ break; case KEY_NAME_INDEX_ArrowDown: if (aEvent.IsControl()) { diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER index 27867055fd..5f4422dba3 100644 --- a/browser_patches/firefox/BUILD_NUMBER +++ b/browser_patches/firefox/BUILD_NUMBER @@ -1,2 +1,2 @@ -1342 -Changed: yurys@chromium.org Tue Aug 2 13:50:22 PDT 2022 +1343 +Changed: yurys@chromium.org Thu Aug 4 18:29:49 PDT 2022 diff --git a/browser_patches/firefox/patches/bootstrap.diff b/browser_patches/firefox/patches/bootstrap.diff index 5dd86f5510..6a406855c3 100644 --- a/browser_patches/firefox/patches/bootstrap.diff +++ b/browser_patches/firefox/patches/bootstrap.diff @@ -1422,7 +1422,7 @@ index c16b813f29d8a519673129bb7debaaec0430145a..6f82922ac7e889e55beda7d43da3ebe6 /** Synthesize a touch event. The event types supported are: * touchstart, touchend, touchmove, and touchcancel diff --git a/dom/media/systemservices/video_engine/desktop_capture_impl.cc b/dom/media/systemservices/video_engine/desktop_capture_impl.cc -index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..70150e9271720a562fd646a50d30369965d8521a 100644 +index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..f955c7bace3cedfe0469e59a5e8c5824158c4d50 100644 --- a/dom/media/systemservices/video_engine/desktop_capture_impl.cc +++ b/dom/media/systemservices/video_engine/desktop_capture_impl.cc @@ -123,10 +123,11 @@ int32_t ScreenDeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, @@ -1494,14 +1494,17 @@ index 9d4e8fbbfe8d45cc6245c7659423004ad1ceedeb..70150e9271720a562fd646a50d303699 int32_t DesktopCaptureImpl::StopCaptureIfAllClientsClose() { if (_dataCallBacks.empty()) { return StopCapture(); -@@ -636,6 +656,12 @@ void DesktopCaptureImpl::OnCaptureResult(DesktopCapturer::Result result, +@@ -636,6 +656,15 @@ void DesktopCaptureImpl::OnCaptureResult(DesktopCapturer::Result result, frameInfo.height = frame->size().height(); frameInfo.videoType = VideoType::kARGB; + size_t videoFrameStride = + frameInfo.width * DesktopFrame::kBytesPerPixel; -+ for (auto rawFrameCallback : _rawFrameCallbacks) { -+ rawFrameCallback->OnRawFrame(videoFrame, videoFrameStride, frameInfo); ++ { ++ rtc::CritScope cs(&_apiCs); ++ for (auto rawFrameCallback : _rawFrameCallbacks) { ++ rawFrameCallback->OnRawFrame(videoFrame, videoFrameStride, frameInfo); ++ } + } + size_t videoFrameLength =