From 6e03b746beb3f2ed8924fe26a74b3fc380a0f98c Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 13 Nov 2026 23:16:45 +0800 Subject: [PATCH] gui: plugin pages load on Windows again, their sandboxed frame kept in the window's process (Mute06162 on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mute06162 on X (0.1.4066, Windows): every plugin page (用量速览, 对话, 模型指纹, GPT号池) showed "This page stopped working / didn't answer", and Codex found "Worker request cancellation setup: The parameter is incorrect" and "Resuming Windows asset request: The parameter is incorrect" in the log. Both are Wails' own lines (request_cancellation_windows.go, v3.0.0-beta.24). Cause, reproduced on xiaomi-gpu (WebView2 157.0.4341.46): WebView2 runs the plugin page's frame (sandbox="allow-scripts") in a process of its own (Chromium's IsolateSandboxedIframes; CDP lists it as an "iframe" target). Wails registers its WebResourceRequested filter with AddWebResourceRequestedFilter, and that isn't raised for this process's requests: the frame got its index.html (a navigation), but bridge.js, app.js and style.css went to the network as http://wails.localhost/... and failed with net::ERR_CONNECTION_REFUSED. The bridge never said hello, so after 10s the page was broken. Wails' request cancellation auto-attaches the frame's target, takes it for a worker, and its setup on that session fails with E_INVALIDARG: that is the log line. Fix: windowsOptions starts WebView2 with IsolateSandboxedIframes disabled (sharedFrameProcess), merged into the one --disable-features with the user's own, unless the user enables it in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS. This is app-wide, so it covers every sandboxed frame magpie makes: plugin pages and plugin panels (pluginpages.js, the only two), in the main window and the tray panel. The frame keeps its sandbox: an opaque origin (its context's origin is "://"), its CSP, messages only. Run: - Real repro on xiaomi-gpu, sandbox HOME (C:\Users\yeton\magpie-wvf), testdata/page-plugin (magpie-usage-glance, the reporter's 用量速览), `magpie app` started in the console session by a one-shot scheduled task, driven over CDP: - origin/main 077421733: the page shows "This page stopped working / Usage glance 的页面没有响应"; the frame target's three subresources fail ERR_CONNECTION_REFUSED; err.log has "Worker request cancellation setup: The parameter is incorrect." on every open. - origin/main with --disable-features=IsolateSandboxedIframes set by hand in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS: the frame stays. - this change: the card draws (screenshot: "Today, 0 calls, 0 tokens, $0.00, Hide cost", so the bridge and usage:summary read work), and no Wails line is logged. - TestWebView2KeepsPluginFramesInTheWindowProcess (new): win-run `go test -run WebView2 ./internal/gui` ok on xiaomi-gpu. Broken by hand (sharedFrameProcess not called): red on Windows, "disabled 0 times". TestWebView2ArgsMergeTheUsers and TestWebView2ArgsSurviveWailsInit updated for the new default. - mote: go test ./internal/gui ok (158s). - mica: go vet ./internal/gui for GOOS=windows, GOOS=linux -tags nogui and darwin ok; gofmt -l clean. Not tried: an older WebView2 runtime (when the runtime turned the isolation on is not proven; 157 has it), the reporter's other three plugins (they are frames like this one), Wails' own fix (registering the filter for every request source kind), and the whole internal/gui package on Windows. --- docs/subsystems/plugin-runtime.md | 12 ++++++ internal/gui/app.go | 4 +- internal/gui/webview2.go | 25 ++++++++++++ internal/gui/webview2_args_test.go | 65 +++++++++++++++++++++++++++--- 4 files changed, 99 insertions(+), 7 deletions(-) diff --git a/docs/subsystems/plugin-runtime.md b/docs/subsystems/plugin-runtime.md index 37ad92af5..5b07679c5 100644 --- a/docs/subsystems/plugin-runtime.md +++ b/docs/subsystems/plugin-runtime.md @@ -351,6 +351,18 @@ starts a Bun host. images and fonts the page loads itself. index.html's manifest link asks with `crossorigin="use-credentials"`. `TestPluginPageWebComesAsOneDocument`, `plugin-page-cookie-proxy.test.cjs`. +- **The frame's process on Windows.** WebView2 157 runs a sandboxed frame + in a process of its own (Chromium's `IsolateSandboxedIframes`), and + Wails' `WebResourceRequested` filter isn't raised for that process's + requests: a page got its index.html, but its bridge.js, scripts and + stylesheet went to the network as `http://wails.localhost/...` and were + refused, so every page and panel said it didn't answer (Mute06162 on X, + 0.1.4066). Wails' request cancellation also logged "Worker request + cancellation setup: The parameter is incorrect" for the frame. + `windowsOptions` starts WebView2 with the feature disabled + (`sharedFrameProcess`), unless the user enables it in + `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS`; the frame keeps its sandbox and + opaque origin. `TestWebView2KeepsPluginFramesInTheWindowProcess`. - **Slots.** A page names a slot with `