Skip to content

fix(desktop): pin preview CDP debugger across webview teardown - #223

Merged
leoisadev1 merged 2 commits into
mainfrom
fix/desktop-preview-debugger-pin
Sep 14, 2026
Merged

leoisadev1 merged 2 commits into
mainfrom
fix/desktop-preview-debugger-pin

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

Problem

Heavy preview automation can SIGSEGV the desktop browser process. Electron's webContents.debugger wrapper is GC-managed but registered with Chromium as a raw pointer. Cleanup also re-read wc.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 lint on 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.

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.
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
akeru-bot-landing Skipped Skipped Sep 10, 2026 5:51pm UTC

Request Review

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Greptile Summary

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 garbage collection while Chromium retains the debugger client and allows cleanup after the associated webview has been destroyed.

Confidence Score: 5/5

Safe to merge.

There are no outstanding findings.

Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile

@leoisadev1
leoisadev1 merged commit 0e56f12 into main Sep 14, 2026
11 checks passed
@leoisadev1
leoisadev1 deleted the fix/desktop-preview-debugger-pin branch September 14, 2026 00:07
This was referenced Sep 14, 2026

This branch was successfully deployed

1 active deployment
Preview — 508699f1 Deployed Sep 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant