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 <jamiewalch@chromium.org>
Commit-Queue: Brave Yao <braveyao@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26230}
This commit is contained in:
braveyao 2019-01-08 14:29:43 -08:00 committed by Commit Bot
parent 977c82020c
commit b46235c1cc

View File

@ -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;