Skip to content

fix(desktop): break renderer crash loops with a guarded GPU-fallback relaunch - #2640

Merged
vastsa merged 8 commits into
mainfrom
fix/renderer-crash-loop-takeover
Nov 28, 2026
Merged

vastsa merged 8 commits into
mainfrom
fix/renderer-crash-loop-takeover

Conversation

@vastsa

@vastsa vastsa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Fixes #2595. Supersedes #2597 and keeps @SeanLiu326's commits and authorship; the follow-up commit addresses the review on #2597.

Problem

A renderer that crashes before did-finish-load on every startup is reloaded every 2 s forever. The show: false main window never appears (#2595 diagnostics: 10 000+ renderer.process.gone per day).

Fix

From #2597: after 5 consecutive crashes with no successful load in between, recovery stops reloading. The first trip relaunches once without hardware acceleration, guarded by a marker. If the loop survives that, a localized dialog offers the log folder or quit.

Review fixes in e6d7c1e59:

  • Timer ownership. A per-window controller (renderer-crash-loop.ts) owns a single healthy-uptime timer for the current renderer. It is cancelled on crash, a newer load, escalation, and window close. The marker is cleared only after 10 min of continuous uptime from one renderer.
  • Persistence failure. A marker write failure is logged at error and shows the terminal dialog instead of relaunching without a dedup guard. A corrupt marker counts as spent and reading it never throws or rewrites.
  • Boot check before ready. fix(desktop): break renderer crash loops with a GPU-fallback relaunch #2597 called disableHardwareAcceleration() in index.ts, which loads only after the async storage bootstrap and may run after ready, where the call has no effect. The marker now lives in userData and is read in installation.ts, synchronously before ready.
  • Ordered shutdown. Relaunch and dialog quit use the confirmed quit (before-quit teardown) instead of app.exit(0), so host-core and running turns are settled.
  • A load re-arms a breaker that tripped for an earlier renderer, so a recreated window still recovers.
  • Architecture: Electron wiring is in bootstrap/renderer-crash-loop-window.ts; window.ts grows by 11 lines and index.ts is unchanged.
  • The GPU cause is not claimed: the fallback is described as a mitigation.

Verification

Task candidate e6d7c1e59 on base origin/main 6214e5583, macOS arm64, Electron 43.6.0.

  • node scripts/e2e-renderer-crash-loop.mjs: 11/11 PASS (new). Three launches on one isolated profile, with every main-window load forced to crash (forcefullyCrashRenderer):

    1. One guarded relaunch: the marker is persisted first, relaunch-disable-gpu is logged, and the exit goes through app.shutdown.
    2. The second failing launch has hardware acceleration disabled and does not relaunch again. The dialog appears once and quitting from it exits.
    3. A stable fallback boot clears the marker.

    app.relaunch, dialog.showMessageBox, and the 10 min timer duration are patched in Main by the script only.

  • renderer-crash-loop.test.mjs (new, real fs + controlled timers) and renderer-recovery.test.mjs: 17/17. Covered: a stale timer after a crash, a reload restarting the window, dispose, a marker write failure, a corrupt marker, and re-arm after a load.

  • Desktop typecheck, biome lint, check-architecture, docs:check, check:pr-base: pass.

  • Spec: 03-runtime/07-process-model.md crash policy row and E2E-RENDERER-crash-loop-fallback.

Not verified: the reporter's Windows / RTX 4060 Ti setup. Forced crashes reproduce the reload loop, not its original trigger.

SeanLiu326 and others added 7 commits November 26, 2026 01:28
A renderer that crashes deterministically at startup (GPU driver or
cache corruption, issue #2595) turned the automatic recovery into an
infinite loop: did-finish-load never fires, so the hidden main window
is never shown, and recoverRendererAfterGone reloads every 2s until
the user force-quits. A plain reinstall does not help because the
corrupt state lives in userData.

Recovery now counts consecutive crashes with no successful load in
between and stops reloading after five: the first trip relaunches the
app once with --disable-gpu (the classic mitigation for corrupt GPU
state), guarded by a userData marker so a loop that survives the
fallback surfaces a localized dialog instead of relaunching forever.
Boot reads the same marker to disable hardware acceleration for
manual launches too, and a run that stays loaded for ten minutes
clears it again. Successful loads reset the streak, so scattered
crashes over a long session never trip the breaker.

The dialog offers opening the log folder (where the rendererProcessGone
diagnostics already land) or quitting; strings are added to all nine
locales.
Review of #2597 found that every did-finish-load started a marker-clearing
timer that no crash, close, or reload cancelled, so a fallback boot could
clear the marker while the renderer was crashing again. A marker write
failure also threw out of the crash callback, losing the only exit path,
and the boot-time hardware acceleration check ran in index.ts after the
async storage bootstrap, possibly after ready, where it has no effect.

A per-window controller now owns one healthy-uptime timer for the current
renderer and cancels it on crash, newer load, escalation, and close. A
failed marker write logs and shows the terminal dialog instead of
relaunching without a guard. Relaunch and dialog quits go through the
confirmed ordered shutdown instead of app.exit. The marker lives in
userData and is read in installation.ts, which runs before ready.

An Electron E2E forces renderer crashes on every load and proves one
guarded relaunch, a second failing launch reaching the dialog, and a
stable fallback boot clearing the marker. GPU state is not claimed as
the #2595 root cause.

Refs #2595
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Deploying pi-desktop with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1949d88
Status: ✅  Deploy successful!
Preview URL: https://15829e39.pi-desktop.pages.dev
Branch Preview URL: https://fix-renderer-crash-loop-take.pi-desktop.pages.dev

View logs

@vastsa
vastsa merged commit 6ff8d4f into main Nov 28, 2026
7 checks passed
@vastsa
vastsa deleted the fix/renderer-crash-loop-takeover branch November 28, 2026 08:28
zergfff added a commit to zergfff/PI-Desktop-fork that referenced this pull request Nov 30, 2026
Ported from vastsa/PI-Desktop v0.24.0-beta.7 (bug fixes only; the release's
features were left for a later rebase):

vastsa#2625 quarantine rejected outbox appends instead of retrying them forever
vastsa#2574 settle live turns and tool rows when the sidecar dies mid-stream
vastsa#2578 native Pi turns stay stoppable after a reload
vastsa#2634 the task badge mirrors work that is still running
vastsa#2639 let Arabic and Hebrew paragraphs choose their own side
vastsa#2640 stop a renderer crash loop with one GPU-less relaunch, then a dialog
vastsa#2642 reject differing spellings of one tool argument
vastsa#2655 compaction summaries open on demand in the transcript
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.

[Bug] 莫名不能正常打开,卡死在启动位置。

2 participants