From decc48fd977ba326cbaa7cf1b516e173af5911ee Mon Sep 17 00:00:00 2001 From: memetao Date: Sun, 10 Dec 2023 14:27:06 +0800 Subject: [PATCH] Fix 'Screen flickering on ScreenCapturerWinDirectx' Bug: webrtc:15718 Change-Id: I230a0a7d196a4a3aea3b3e47cdf4f47c437e7196 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/330800 Commit-Queue: Mark Foltz Reviewed-by: Zijie He Reviewed-by: Mark Foltz Cr-Commit-Position: refs/heads/main@{#42177} --- AUTHORS | 1 + modules/desktop_capture/win/dxgi_duplicator_controller.cc | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/AUTHORS b/AUTHORS index 01ef5ab08c..e7592cf887 100644 --- a/AUTHORS +++ b/AUTHORS @@ -121,6 +121,7 @@ Silviu Caragea Stefan Gula Stephan Hartmann Steve Reid +Tao chen Takaaki Suzuki Tarun Chawla Todd Wong diff --git a/modules/desktop_capture/win/dxgi_duplicator_controller.cc b/modules/desktop_capture/win/dxgi_duplicator_controller.cc index 973aa3fd99..6fda5a82b8 100644 --- a/modules/desktop_capture/win/dxgi_duplicator_controller.cc +++ b/modules/desktop_capture/win/dxgi_duplicator_controller.cc @@ -500,6 +500,13 @@ bool DxgiDuplicatorController::EnsureFrameCaptured(Context* context, // ensure the video adapter has time to update the screen. webrtc::SleepMs(ms_per_frame); } + // When capturing multiple monitors, we need to update the captured region to + // prevent flickering by re-setting context. See + // https://crbug.com/webrtc/15718 for details. + if (shared_frame != target) { + context->Reset(); + Setup(context); + } return true; }