Skip to content

fix(browser): pause native previews while window is minimized - #3429

Open
kev1n77 wants to merge 1 commit into
GCWing:mainfrom
kev1n77:fmy/bugfix
Open

kev1n77 wants to merge 1 commit into
GCWing:mainfrom
kev1n77:fmy/bugfix

Conversation

@kev1n77

@kev1n77 kev1n77 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Pause embedded browser previews and child WebView rendering when the native controller window is minimized or hidden, and resume eligible views when the window is restored.

Use one shared, event-driven infrastructure subscription to native window state across cached browser panels. Preserve active-panel, toolbar-transition and overlay-occlusion checks. The existing 5-second active preview interval and adaptive idle backoff up to 30 seconds are unchanged; no polling timer is added.

Type and Areas

Type: Bug fix

Areas: Web UI, desktop/Tauri window integration, browser visibility tests and verification guidance

Motivation / Impact

On Windows, the main WebView can keep document.visibilityState === 'visible' while the native window reports isMinimized() === true. The previous DOM-only check therefore kept taking screenshots and rendering an animated child page after minimization. Before the fix, a verified 30-second minimized sample recorded 5 captures and 5 decodes, with the test animation continuing at approximately 165 callbacks per second.

The fix hides the native child view and stops scheduling preview captures while minimized. Restoring the window resumes only the active, unoccluded browser panel and does not explicitly request focus. Native window state always comes from the local controller, including Peer Device Mode.

Verification

Real Windows WebView2 verification

Used the actual Debug desktop host with WebView2 155.0.4283.45, Vite serving the changed source, and a local synthetic animated canvas. A temporary test host mounted the production browser hook, preview cache and preview component. Capture requests used the production native screenshot/encoding path; the native capture API was not mocked.

Each phase was sampled for 30 seconds:

State Native captures Preview decodes Animation frame callbacks
Window visible 5 5 4950
Window minimized 0 0 0
Window restored 5 5 4950
  • Confirmed native minimized state before and after the minimized sample. The main document still reported visible, but the child document reported hidden and its frame counter did not advance.
  • Confirmed native restored state before and after the restored sample. The child document became visible and both capture and animation resumed.
  • Additional native minimize/restore checks kept inactive and overlay-occluded panels hidden, with zero captures and zero animation callbacks during each 6.5-second observation. Removing the overlay resumed the animation.
  • No capture errors or overlapping capture requests occurred in the three samples.
  • Verified source SHA-256 hashes against the measurement record before committing. Temporary harnesses, logs and measurement artifacts are excluded from this PR.

Automated checks

  • The initial CI run had one failing test out of 11,460: an obsolete overview icon source assertion. The branch now includes upstream commit 41b06f9a3 (test(web-ui): follow current overview icon composition); the failing test and overview component tests pass in the focused command above. Browser visibility implementation and preview intervals are unchanged by this upstream synchronization. The native WebView measurements above were collected before that synchronization, with identical browser runtime source files.

  • pnpm --dir src/web-ui run test:run src/app/components/NavPanel/navigationIconIntegration.test.ts src/app/scenes/personal-overview/OverviewMiniAppLogos.test.tsx src/app/scenes/browser src/infrastructure/runtime/windowVisibility.test.ts — 51 tests passed across 11 files on the updated upstream baseline. Covers minimize/restore scheduling, inactive/occluded panels, initial minimized state, shared listeners, stale asynchronous snapshots, cleanup and web fallback.

  • pnpm --dir src/web-ui exec tsc --noEmit — passed.

  • pnpm --dir src/web-ui exec eslint src/infrastructure/runtime/windowVisibility.ts src/app/scenes/browser/useEmbeddedBrowserWebview.ts — passed.

  • git diff --check and staged whitespace check — passed.

  • pnpm run check:web — blocked by 25 pre-existing typography violations in design-system Design Lab styles and MobileAvatar/MobileTag styles; those files are unchanged. Standalone TypeScript validation passed as listed above.

Reviewer Notes

  • Native verification is Windows Debug with a synthetic local page, not a Release benchmark or a real-video workload. macOS and Linux were not exercised.
  • Remote workspace, remote control, Peer Device Mode and Detached Dispatch were not runtime-tested. This change reads controller-local window state through existing Tauri APIs and adds no commands, wire shapes or persisted fields.
  • A native capture already in flight is not cancelled when the window minimizes; subsequent captures are paused. This change does not suspend page networking or all JavaScript execution.
  • Implementation and validation were AI-assisted.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable. No user-facing copy changed; focused browser verification guidance was added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant