ac4af582301a4e8a29245dbba767eba31334ddf9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3608ed782e |
gui: WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS reaches magpie's WebView2 on Windows again (#2753, LuYquan)
The reporter's Nahimic DLL gets WebView2's renderer killed by code
integrity and the window goes black; the usual workaround,
WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--disable-features=RendererCodeIntegrity,
never reached magpie's renderer. The cause is not WebView2 skipping the
variable because magpie passes its own arguments: Wails v3.0.0-beta.24's
loader blanks the variable in its package init
(webviewloader.preventEnvAndRegistryOverrides), before any magpie code
runs. Seen on the Windows box: a debug build's windowsOptions read "".
- internal/webview2env reads the variable at init. It imports only
syscall, so by Go's init order (first ready package by import path)
it is initialized before os, and so before Wails' loader, which needs
os.
- windowsOptions sorts it into Wails' DisabledFeatures, EnabledFeatures
and AdditionalBrowserArgs. Wails writes msSmartScreenProtection plus
the user's features as one --disable-features (Chromium keeps only
the last of two), one --enable-features, and the rest as written.
A list given twice is merged, each feature once.
- Nothing is added by default: RendererCodeIntegrity stays on unless
the user asks.
ProcessFailed: not done. Wails' edge.Chromium has a ProcessFailedCallback,
but setupChromium never sets it, the package is under wails/v3/internal
(not importable) and a window's chromium is unexported; Wails has no
public event for a dead renderer. Reloading on renderer death needs a
change in Wails.
Run:
- gofmt -l: clean. go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
clean. Builds for the three.
- go test ./internal/gui -run 'TestWebView2|TestWindowsOptions' on
macOS, and the windows/amd64 test binary on the Windows box (sandbox
dir, my own process name): TestWebView2ArgsSurviveWailsInit passes
there with os="" (Wails blanked it) and disabled=[RendererCodeIntegrity].
- The real app on the Windows box (portable sandbox, MAGPIE_ADDR :3481,
USERPROFILE/APPDATA/LOCALAPPDATA redirected) started with
"--disable-features=RendererCodeIntegrity --enable-features=msTestFoo
--lang=de": every msedgewebview2.exe of it carries one
--disable-features with both features, --enable-features=msTestFoo
and --lang=de. Before, the same launch showed only
--disable-features=msSmartScreenProtection and --lang=zh-CN.
Broken by hand:
- windowsOptions reading os.Getenv instead of webview2env.Args: on the
Windows box TestWebView2ArgsSurviveWailsInit goes red
(os="" disabled=[]).
- webView2Args ignoring the env (""): TestWebView2ArgsMergeTheUsers red
in "the reporter's" and "twice".
- --disable-features treated as an other argument: red in three cases,
including the one-switch count.
Full suite at origin/main
|
||
|
|
a51b90ce30 |
gui: the WebView2 notice also gives winget's command for the runtime (#1806)
ufec confirmed the notice works and asked that it say the runtime can be installed with winget too. Each language's box now adds "winget install Microsoft.EdgeWebView2Runtime" under Microsoft's page (the id is winget-pkgs' manifests/m/Microsoft/EdgeWebView2Runtime). Ran: go test ./internal/gui -run WebView2 (TestWebView2Notice now checks the command in every language; red without the strings), gofmt -l, GOOS=windows go vet ./internal/gui. Reported-by: ufec |
||
|
|
ff49ca72fe |
gui: Windows without the WebView2 runtime says so in a message box and offers the download page, instead of a double-click doing nothing (#1806)
magpie's windows are WebView2, which Windows 10 doesn't always have. Without it Wails handed the failure to ErrorHandler and exited, and the desktop build (-H windowsgui) has no console for the log line to land in: ufec's double-click came up to nothing at all. ufec found the cause, that Wails' own Env.Info().PlatformInfo["WebView2"] answers "" then, and that a box can't come from ErrorHandler (it runs on the thread Wails makes its windows on); this takes both from their branch. Run asks webView2Check right after application.New, before any window. Missing, it logs it and shows MessageBoxW (Yes/No, error icon, topmost) in the reader's language (trayLang): the runtime is missing, Microsoft's page https://developer.microsoft.com/microsoft-edge/webview2/, that "magpie web" and "magpie tui" work without it, and whether to open the page now; Yes opens it (ShellExecute), and Run ends. A key Wails doesn't set is read as present: refusing to start a magpie that would have worked is worse than the silent exit. The tray isn't kept: its panel is a WebView2 window too. Run: TestWebView2Missing and TestWebView2Notice (all OSes); TestWebView2MissingFromWails on the Windows box (10.0.0.132, Windows with WebView2 installed): a child process with Wails pointed at a folder that isn't a runtime reads missing, the machine's own runtime reads present. TestWebView2Missing goes red with webView2Missing made to answer false. On the box, a throwaway -H windowsgui test binary calling webView2Check with that bogus runtime path, run in the desktop session: the box came up titled "magpie 需要 WebView2" with the Chinese text, the page and 是/否 buttons (read back from the dialog's controls), the log line was written, pressing 是 opened the page in Edge and the check answered false. go test -tags nogui ./internal/gui in a sandbox HOME; gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows; windows and linux builds. Not tried: a machine that really lacks the runtime (the box has it; the missing case is Wails' lookup failing on a path that isn't a runtime, the same failure), nor a real magpie.exe start through Run. |