From e3a8e55b75eeed80585eec1125e10ba7dfe4c094 Mon Sep 17 00:00:00 2001 From: Lambros Lambrou Date: Wed, 12 Oct 2022 17:03:36 -0700 Subject: [PATCH] Reset the queue in ScreenCapturerX11 when updating monitors. This is a speculative fix for the DCHECK at the top of ScreenCapturerX11::CaptureScreen(). Whenever |selected_monitor_rect_| changes, |queue_| should be reset, so that new frames are allocated with the correct size. This CL adds a reset to UpdateMonitors() which modifies |selected_monitor_rect_| and is called whenever an X11 configuration-change event is received (for example, when a monitor is resized). Bug: chromium:1372579 Change-Id: I9cc84a8b6990802f9d7dde05966ee17a80ddd48e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279065 Reviewed-by: Mark Foltz Commit-Queue: Mark Foltz Commit-Queue: Lambros Lambrou Auto-Submit: Lambros Lambrou Cr-Commit-Position: refs/heads/main@{#38374} --- modules/desktop_capture/linux/x11/screen_capturer_x11.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc index 4b7cbf54cb..d5dcd7af86 100644 --- a/modules/desktop_capture/linux/x11/screen_capturer_x11.cc +++ b/modules/desktop_capture/linux/x11/screen_capturer_x11.cc @@ -185,6 +185,10 @@ void ScreenCapturerX11::InitXrandr() { RTC_NO_SANITIZE("cfi-icall") void ScreenCapturerX11::UpdateMonitors() { + // The queue should be reset whenever |selected_monitor_rect_| changes, so + // that the DCHECKs in CaptureScreen() are satisfied. + queue_.Reset(); + if (monitors_) { free_monitors_(monitors_); monitors_ = nullptr;