Skip to content

fix(browser): stop phone taps waiting on the desktop window's paint - #22390

Closed
Jinwoo-H wants to merge 1 commit into
mainfrom
browser-streamed-input-skips-visibility-lease
Closed

Jinwoo-H wants to merge 1 commit into
mainfrom
browser-streamed-input-skips-visibility-lease

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​132
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​35

ELI5

When you use a browser tab from the Orca phone app, every tap, scroll or key press first asked the desktop app to "get the page ready to be seen" and waited for the desktop window to draw twice. If the desktop window was minimized or hidden behind other windows, it never draws, so every tap waited 2 seconds before happening. The phone is already watching that page, which keeps it ready, so the wait is skipped now.

What Changed

  • Before: with the Orca desktop window minimized, hidden or throttled, every phone input to a browser tab waited 2s before reaching the page. The host runs a page's inputs one at a time, and a scroll sends two, so it took 4s. Frames kept streaming, so the page looked live but ignored input for seconds (STA-8024: "streams but barely/not responsive").
  • After: while a page has a live screencast, input goes straight to the page.
  • Mechanism: executeWithVisibleTarget (agent-browser bridge queue) takes an automation-visibility lease before each targeted command. That lease runs script in the desktop renderer and waits on two requestAnimationFrames, capped at 2s (waitForAutomationVisiblePaint). A throttled window never fires requestAnimationFrame. The screencast stream now marks its guest as streaming for the life of the stream (browser-screencast-streaming-guests.ts), and the queue skips the lease for a guest that is streaming.

Why

A page with a remote viewer is already kept paintable. isBrowserPagePanePaintable includes a hasRemoteViewer term for this reason, so while the stream runs, the lease is redundant. Alternatives considered:

  • Holding one lease for the stream's lifetime. This adds a second mechanism that does the same thing as the remote-viewer term.
  • Disabling background throttling while a phone is connected. This costs power on every paired host and only hides the dependency.

Commands without a screencast, such as agent CLI automation, keep the lease unchanged.

No wire change; host-only, so mixed client/host versions are unaffected. Works the same for SSH-backed worktrees (the browser always runs on the desktop host).

Linked Issue

STA-8024 (Linear). Related: STA-4128, STA-7002.

Visual Proof

N/A: input timing on the host, with no UI change. Timings are below.

Testing

Timed on a background (ORCA_BACKGROUND_LAUNCH=1) dev build on macOS. Each run took orca mouse move against a local test page with temporary timing logs in executeWithVisibleTarget:

Desktop renderer state lease dispatch end-to-end CLI
awake (never shown, requestAnimationFrame running) 11–36 ms 0–1 ms (with a screencast running) ~150 ms
not running requestAnimationFrame (renderer frozen via CDP Page.setWebLifecycleState, standing in for minimized/occluded) 2001 ms 0–1 ms ~2150 ms

The frozen renderer stands in for a minimized window: it stops the renderer the same way, but it isn't the real macOS occlusion path. I didn't minimize a visible window, because doing that from automation would take focus.

  • New agent-browser-bridge-streaming-input.test.ts: move, wheel and click on a streaming guest take no lease, and the lease comes back once the last stream ends. It fails without the fix.
  • browser-screencast-lifecycle.test.ts: the guest is marked streaming for exactly the life of the stream.
  • pnpm tc:node, targeted src/main/browser suites, pnpm run check:code-quality:changed.

AI Disclosure

Claude (Opus).

Notes

A companion mobile PR fixes the other two freeze and tap causes on the phone side (frame pacing, double taps).

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A with reason for visuals
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote impact considered
  • pnpm lint, pnpm typecheck, pnpm test, pnpm build (targeted locally; CI will cover the rest)

Every coordinate input from the phone (tap, move, wheel, key) took an
automation-visibility lease first. The lease runs script in the desktop
renderer and waits for two animation frames, capped at 2s. When the desktop
window is minimized, occluded or otherwise throttled, those frames never come,
so each input stalled the full 2s before dispatching — and inputs are
serialized per page, so a scroll (move + wheel) cost 4s.

A page with a live screencast is already kept paintable for its remote viewer
(browser-page-paintability's hasRemoteViewer term), so the lease buys nothing
there. The screencast stream now marks its guest as streaming for the life of
the stream, and the bridge skips the lease for a streaming guest.

Measured on a background dev build with the desktop renderer frozen via
CDP Page.setWebLifecycleState: lease 2001ms, dispatch 0-1ms per input.
@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Superseded by #22528, #22534 and #22526, which remove the per-command wait on the desktop window's paint entirely instead of skipping it for streamed pages.

@Jinwoo-H Jinwoo-H closed this Sep 24, 2026
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