Repository navigation
Conversation
wry 0.57 handles WM_SIZE only while wparam != SIZE_MINIMIZED, and touches ICoreWebView2Controller::SetIsVisible only at creation and from Webview's own set_visible. So a minimised window, and a window hidden to the tray, leave WebView2 believing it is on screen: document.visibilityState stays "visible" and Chromium keeps rendering behind a window nobody can see. Measured on a build without this: 0.478 core on screen, 0.025 core minimised, 0.365 core restored — with visibilityState reporting "visible" in all three. webview_visibility mirrors each window's shown/minimised state into SetIsVisible(shown && !minimised), per window, from the paths that change it: window setup, Resized (tao forwards SIZE_MINIMIZED as a zero-size resize), focus, the tray's hide, and show_and_focus_window. Only a changed answer is dispatched, so a drag-resize does not queue one message per frame. It never shows, hides or resizes anything, so wry's own set_visible cannot fight it; browser surfaces keep their own controllers and windows.
Only `tracked` (Windows) and the unit test call it, so on Linux and macOS the lib target saw an unused function and CI's `-D warnings` failed the build before it got as far as anything interesting.
|
The ubuntu desktop job failed on |
|
Measured on the build from this PR (Windows 11, WebView2,
Before, the same measurement read Two things worth saying plainly:
|
fix(window): tell WebView2 when a window leaves the screen
Why
On Windows the app keeps working behind a window nobody can see. Minimise it,
or hide it to the tray, and
document.visibilityStatestill says"visible":Chromium goes on producing frames and running the page's timers. Everything the
frontend hangs off visibility therefore never pauses —
useDocumentVisible(src/lib/document-visibility.ts) keeps transcriptrendering and the live elapsed timers running;
animation-play-staterules insrc/app/globals.cssnever fire;requestAnimationFrameloop(
src/components/personal-agent/bot-face-motion.ts) keep ticking.That is what #1430 was trying to fix in the page, and why its approach could
not work: the page was never told. As @xintaofei put it on that PR,
wry0.57handles
WM_SIZEonly whilewparam != SIZE_MINIMIZED(
wry/src/webview2/mod.rs:1297), and touchesICoreWebView2Controller::SetIsVisibleonly when a webview is created and fromWebview::set_visible— neither a minimised window nor one hidden to the traytakes either path. The fix belongs where the window state is known.
What it does
src-tauri/src/webview_visibility.rskeeps each window's shown/minimised stateand mirrors it into WebView2:
Recomputed from the paths that change it:
commands::windows::post_window_setupWindowEvent::ResizedWM_SIZE(SIZE_MINIMIZED)as a zero-size resize, and the restore as the next oneWindowEvent::Focused(true)show_and_focus_windowlib.rs)commands::windows::show_and_focus_windowWindowEvent::DestroyedOnly a changed answer is dispatched, so a drag-resize costs one lock per
event and no
with_webviewmessage.What it deliberately does not touch
IsVisibleflag. wry's ownset_visible(which also shows or hides thewebview's HWND) cannot fight with it.
is built through wry directly (
browser::surface_child), and an owned tab'swindow by
browser::surface_window— neither goes throughpost_window_setup, so neither is followed.stop a second window from drawing.
truecostsframes, a wrong
falsewould leave the page blank.Measured
App built without this change (Windows 11, WebView2,
codeg.exe+msedgewebview2.exe, CPU share averaged over 15–20 s windows):document.visibilityStatevisiblevisible← the bugvisibleWith the change, the same measurement reports
hiddenwhile minimised, and thepage's own pause paths (
useDocumentVisible, theglobals.cssrules, the faceloop) take effect instead of running blind. The measured figures from the built
app are in the PR comment below.
Tests
cargo test --lib webview_visible— the pure decision(
shown && !minimised), four cases.cargo check --libandcargo test --libclean on Windows.