Repository navigation
fix(desktop): break renderer crash loops with a GPU-fallback relaunch - #2597
SeanLiu326 wants to merge 5 commits into
Conversation
A renderer that crashes deterministically at startup (GPU driver or cache corruption, issue vastsa#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.
…ed to this branch)
|
Overlap note: #2600 (filed ~10h earlier) caps the same recovery loop at 5 reloads with a 30s recovery window — same breaker idea, self-contained reset heuristic (crash spacing instead of |
|
I confirmed the unbounded reload in current
Please coordinate the single breaker with #2600, and add an isolated Electron/integration scenario proving one guarded relaunch, a second failing launch reaching the dialog, and a stable fallback clearing the marker. GPU acceleration is a reasonable mitigation to try, but the available diagnostics do not establish a GPU/cache root cause; please avoid presenting it as confirmed without a comparison on the affected Windows setup. |
|
Taken over in #2640, which keeps your commits and authorship. The follow-up commit addresses the review: the healthy-uptime timer is now owned by the current renderer and cancelled on crash/reload/close; a marker write failure goes to the dialog instead of an unguarded relaunch; the boot-time hardware acceleration check moved before |
Review of vastsa#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 vastsa#2595 root cause. Refs vastsa#2595
Fixes #2595
The failure
The reporter's machine (Win11, RTX 4060 Ti, 150% scaling) renderer-crashes deterministically at startup:
did-finish-loadnever fires, so theshow: falsemain window is never shown, andrecoverRendererAfterGonereloads every 2 seconds — forever. The user sees a black screen, a flashing taskbar icon, and can only quit from the tray. Reinstalling does not help because the corrupt state (GPU driver/driver-cache interplay) lives outside the install directory.The fix
Recovery gains a crash-loop breaker on top of the existing cooldown:
recoverRendererAfterGonecounts consecutive crashes with no successful load in between (a newnoteRendererLoaded()resets the streak fromdid-finish-load). After 5 consecutive crashes it stops reloading and firesonCrashLoopDetectedexactly once; further crashes keep logging (rendererProcessGonediagnostics) but stay inert.--disable-gpu— the standard mitigation for corrupt GPU state, and the one thing a stuck black-screen boot can still do for the user. Guarded by auserData/renderer-crash-loop.jsonmarker so it can only ever happen once per fallback cycle.rendererCrashstrings in all nine locales) offers opening the log folder — where the crash diagnostics already land — or quitting.app.disableHardwareAcceleration()before ready, so manual launches are safe too, not just the relaunch. A run that stays loaded clears the marker after ten stable minutes, so a machine whose driver was updated (or whose corruption was transient) returns to hardware acceleration on a later boot.Scattered crashes over a long session never trip the breaker — the streak only counts crashes with zero successful loads in between, which is exactly the #2595 signature.
Verification
renderer-recovery.test.mjs: 8/8 — new tests cover the trip-once-then-inert behavior across 7 consecutive crashes, streak reset bynoteRendererLoaded(6 crash/load cycles never trip), and clean exits never counting. On pre-fix source the suite cannot even import (noteRendererLoadeddid not exist), so the tests pin the behavior.pnpm typecheck(desktop) clean after rebuilding@pi-desktop/shareddist;biome lintclean (152 files);pnpm -C packages/i18n buildclean with the newrendererCrashsection typed into all ninesatisfies EnglishCatalogcatalogs.