Uh oh!
There was an error while loading. Please reload this page.
fix(desktop): stop hidden previews draining battery - #8567
Merged
juliusmarminge merged 2 commits intoAug 28, 2026
Conversation
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Why
Hidden preview webviews were moved offscreen but left CSS-visible. Animated pages therefore kept the Chromium renderer and GPU processes busy after the preview panel closed.
In the current Nightly build, a hidden animated X tab used about 63% combined CPU across the T3 Code GPU, guest renderer, and main renderer processes. Hiding the whole app dropped the guest and GPU processes to 0%, which isolated the work to hidden foreground webview painting.
This complements #8018. That PR removes duplicate downstream work for static recording frames; this PR stops rendering when no visible or background consumer needs frames.
Fixes#3143.
Verification
bun fmtbun lintbun typecheckbun run test: all affected and app tests passed; one unrelated, unchanged Windows packaging test fails locally on macOS (skips the primary native probe for cross-architecture Windows payloads)Risk
Low. The change is limited to preview visibility. Regression tests cover inactive previews, active background work, and concurrent activity leases. Existing recording and picture-in-picture state keeps those consumers paintable.
Note
Suspend rendering of hidden desktop preview webviews to stop battery drain
visibility: hiddenand adata-preview-rendering="suspended"attribute unlessrenderingActiveis true, stopping unnecessary paint workrenderingActiveis computed from three signals: a per-tab background activity lease (acquireBrowserSurfaceActivityinbrowserSurfaceStore.ts), picture-in-picture state, and active recording tab idsPreviewAutomationHostsacquire an activity lease for the target tab for the duration of the operation, and gate overlay/readiness checks on the webview actually rendering viaisPreviewWebviewRenderingactiveBrowserRecordingTabIdsAtomearlier (before screencast starts), changing the observable event order sopublish:tabIdprecedesstart-screencaststartBrowserRecordingevent ordering changed —publish:tabIdnow fires beforestart-screencast; tests inbrowserRecording.test.tsupdated accordingly. Inactive webviews that previously rendered offscreen are now hidden, which could affect anything that relied on offscreen paint without holding a lease.Macroscope summarized cd53061.