Skip to content

fix(window): stop a covered window drawing after a phone stream, and keep a streamed foreground tab live - #26657

Merged
Jinwoo-H merged 5 commits into
mainfrom
throttle-lease-rehide
Oct 8, 2026
Merged

Jinwoo-H merged 5 commits into
mainfrom
throttle-lease-rehide

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​208 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​191
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​19 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​17

Follow-up to #26284.

Problem

  1. The window keeps drawing after a phone stream. When a phone stops streaming a browser tab while the desktop is still covered (screen saver or minimized), the main window kept compositing: about 60 frames per second and +5 % CPU. It continued until the window was next uncovered and covered again.
    • Releasing the renderer-throttle lease calls setBackgroundThrottling(true), but in Electron that only clears the "don't hide" flag. It never replays the hide that was swallowed while the lease was held, and Chromium's visibility update skips an unchanged visibility.
    • The same applies to every lease user: remote browser screencast, phone-created terminals, phone tab close, and capture paint holds.
  2. A foreground browser tab froze on the phone. If the streamed browser tab was the foreground desktop tab, the phone got one or two frames and then froze under a cover. The page's own view is the one that gets hidden, and its attach-time unthrottle doesn't hold.

Fix

  • Re-hide on release. On the last lease release, after setBackgroundThrottling(true), the lease takes a hidden capture: capturePage with an empty rect and { stayHidden: true }. When the capture completes, Chromium re-applies the current visibility, so the swallowed hide lands.
    • Why an empty rect: a non-empty hidden capture sets a capture-size hint that can resize a hidden view.
    • Skipped when the target is focused. isFocused requires the (embedder's) window to be key, and a cover takes that away, so a focused target has nothing to replay. This also avoids a full-view readback on ordinary releases while the user is working.
  • The streamed page holds the same lease on itself for the life of the stream. That keeps the active tab painting while a phone watches, and re-hides it when the stream ends.

No new lifecycle state and no wire change. It's desktop-only.

Verification

Measured on real macOS hardware with the window actually shown, against a no-stream baseline, interleaved:

case before after
main window after the stream ends while covered (saver / minimize) 60 frames/s, +5 % CPU until the next cover cycle 0 frames/s and baseline CPU (8/8, then 6/6)
foreground tab while covered 1–2 frames, then frozen live for 60 s in all four cover/subscribe orders (12/12)
foreground-tab page after the stream kept painting back to baseline (6/6)
hidden-tab case (#26284) live still live, with no leftover drawing (5/5)
stream ends while the window is visible — the page keeps painting normally; never hidden (5/5)
  • Other checks: with Orca focused first, the screen saver and minimize both take focus, so the re-hide runs (4/4). The re-hide never made a page visible, never showed or focused the window, and later streams worked. Phone-created terminals and phone tab close while covered leave no leftover drawing.
  • Cost: about 32 MB transient and 11–28 ms per re-hide, only on releases while the window isn't focused.
  • Not verified: the real lock screen (password prompt).
  • Unit tests pin the release sequence (throttle, then a hidden empty-rect capture), the focus skip, rejection handling, the per-page guest lease shared by viewers, re-apply on the next stream, and a destroyed target.

…e is released

Restoring background throttling only clears Electron's disable_hidden flag; the
occlusion or minimize hide swallowed while the lease was held is never replayed,
so a covered window kept compositing at ~60 rAF/s until the next cover cycle.
After the last release, a discarded empty-rect stayHidden capturePage makes
Chromium's capturer-count decrement re-apply the current visibility, so the
pending hide lands without the page ever reporting visible. Skipped for a
focused renderer, best-effort and never awaited.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ng it

Drops the synchronous try/catch around the stayHidden capture so a missing
capturePage fails loudly; only the promise rejection is swallowed. Test
doubles that reach a final lease release now provide capturePage. Keeps the
focused-window skip (a covered window loses focus) and the empty rect.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…n the stream ends

When the streamed tab is the foreground desktop tab, the guest's own widget is
what a cover hides, and lifting the window throttle does not reach it, so the
phone froze after one or two frames. The page stream now re-applies the guest's
setBackgroundThrottling(false) at start and on the window's hide/minimize while
live. At stream end it drops those listeners, re-throttles the guest and replays
its swallowed hide with the same stayHidden capture the window lease uses
(now exported as replaySwallowedHide), so the guest stops painting.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…tle lease

The page stream now takes a rendererPublicationThrottle lease on the guest
instead of a bespoke guest-paint helper. The start unthrottle sets the guest
widget's disable_hidden flag (copied onto new widgets), so the window
hide/minimize re-apply listeners were no-ops and are gone. The guest gets the
lease's end-of-stream re-throttle and stayHidden re-hide, including the focus
skip, which holds for a guest because its isFocused requires the embedder's
window to be key and its root view focused.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b05fe558-9487-487f-b2a8-29af46d29b80
📥 Commits

Reviewing files that changed from the base of the PR and between 56db656 and 2576caa.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-03.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-session-tabs-part-05.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The renderer publication throttle now supports focus checks and hidden page captures after the final lease ends. Screencast streams acquire a throttle lease for the guest web contents and release it when the stream ends. Tests cover lease sharing, guest destruction, capture behavior, and updated runtime test doubles.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 2576c

Closing a streamed guest triggers debugger detachment and lease cleanup. No concrete user-impacting issue remains that warrants delaying the PR.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both main fixes: stopping covered-window drawing after a phone stream and keeping a streamed foreground tab live.
Description check ✅ Passed The description provides a clear problem statement, user-facing impact, implementation details, rationale, linked follow-up issue, verification results, test coverage, platform scope, performance cost…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Jinwoo-H
Jinwoo-H merged commit d4acd11 into main Oct 8, 2026
30 checks passed
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