Files
Byron Campen 362b016687 Bug 2040478 - Vendor libwebrtc from 983b4f025f
Upstream commit: https://webrtc.googlesource.com/src/+/983b4f025fb568e404eba87500edfd381d241fce
    [M149] Validate CGImage dimensions in MouseCursorMonitorMac

    Original change's description:
    > Validate CGImage dimensions in MouseCursorMonitorMac
    >
    > This adds missing height checks alongside the existing width checks
    > when processing and scaling the cursor image.
    >
    > Fixed: chromium:513268100
    > Change-Id: Ida1e58334a9d3bda429819e4af51b33afbd0a95d
    > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/472700
    > Reviewed-by: Alexander Cooper <alcooper@chromium.org>
    > Auto-Submit: Johannes Kron <kron@webrtc.org>
    > Commit-Queue: Alexander Cooper <alcooper@chromium.org>
    > Cr-Commit-Position: refs/heads/main@{#47715}

    (cherry picked from commit b343cd4e280980f26b4feb80684f57d5b4324e12)

    Bug: chromium:514928856,chromium:513268100
    Change-Id: Ida1e58334a9d3bda429819e4af51b33afbd0a95d
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/473981
    Auto-Submit: Chrome Cherry Picker <chrome-cherry-picker@chops-service-accounts.iam.gserviceaccount.com>
    Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
    Commit-Queue: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
    Cr-Commit-Position: refs/branch-heads/7827@{#1}
    Cr-Branched-From: d606bc991592fbf4dcbe85e9d05db5e501a5ad42-refs/heads/main@{#47595}
2026-06-01 20:49:03 +00:00

67 lines
3.2 KiB
Diff

From: Dan Minor <dminor@mozilla.com>
Date: Tue, 31 Jul 2018 13:32:00 -0400
Subject: Bug 1376873 - OS X desktop capture fixes; r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D7464
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/02c038eca65c1218b56fdf8937fdeab3d8767fe6
---
modules/desktop_capture/mac/screen_capturer_mac.h | 7 +++++++
modules/desktop_capture/mac/screen_capturer_mac.mm | 4 +++-
modules/desktop_capture/mouse_cursor_monitor_mac.mm | 3 ++-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.h b/modules/desktop_capture/mac/screen_capturer_mac.h
index 127cf5ee24..28f0510e3d 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.h
+++ b/modules/desktop_capture/mac/screen_capturer_mac.h
@@ -114,6 +114,13 @@ class ScreenCapturerMac final : public DesktopCapturer {
// Start, CaptureFrame and destructor have to called in the same thread.
SequenceChecker thread_checker_;
+
+ // Used to force CaptureFrame to update it's screen configuration
+ // and reregister event handlers. This ensure that this
+ // occurs on the ScreenCapture thread. Read and written from
+ // both the VideoCapture thread and ScreenCapture thread.
+ // Protected by desktop_config_monitor_.
+ bool update_screen_configuration_ = false;
};
} // namespace webrtc
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index 57ff0688a3..7405c95911 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -189,6 +189,7 @@ void ScreenCapturerMac::Start(Callback* callback) {
current_display_);
callback_ = callback;
+ update_screen_configuration_ = false;
// Start and operate CGDisplayStream handler all from capture thread.
if (!RegisterRefreshAndMoveHandlers()) {
RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers.";
@@ -210,7 +211,8 @@ void ScreenCapturerMac::CaptureFrame() {
MacDesktopConfiguration new_config =
desktop_config_monitor_->desktop_configuration();
- if (!desktop_config_.Equals(new_config)) {
+ if (update_screen_configuration_ || !desktop_config_.Equals(new_config)) {
+ update_screen_configuration_ = false;
desktop_config_ = new_config;
// If the display configuraiton has changed then refresh capturer data
// structures. Occasionally, the refresh and move handlers are lost when
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 3e6a6cb3c6..5b0406609f 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -133,7 +133,8 @@ void MouseCursorMonitorMac::CaptureImage(float scale) {
NSSize nssize = [nsimage size]; // DIP size
// No need to caputre cursor image if it's unchanged since last capture.
- if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]])
+ if (last_cursor_ &&
+ [[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]])
return;
last_cursor_ = nsimage;