Repository navigation
fix(browser): a crashed page no longer crashes Orca when its viewport is resized - #23852
Conversation
…gfaulted Orca Chromium's Emulation.setDeviceMetricsOverride and Emulation.setVisibleSize resize the page's view without checking it still exists (WebContentsImpl::SetDeviceEmulationSize). A crashed page renderer takes its view with it until a reload builds a new one, so either command sent in that gap killed Orca's whole main process with SIGSEGV. One gate, sendGuestCdpCommand, now refuses those two commands while the tab's renderer is gone. The viewport preset writer, the agent viewport command, the agent bridge's command sender, the CDP proxy and the screencast device metrics all send through it. The check runs in the same task as the send, so the renderer cannot die in between. The page's own reload reapplies the chosen preset on dom-ready, as it already did.
… cast CI's changed-lines gate rejects new type assertions. The gate only uses isDestroyed, isCrashed and debugger.sendCommand, so it now takes exactly that shape; the viewport test keeps the one fixture cast its siblings use, with a line-specific SAFETY note.
|
Status: ready for review. Not merged, and auto-merge is not enabled. Review session
Live QA (M4Air, macOS, isolated profiles, real viewport menu path; the Grok QA seat was unavailable, returning HTTP 402, so I drove it myself)
CI on Also checked
|
|
Warning Review limit reachedNext included review available in 40 seconds. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (15)
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 |
|
| // The reloaded page's dom-ready reapplies the store's preset. | ||
| setRendererCrashed(false) | ||
| await expect(browserManager.setViewportOverride('tab-crashed', PHONE)).resolves.toBe(true) |
There was a problem hiding this comment.
Reload recovery remains untested. The test flips
isCrashed and calls setViewportOverride again, rather than triggering the dom-ready handler that reapplies the preset in production. It would pass even if a reload stopped reapplying the selected size, leaving that part of the fix without regression coverage.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Comments Outside DiffThese findings could not be posted inline.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — this run read the complete diff (15 files) against main at 31012aeb09 and traced every caller of the two view-resizing CDP methods.
- New CDP gate —
sendGuestCdpCommandrefusesEmulation.setDeviceMetricsOverride/Emulation.setVisibleSizewhile the guest is crashed or destroyed, forwards everything else, and keeps the check in the same task as the send. - Every sender routed through it — the viewport preset writer, the agent
viewportcommand, the CDP bridge sender (which also carriescdp-auxiliary-commands.setViewport), the CDP proxy forwarder, and the paired-phone screencast device metrics. A repo-wide grep for the two method names confirms no remaining directdebugger.sendCommandcaller. - Screencast timeout extraction —
runDebuggerCommandWithTimeoutletsbrowser-screencast-device-metricswrap the gated send without changing microtask timing for existingsendDebuggerCommandcallers. - Tests and doubles — new guard tests plus
isCrashedadded to the shared viewport fixture, bridge harness, proxy harness, and screencast doubles. The new tests fail if the guard is removed (pre-existing code writes the metrics command with no crash check).
Verified locally: ORCA_BACKGROUND_LAUNCH=1 pnpm test src/main/browser/ (206 files, 1926 passed), pnpm tc clean, pnpm run check:code-quality:changed reports 0 new findings across the 15 changed files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…3789, #23812, #23852) into brennanb2025/codex-home-single-writer #23744 moves every agent's folder pre-trust into the PTY spawn hook (and the structured Codex chat create), removing Codex's launch-prep and resume-prep trust writes. markCodexProjectTrusted now takes the config files to write. Conflicts: - agent-trust-presets.ts: #23744's configFiles signature and nested lane acquisition, with this branch's lane rationale (hook installs read and rewrite across awaits); main's "capture->restore window" wording described the grant snapshot this branch removed. - agent-trust-write-deadline.ts: the Codex writer waits only on managed-home installs' inline grant; the real-home background approval holds no lane. #23744's SSH/SFTP writer is gone, so it is no longer named; its 1.5 s short deadline is kept. - codex-trust-config-concurrent-launch.test.ts: this branch's tests (a launch's write lands while a grant session runs; the renamed sibling-failure case) with #23744's new call signature. Outside the conflicts: codex-launch-during-real-home-grant.test.ts passed launchAgent/workspacePath into launch prep, which #23744 removed; its launch helper now runs launch prep and then applyAgentWorkspaceTrust, as the spawn builder does, so it still proves a launch and its project trust land while the real-home approval hangs.
… is resized (#23852) * fix(browser): never resize a browser tab whose page crashed, which segfaulted Orca Chromium's Emulation.setDeviceMetricsOverride and Emulation.setVisibleSize resize the page's view without checking it still exists (WebContentsImpl::SetDeviceEmulationSize). A crashed page renderer takes its view with it until a reload builds a new one, so either command sent in that gap killed Orca's whole main process with SIGSEGV. One gate, sendGuestCdpCommand, now refuses those two commands while the tab's renderer is gone. The viewport preset writer, the agent viewport command, the agent bridge's command sender, the CDP proxy and the screencast device metrics all send through it. The check runs in the same task as the send, so the renderer cannot die in between. The page's own reload reapplies the chosen preset on dom-ready, as it already did. * test(browser): type the CDP gate's target so its test double needs no cast CI's changed-lines gate rejects new type assertions. The gate only uses isDestroyed, isCrashed and debugger.sendCommand, so it now takes exactly that shape; the viewport test keeps the one fixture cast its siblings use, with a line-specific SAFETY note. (cherry picked from commit 4ebec19)

ELI5
If a page in Orca's built-in browser crashed and you then picked a viewport size (for example a phone size), the whole Orca app could crash and close, taking every terminal and agent with it.
Now Orca skips resizing a crashed page, and the size you picked is applied as soon as the page loads again.
What Changed
The problem. Orca's main process crashed with a segmentation fault (SIGSEGV) when a browser tab's page had crashed and something then asked Chromium to resize that page's viewport.
It was first seen by the #23718 identity regression audit (follow-up 2): 2 of 2 on the #23718 merge and 1 of 1 on its parent, using a forced renderer crash.
I reproduced it on current
mainon macOS with a natural crash and no debugging hooks: a page that runs out of memory while it is still loading crashes again on Orca's automatic recovery reload, which leaves the tab dead; choosing a phone preset from the viewport menu 5 seconds later closed Orca 2 of 2 times.It is not a regression from a recent PR: the unsafe call pattern predates #23718.
Who can hit it. Anyone whose browser-tab page crashes (out of memory, a renderer bug, or the OS killing it) while a viewport resize is in flight or soon after, if Orca's automatic reload has not rebuilt the page yet.
The same resize is sent by four other paths, all affected in the same way: the viewport preset reapplied when a page finishes loading, the agent
viewportcommand, raw CDP commands an agent sends through Orca's CDP proxy (for exampleset viewport), and the device-size emulation for a paired phone watching a browser tab.When the automatic reload succeeds, the unsafe window is only about 1 to 3 ms after the crash (measured over 48 real crashes), so the stuck-tab case above is the realistic trigger.
Not affected. Every other command Orca sends to a crashed page, which I tested one by one on a dead page without a crash: touch emulation, user-agent changes, running page scripts, mouse input, screenshots, and clearing the viewport size.
Pages that have not crashed behave exactly as before.
What you see now. Orca stays open. Picking a viewport size on a crashed tab is remembered but not applied to the dead page; when the page reloads (or you navigate it anywhere) it comes up at the size you picked.
An agent's
viewportcommand on a crashed tab now returns an error ("The page crashed; its viewport can be changed again once it reloads.") instead of taking down the app.Mechanism. Chromium's handlers for
Emulation.setDeviceMetricsOverrideandEmulation.setVisibleSizecallWebContentsImpl::SetDeviceEmulationSize, which dereferences the page's view without checking that it exists. A crashed renderer takes its view with it until a reload builds a new one, so either command sent in that gap is a null-pointer crash in Orca's main process (symbolized stack in Testing below).A new function,
sendGuestCdpCommandinsrc/main/browser/guest-cdp-command.ts, is now the one gate these commands pass through: it refuses those two commands while the tab'swebContents.isCrashed()is true (or the tab is destroyed) and forwards everything else unchanged.The check runs in the same task as the send, and Chromium sets
isCrashed()in the same task that drops the view, so the renderer cannot die between the check and the send. On reload, Chromium creates the new view before it clears the crashed state, so a page reported as not crashed always has a view.Routed through it: the viewport preset writer, the agent
viewportcommand, the CDP bridge's command sender (which agent commands use), the CDP proxy's forwarder, and the paired-phone screencast's device-size emulation. It takes only the three members it uses (isDestroyed,isCrashed,debugger.sendCommand).The existing reapply-on-load behaviour is what restores the chosen size after recovery; nothing new had to be added for that.
Why
The bug is a missing null check inside Chromium, so Orca cannot fix the dereference itself; the fix has to make sure Orca never sends those two commands while the view is gone.
I put that rule in one function that every sender of those commands goes through, rather than a check inside the preset code alone, because the agent, CDP proxy and screencast paths send the same commands and would still crash the app.
I considered blocking every command to a crashed page. I rejected it because nothing else I tested crashes, and it would change agent behaviour for no gain: commands such as navigation are how an agent could recover a dead tab.
I considered sending
dontSetVisibleSize: truewith the metrics command, which skips the unsafe call. I rejected it because it changes how emulation sizes the page on every healthy tab and does not coverEmulation.setVisibleSize.I considered tracking crashes in Orca's own state from the
render-process-goneevent. I rejected it because asking Chromium directly (isCrashed()) cannot go stale, while a stored flag would have to be cleared at exactly the right moment on reload.Linked Issue
No issue; found by the #23718 identity regression audit (follow-up 2).
Visual Proof
After (this branch, M4Air, macOS): the page crashed while loading and stayed dead, a phone preset was applied 5 s later, and Orca is still running. Navigating the tab loads the page in the phone viewport (the page reports 375×667; device pixel ratio 2, 5 touch points, no hover, iPhone user agent).
Before (
mainat this branch's parent, 31012ae): there is nothing to show because the app closes. Its log ends withElectron exited with signal SIGSEGV, and the macOS crash report's faulting thread is the browser main thread (EXC_BAD_ACCESS,KERN_INVALID_ADDRESS at 0x0).Testing
Live, on the M4Air (macOS, Electron 43.7.5), an isolated profile and home per run, driving the real viewport menu path (store + IPC):
A third run of the first branch case died one second after launch, before any test step ran, with no crash report (its network service and window process ended together). I counted it as invalid, not as a pass.
Root cause, symbolized from the macOS crash report with Electron's published symbols for 43.7.5:
electron::api::Debugger::SendCommand→content::DevToolsSession::DispatchProtocolMessage→Emulation::DomainDispatcherImpl::setDeviceMetricsOverride→EmulationHandler::SetDeviceMetricsOverride→WebContentsImpl::SetDeviceEmulationSize(faulting frame). The same stack showed up in every crash, both forced and natural.Per command, sent straight to a page whose
isCrashed()was true (logged just before each send):Emulation.setDeviceMetricsOverrideandEmulation.setVisibleSizecrashed the app;Emulation.setTouchEmulationEnabled,Emulation.setUserAgentOverride,Emulation.clearDeviceMetricsOverride,Runtime.evaluate,Input.dispatchMouseEventandPage.captureScreenshotdid not.Unit tests (head
94fb9ca96df):guest-cdp-command.test.ts(refuses both commands on a crashed or destroyed page, forwards other commands, session id handling) andbrowser-manager-viewport-crashed-guest.test.ts(a preset on a crashed tab sends no resize, and the same preset applies once the page is alive again). With the guard removed, all 4 guard tests fail. Everybrowser-manager*,cdp-*,agent-browser-bridge*,browser-screencast-*and runtime browser test file passes (54 files, 604 tests); their mocks gainedisCrashed. Three screencast and CDP files that cannot import@streamparser/jsonin my local install were left to CI.Not tested live: the agent
viewportcommand, the CDP proxy and the paired-phone screencast on a crashed tab (covered by the shared gate and the unit tests), and Windows or Linux. The Chromium code involved is the same on every platform.AI Disclosure
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: none; the change only withholds two commands. Cross-platform: the Chromium code is shared across macOS, Windows and Linux. Remote SSH: browser pages always run in the local Electron app, so SSH is unaffected. Mobile: a paired phone watching a crashed tab no longer triggers the crash through its device-size emulation. Compatibility: no persisted data or wire change. Performance: one
isCrashed()call on two rarely sent commands.Open PR #23812 also edits
browser-manager-viewport.ts; this PR changes one line there, away from its hunks.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)