fix(desktop): pin preview CDP debugger across webview teardown - #223
fix(desktop): pin preview CDP debugger across webview teardown#223leoisadev1 wants to merge 1 commit into
Conversation
Keep the Electron Debugger wrapper alive for each preview control session and detach through that reference. Re-reading wc.debugger after destruction throws and can crash the browser process. Adapted from pingdotgg#9068.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR pins each preview control session's Electron debugger wrapper and consistently uses that retained reference for CDP attachment, commands, color-scheme emulation, listener cleanup, and detachment. This prevents cleanup from re-reading
Confidence Score: 5/5The PR appears safe to merge, with the debugger lifetime fix consistently applied and covered by a focused teardown regression test. No actionable failures remain; the retained debugger is used for attachment, command dispatch, listener cleanup, and detachment, while existing replacement cleanup prevents an old session from detaching its successor. Important Files Changed
Sequence DiagramsequenceDiagram
participant M as Preview Manager
participant W as WebContents
participant D as Pinned Debugger
participant C as Chromium CDP
M->>W: Read debugger during session creation
W-->>M: Debugger wrapper
M->>D: Retain wrapper for session lifetime
D->>C: Attach and send commands
W--xW: Webview destroyed
M->>D: Remove listener and detach
D->>C: Detach without re-reading WebContents
Reviews (1): Last reviewed commit: "fix(desktop): pin preview CDP debugger a..." | Re-trigger Greptile |
Problem
Heavy preview automation can SIGSEGV the desktop browser process. Electron's
webContents.debuggerwrapper is GC-managed but registered with Chromium as a raw pointer. Cleanup also re-readwc.debugger, which throws once the webview is destroyed, so detach was skipped.Changes
Pin the debugger reference on each preview control session and route attach, detach, sendCommand, and color-scheme emulation through it. A new test destroys the webview getter and still expects detach.
Adapted from pingdotgg#9068. Preview artifact transfer remains with the remote-media worker.
Scope
This PR is debugger lifetime only.
Covered here:
Still assigned to this handoff, in later PRs:
Verification
vp test run apps/desktop/src/preview/Manager.test.ts: 73 passed, including the destroyed-webview detach case.vp linton the two files: no new errors.Native Electron crash reproduction was not run on this Linux host.
Implemented and verified by Grok 4.6 High in Grok Build via Orca.