Repository navigation
[perf-remote] perf(renderer): park hidden remote browser screencasts - #13608
Conversation
|
Warning Review limit reached
Next review available in: 6 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThe change adds shared window visibility tracking with delayed stream parking and stale-document recovery. The emulator visibility hook now re-exports the shared implementation. A new remote browser activation hook controls stream opening and cleanup based on pane activity and window visibility. Browser pane integration uses the new hook. Tests cover delayed parking, reopening, visibility transitions, active-pane changes, stale visibility recovery, unsubscription, and reuse of the existing remote page. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve 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. Comment |
Restores the WHY behind the '|| isDocumentVisibilityProvenStale()' term the emulator-module dedupe dropped, and pins it plus the close-tab-while-parked path with tests. Extracts the lifecycle harness so the spec stays under max-lines without a suppression. Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
037ea1b to
48a090b
Compare
The stream-gating hook (#13608) and the subscription parking installer (#13621) each reimplemented `isWindowVisible() || isDocumentVisibilityProvenStale()` plus its visibilitychange + stale-recovery subscription, and each carried its own 500ms park delay that agreed only by coincidence. Extract both into `lib/window-park-visibility.ts` and leave the two consumers as thin wrappers: `useWindowStreamVisible` feeds the snapshot and subscribe into `useSyncExternalStore`, the parking installer calls them imperatively. The subscribe now always uses the defensive `typeof document` guard the parking side already had, and registers stale recovery before the visibilitychange listener so the stale latch is cleared before the callback reads it. Both park delays now derive from one `WINDOW_HIDE_PARK_GRACE_MS`: they debounce the same signal against the same user behaviour (a quick app-switch round trip). The parking side's 8x reveal-side backoff stays where it is - that models its own resume cost, not the grace window. Renderer-authoritative gating (#13622 native chat, #13634 editor panels) is deliberately left alone; it keys off Zustand routing state, not OS visibility. Also switch the active-runtime ref writes in web-session-tabs-sync to `useLayoutEffect` so no resume event can land between paint and the passive flush, and correct the stale comment above them - the install effect reads neither ref (both readers are gated on `isVisibilityResume`).
…tablyai#13608) * perf(renderer): park hidden remote browser screencasts * test(renderer): pin stale-visibility term and parked-unmount teardown Restores the WHY behind the '|| isDocumentVisibilityProvenStale()' term the emulator-module dedupe dropped, and pins it plus the close-tab-while-parked path with tests. Extracts the lifecycle harness so the spec stays under max-lines without a suppression. Co-authored-by: Orca <[email protected]> * fix(ci): exclude test-support modules from the localization audit Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Orca <[email protected]>
…yai#13778) The stream-gating hook (stablyai#13608) and the subscription parking installer (stablyai#13621) each reimplemented `isWindowVisible() || isDocumentVisibilityProvenStale()` plus its visibilitychange + stale-recovery subscription, and each carried its own 500ms park delay that agreed only by coincidence. Extract both into `lib/window-park-visibility.ts` and leave the two consumers as thin wrappers: `useWindowStreamVisible` feeds the snapshot and subscribe into `useSyncExternalStore`, the parking installer calls them imperatively. The subscribe now always uses the defensive `typeof document` guard the parking side already had, and registers stale recovery before the visibilitychange listener so the stale latch is cleared before the callback reads it. Both park delays now derive from one `WINDOW_HIDE_PARK_GRACE_MS`: they debounce the same signal against the same user behaviour (a quick app-switch round trip). The parking side's 8x reveal-side backoff stays where it is - that models its own resume cost, not the grace window. Renderer-authoritative gating (stablyai#13622 native chat, stablyai#13634 editor panels) is deliberately left alone; it keys off Zustand routing state, not OS visibility. Also switch the active-runtime ref writes in web-session-tabs-sync to `useLayoutEffect` so no resume event can land between paint and the passive flush, and correct the stale comment above them - the install effect reads neither ref (both readers are gated on `isVisibilityResume`).
Summary
Parks remote-browser screencasts when the Orca window stays hidden:
ELI5
A remote browser is a little like a video call with a browser running on another computer. Before, Orca kept asking that computer to take, compress, send, and decode new pictures even while the Orca window was minimized or covered up. Now Orca hangs up only the video feed after half a second. It leaves the browser page and its last picture in place, then reconnects the feed when you come back instead of creating a new browser page.
This is structural hardening for the observed remote-host slowdown. It is not presented as a confirmed root-cause fix for the v1.4.177 to v1.4.178 regression.
Screenshots
No visual change.
Work bounds
browser.tabCreateThe parked request is the existing JPEG-quality-70
browser.screencast, capped at 3840x2160 and configured for every second compositor frame. The bound applies per mounted active remote-browser pane. It does not park the remote page's JavaScript, session-tab mirrors, native-chat streams, file watchers, or other runtime subscriptions.Revealing an established pane performs the existing two
browser.tabShowcalls, onestatus.get, and one new screencast subscription. It does not create another page.The 500ms value is the requested grace. Chromium may schedule a hidden renderer timer later because background throttling remains enabled. Once cleanup runs, renderer callbacks and tokens are retired immediately; the host's existing
Page.stopScreencastcommand retains its bounded 8-second debugger timeout.Testing
pnpm lintpnpm typecheckpnpm testwithORCA_CROSS_VERSION_BASELINE_REF=v1.4.177: 4,596 files / 49,269 tests passed; 16 files / 99 tests skippedpnpm build— full native packaging not run;pnpm build:electron-vitepassedAdditional checks:
browser.tabCreate, and restoredlivestatuspnpm check:code-quality:changedpnpm check:react-doctor:changedpnpm check:max-lines-ratchetgit diff --checkThe unpinned suite can select an unrelated repository-history tag named
v799, whose tree predates this repository layout. The full run therefore pins the intended release baseline,v1.4.177.AI Review Report
Three read-only adversarial passes traced the renderer effect, preload/main unsubscribe path, host CDP teardown, page-handle reuse, generation fencing, retry/liveness cancellation, StrictMode replay, and the full readiness checklist.
The review loop specifically caught or closed these risks:
document.visibilityStaterecovery needed coverage after the stream was already parkedFinal readiness verdict: no P0, P1, or production P2 findings.
The review covered SSH/relay disconnects, late subscription resolution, in-flight page creation, repeated hide/show, stale visibility, cleanup and retry bounds, mixed client/host versions, folder workspaces, macOS/Linux/Windows behavior, and mobile-facing compatibility.
Security Audit
No dependency, command execution, parser, filesystem, auth, secret, persistence, IPC/RPC method, schema, stream opcode, or remote-wire payload changes. The renderer only changes when it holds an existing validated screencast subscription. Unsubscribe retains the existing ownership checks and dedicated transport cleanup.
Notes