From fd76056c0fe2dabd51c1aed817f37bbe2308c3cd Mon Sep 17 00:00:00 2001 From: Bl4z3-k1n91 <225643968+Bl4z3-k1n91@users.noreply.github.com> Date: Wed, 2 Dec 2026 22:00:00 +0530 Subject: [PATCH] fix(windows): avoid blocking in the WebView window hook --- windows/runner/flutter_window.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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;