From 933afdf19770efa822156d49ce599bdb41c7f714 Mon Sep 17 00:00:00 2001 From: Austin Orion Date: Tue, 17 Aug 2021 14:21:47 -0700 Subject: [PATCH] Restrict WGC screen capture to Windows version 20H1 and greater. The Windows.Graphics.Capture API CreateForMonitor has a bug that was fixed in 20H1 that causes an exception to be thrown when an HMONITOR with a value of 0 is provided. This is a valid input used to request capture of all monitors. To avoid this issue, we can restrict screen capture using WGC to versions of Windows >=20H1. Bug: webrtc:13078 Change-Id: Ia66bf2b2738c29813d41e214fdfc1eb96e0a1312 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229140 Reviewed-by: Henrik Andreassson Commit-Queue: Austin Orion Cr-Commit-Position: refs/heads/main@{#34878} --- modules/desktop_capture/desktop_capturer.cc | 2 +- rtc_base/win/windows_version.cc | 6 +++++- rtc_base/win/windows_version.h | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc index 735aa4d530..9e6b99ac58 100644 --- a/modules/desktop_capture/desktop_capturer.cc +++ b/modules/desktop_capture/desktop_capturer.cc @@ -79,7 +79,7 @@ std::unique_ptr DesktopCapturer::CreateScreenCapturer( const DesktopCaptureOptions& options) { #if defined(RTC_ENABLE_WIN_WGC) if (options.allow_wgc_capturer() && - rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_RS5) { + rtc::rtc_win::GetVersion() >= rtc::rtc_win::Version::VERSION_WIN10_20H1) { return WgcCapturerWin::CreateRawScreenCapturer(options); } #endif // defined(RTC_ENABLE_WIN_WGC) diff --git a/rtc_base/win/windows_version.cc b/rtc_base/win/windows_version.cc index dab61ae897..0ed8957bd1 100644 --- a/rtc_base/win/windows_version.cc +++ b/rtc_base/win/windows_version.cc @@ -207,8 +207,12 @@ Version MajorMinorBuildToVersion(int major, int minor, int build) { return VERSION_WIN10_RS4; } else if (build < 18362) { return VERSION_WIN10_RS5; - } else { + } else if (build < 18363) { return VERSION_WIN10_19H1; + } else if (build < 19041) { + return VERSION_WIN10_19H2; + } else { + return VERSION_WIN10_20H1; } } else if (major > 6) { RTC_NOTREACHED(); diff --git a/rtc_base/win/windows_version.h b/rtc_base/win/windows_version.h index 33449e2b37..dbb0d8eb58 100644 --- a/rtc_base/win/windows_version.h +++ b/rtc_base/win/windows_version.h @@ -45,6 +45,8 @@ enum Version { VERSION_WIN10_RS4 = 12, // Redstone 4: Version 1803, Build 17134. VERSION_WIN10_RS5 = 13, // Redstone 5: Version 1809, Build 17763. VERSION_WIN10_19H1 = 14, // 19H1: Version 1903, Build 18362. + VERSION_WIN10_19H2 = 15, // 19H2: Version 1909, Build 18363. + VERSION_WIN10_20H1 = 16, // 20H1 (Vibranium): Version 2004, Build 19041. // On edit, update tools\metrics\histograms\enums.xml "WindowsVersion" and // "GpuBlacklistFeatureTestResultsWindows2". VERSION_WIN_LAST, // Indicates error condition.