diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp index 25a5ad2d..0475d91d 100644 --- a/windows/runner/flutter_window.cpp +++ b/windows/runner/flutter_window.cpp @@ -46,10 +46,12 @@ void SetWindowAppUserModelId(HWND hwnd) { } bool IsBotGuardWindow(HWND hwnd) { - if (hwnd == nullptr || !::IsWindow(hwnd)) return false; - DWORD pid = 0; - ::GetWindowThreadProcessId(hwnd, &pid); - if (pid != ::GetCurrentProcessId()) return false; + // The WebView plugin creates its windows on the platform thread. + // GetWindowTextW sends WM_GETTEXT synchronously to in-process windows, + // so querying a worker window can stall the platform thread indefinitely. + if (::GetWindowThreadProcessId(hwnd, nullptr) != ::GetCurrentThreadId()) { + return false; + } wchar_t title[128]{}; int len = ::GetWindowTextW(hwnd, title, 128); if (len <= 0) return false;