From 59abb10c4f830f0eacfb76c43ccaad685d533d57 Mon Sep 17 00:00:00 2001 From: Joyer Huang Date: Thu, 27 Nov 2025 17:29:07 +0800 Subject: [PATCH] Fix for webview2 hidden window blocking desktop Use negtive location to hide webview in desktop this is a workaround for https://github.com/MicrosoftEdge/WebView2Feedback/issues/4829 --- windows/webview_bridge.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/windows/webview_bridge.cc b/windows/webview_bridge.cc index f0cae1d..259ed1f 100644 --- a/windows/webview_bridge.cc +++ b/windows/webview_bridge.cc @@ -155,9 +155,12 @@ WebviewBridge::WebviewBridge(flutter::BinaryMessenger* messenger, texture_id_ = texture_registrar->RegisterTexture(flutter_texture_.get()); texture_bridge_->SetOnFrameAvailable( [this]() { texture_registrar_->MarkTextureFrameAvailable(texture_id_); }); - // texture_bridge_->SetOnSurfaceSizeChanged([this](Size size) { - // webview_->SetSurfaceSize(size.width, size.height); - //}); + + // use negtive location to hide webview in desktop + // this is a workaround for https://github.com/MicrosoftEdge/WebView2Feedback/issues/4829 + webview_->SetSurfaceOffset(-71, -71, 1.0f); + webview_->SetSurfaceSize(71, 71, 1.0f); + const auto method_channel_name = std::format("io.jns.webview.win/{}", texture_id_);