From b46235c1ccb3d105a6a0f8944c32440c97cd27ce Mon Sep 17 00:00:00 2001 From: braveyao Date: Tue, 8 Jan 2019 14:29:43 -0800 Subject: [PATCH] desktopCapture: skip non-responsive windows in the picker This is a following up cl to the fix of crbug.com/911110. On Windows, if an App window is suspended, it will block some queries (which causes Chromium freezing and is fixed in Chromium.) and won't be captured. So there is no reason to list it in the window capture picker. Notes: this cl can't fix the case that the select app window becomes non-responsive just before capturing starts. Hope that an extreme corner case that can be safely ingored. Bug: chromium:911110 Change-Id: I0d14872ac699d559f40b3bff70f048efc67ca5d9 Reviewed-on: https://webrtc-review.googlesource.com/c/115441 Reviewed-by: Jamie Walch Commit-Queue: Brave Yao Cr-Commit-Position: refs/heads/master@{#26230} --- modules/desktop_capture/window_capturer_win.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/desktop_capture/window_capturer_win.cc b/modules/desktop_capture/window_capturer_win.cc index 6730734ad2..5dc3d95439 100644 --- a/modules/desktop_capture/window_capturer_win.cc +++ b/modules/desktop_capture/window_capturer_win.cc @@ -41,6 +41,14 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) { (owner && !(exstyle & WS_EX_APPWINDOW))) { return TRUE; } + // Skip unresponsive windows. Set timout with 50ms, in case system is under + // heavy load, the check can wait longer but wont' be too long to delay the + // the enumeration. + const UINT uTimeout = 50; // ms + if (!SendMessageTimeout(hwnd, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, uTimeout, + nullptr)) { + return TRUE; + } // Skip the Program Manager window and the Start button. const size_t kClassLength = 256;