Skip to content

fix(gpu): make the software-rendering rescue reachable across launches - #15059

Open
nwparker wants to merge 3 commits into
mainfrom
nwparker/win-gpu-fallback-cross-launch
Open

nwparker wants to merge 3 commits into
mainfrom
nwparker/win-gpu-fallback-cross-launch

Conversation

@nwparker

@nwparker nwparker commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Orca has a rescue for machines whose GPU driver is unusable: after repeated GPU-child crashes it falls back to software rendering. On the shape of failure that actually strands users — the GPU child dying during startup — that rescue could never fire.

GpuCrashFallbackTracker requires 3 GPU crashes within a rolling 30s window inside one process. Its evidence lives in an in-memory array on a module-scope singleton (gpu-crash-fallback-decision.ts, constructed at index.ts:410) fed with performance.now(). When the GPU child dies ~600ms into startup and the user quits and relaunches, each launch contributes exactly one crash and the counter dies with the process. The only persisted artifact, gpu-fallback.json, is written downstream of both the threshold and a modal the user must answer — so it was structurally unwritable in this scenario, and maybeApplyGpuFallbackForThisLaunch() read null forever.

Prior work (#10707 rolling window, #11295 removing the GPU child) fixed the within-session case. The across-session case was still open.

This makes the evidence durable across launches, and lets the fallback engage before any window exists — because on a machine that dies in 600ms there is nothing to prompt on.

Fix evidence

Field data — the counter provably never advances

Reconstructed 48 distinct app launches (deduped by mainProcessLaunchId) from the 6 diagnostics bundles attached to the v1.4.184 crash cluster in #orca-crashes:

GPU crashes per launch: {1: 38, 0: 10}   <- never 2, never 3

grep -c gpu_fallback across all 12 files (6 crash reports + 6 bundles) = 0 everywhere. No gpu_fallback_engaged, no gpu_fallback_applied, no gpu_fallback_restart_deferred. The rescue never fired, on any of the 48 launches, on either machine.

Before/after on real Windows — the decisive test

Run on Windows 11 build 26200, real electron.exe 43.1.0, linking the real shipped modules, fresh --user-data-dir per arm. GPU killed via chrome://gpucrash (deliberately not --gpu-launcher, which emits no child-process-gone at all — see Known limitation):

[e2e] child-process-gone type=GPU reason=crashed exitCode=-1073741819   <- real crash, not simulated

Pre-fix arm (bundles gpu-crash-fallback-decision.ts + gpu-fallback-marker.ts verbatim from git show 71bbab72e14:) — identical on all 7 launches:

launch 1..7: in-memory tracker crashesInWindow=1 shouldEngage=false
RESULT prefix launch=1..7  gpu-fallback.json=absent

7 launches, marker never written. Matches the field distribution exactly.

Fixed arm — evidence accumulates and engages:

launch 1: engage=false reason=no-evidence crashesInWindow=0  -> history [launch-1]
launch 2: engage=false reason=no-evidence crashesInWindow=1  -> history [launch-1,launch-2]
launch 3: engage=false reason=no-evidence crashesInWindow=2  -> history [launch-1,launch-2,launch-3]
launch 4: breadcrumb gpu_fallback_applied {"source":"crash-history","crashesInWindow":3,
            "switches":"disable-gpu,disable-software-rasterizer,in-process-gpu"}
          gpu-fallback.json=PRESENT   gpu-crash-history.json=absent (consumed)
launch 5-7: reason=marker

gpuChildCount goes 1 → 0 at launch 4 and stays 0. Same machine, same induced fault: 0 markers in 7 launches before, engagement at launch 4 after.

Healthy machines are not swept up

Control run at the shipped GPU_CRASH_HISTORY_RESET_DELAY_MS = 60_000 (real 60s, no clock injection):

A: crash, dies early                    -> history [launch-a]
B: crash, dies early                    -> history [launch-a,launch-b]
C: crash at startup, PAINTS a window, survives the real 60s
     reset resolved {"forgetThisLaunch":true,"clearSupersededMarker":false}
   -> history [launch-a,launch-b]        <- C dropped ONLY its own entry
D: probe -> engage=false crashesInWindow=2
E: fully healthy launch, no crash        -> history STILL [launch-a,launch-b]

A launch that booted stops counting as "cannot even boot" evidence, and never destroys another launch's.

Gates

519 passed | 6 skipped (main/startup + crash-reporting) and 1792 passed (renderer hooks + settings) on both macOS and Windows; typecheck exit 0; oxlint 0 warnings 0 errors across 15,397 files; check:max-lines-ratchet OK — 192 grandfathered, no new bypasses; localization catalog/extraction/coverage green.

ELI5

Orca has a spare tire for computers whose graphics driver is broken: after the graphics helper crashes 3 times quickly, Orca switches to slow-but-reliable software drawing.

The problem: Orca counted those crashes on a notepad it threw away every time it started. If the graphics helper crashed while Orca was still starting up, Orca wrote "1", died, and threw the notepad away. Next launch: "1" again. It never reached 3, so it never got the spare tire out — no matter how many times you tried.

This change writes the count on a sticky note left on the fridge instead. Three bad launches in ten minutes and the next launch quietly starts in safe graphics mode. Two extra rules keep it honest: if a launch actually works for a minute, it erases its own tally mark (so a computer that's fine never accumulates), and marks older than ten minutes are ignored (so one bad day a month never adds up).

Trade-offs and negative behavior changes

These are real. None is hypothetical.

  1. Silent engagement with no consent. When the threshold is met from persisted evidence, Orca disables hardware acceleration before any window exists — no dialog, because there is nothing to show one on. Users get a materially different rendering path without being asked. Mitigated by a non-modal notice after the window is up plus a Settings toggle, but the first they know is after the fact.

  2. False positives are now possible where they were structurally impossible. Before this change a healthy machine could never be downgraded by this path, because the evidence was destroyed on every process exit. Now it survives — and that is inherent to the fix: the property that rescues a genuinely broken machine is the same one that lets a healthy one accumulate.

    To be precise about how narrow the exposure actually is, four filters stack before anything is counted:

    Filter Effect
    app.on('child-process-gone') (index.ts:3082) Child processes only. Renderer crashes — react-error-boundary, renderer oom, renderer killed — can never reach this path.
    isGpuFallbackCrashCandidate platform === 'win32' && processType === 'gpu' && reason ∈ {abnormal-exit, crashed, launch-failed}. Excludes killed (Electron's intentional reload/update/quit shape) and integrity-failure.
    recordGpuCrashInHistory Hard-bails on msSinceLaunch > GPU_CRASH_STARTUP_WINDOW_MS (15s). A GPU crash mid-session is the in-session tracker's job (fix(gpu-fallback): make the crash window rolling, not launch-anchored #10707) and is never written.
    countStartupGpuCrashLaunches Deduped by launchId, bounded by an absolute 10-minute wall-clock horizon, and requires 3 distinct launches — not 3 crashes.

    On top of that, a launch that reaches ready-to-show and survives 60s drops its own entry.

    So the residual false-positive shape is: three separate launches within ten minutes, each with a genuine GPU-child crash inside its first 15 seconds, and each quit within ~60s of the window painting — because any launch that sticks around exonerates itself. The realistic way to hit it is rapid restarts on a machine where the GPU child blips at startup but Chromium respawns it fine (an update relaunch, then the Restart button in Advanced, then a manual restart). It is not reachable from crash-type breadth. The risk is bounded, not eliminated, and the resulting downgrade is sticky for the build.

  3. Software rendering is genuinely worse. --in-process-gpu + --disable-gpu degrades xterm's WebGL renderer, scrolling, and animation.

  4. --in-process-gpu removes process isolation (pre-existing on main, but this change makes it reachable far more often). Once engaged, a GPU fault becomes fatal to the main process instead of an isolated child death — observed directly in the E2E. We trade "crashes at startup" for "may crash later, harder to attribute".

  5. Extra sync I/O on the crash path. One writeFileDurableSync (~10.5ms, fsync) per crashing launch, on an already-unhealthy process. Bounded to one write per launch by the launchId dedupe and the 15s startup-scope bail.

  6. Startup read on every Windows launch, before whenReady: measured ~5–30µs against a file bounded to 884 bytes. Zero file I/O on macOS/Linux (hard-gated).

  7. Scope is larger than a minimal crash fix — it adds a Settings row, a notice, and i18n strings. That surface exists to make the silent downgrade visible and reversible; without an exit, a user whose driver is later fixed would be stuck in software rendering until the next release (clearGpuFallbackMarker previously had zero callers outside its own module). It also incidentally de-duplicates useLocalizedToastReady out of two existing TCC notice hooks.

Adversarial review

5 rounds, 15 independent reviewer agents, three fixed lenses per round (correctness · user-facing regression · crash-path durability), each round a fresh agent with no memory of the last.

Round Blocking findings Outcome
1 9 (2 major) fixed
2 6 fixed
3 6 (1 major) did not converge — see below
4 (verify) 5 (0 major) fixed
5 (verify) 1 false positive — clean

Round 3 did not converge, and the reason mattered: rounds 1 and 3 raised opposite majors about the same thing — whether a launch that recorded crash evidence may later clear it. The fixes were oscillating between two failure modes, which meant it was a design ambiguity, not a bug. Resolved by ruling that the unit of evidence is a launch: every lifecycle step acts on a single launchId and never on the whole file, which satisfies both sides. clearGpuCrashHistory is now reserved for events that retire the evidence outright (promotion into the marker, or a user pin).

Findings worth naming, all caught by review rather than testing:

  • A failed read deleted the evidence file. readGpuCrashHistory collapsed "content is invalid" and "readFileSync threw" into one null, and the caller deleted for both. Verified empirically: a valid, correctly-versioned history made unreadable is deleted. On Windows the realistic trigger is a Defender sharing violation right after renameSync publishes the file — silently resetting the counter on exactly the machine the rescue exists for. Now classified via persisted-json-read.ts (missing / unreadable / invalid / ok); only invalid clears.
  • Durable evidence destroyed right after a non-durable marker write. writeGpuFallbackMarker was a bare writeFileSync; the change deleted the fsynced history the instant it was called. A bugcheck microseconds later left a torn marker and no history. Now routed through durableWriteTempPath + writeFileDurableSync.
  • A user-pinned mode was reported as crash-caused — after deliberately pinning software rendering, users got a warning toast saying it was off "because Orca's graphics process crashed on repeated launches", contradicting the dialog they had just accepted.

The round-5 finding was verified false: it claimed the Safe Graphics Mode search entry leaks onto the web client, but searchEntries sits inside ...(showDesktopOnlySettings ? [...] : []) where showDesktopOnlySettings = !isWebClient, and that is already pinned by useSettingsNavigationMetadata.test.ts:147. No change made.

Perf review (/perf) verdict: ship. Measured the pre-whenReady read at 5–30µs on Windows and exactly zero elsewhere; confirmed the 60s timer is unref'd; found and fixed a readdir + per-file stat running on the ready-to-show path and re-running on every window open (moved into the timer body), plus an unbounded read-side array on the earliest startup path.

Known limitation, stated explicitly

The GPU launch-failure mode remains unrescued, and the code says so. Discovered during E2E: when the GPU process fails to launch (as opposed to crashing after launch), Electron 43 emits no child-process-gone event at all — 0 events across 42 induced failures; Chromium retries 6× internally then FATALs the browser process. 'launch-failed' remains in GPU_FALLBACK_CRASH_REASONS but is unreachable on that path, which is now documented at gpu-crash-fallback-decision.ts:9-18 rather than left as a misleading dead branch.

What this does not fix

This does not fix the v1.4.184 Windows crash cluster that prompted the investigation, and should not be read as doing so. Those six reports are two machines whose GPU and renderer both die at sandbox init with STATUS_BREAKPOINT; one of them (e3e21dc6) had no GPU crash at all — three renderer deaths and a circuit-breaker open — so software-rendering fallback could not have helped it.

Correction (updated after this PR was opened). An earlier revision of this section said the AppContainer/LPAC ACL hypothesis had been falsified. That was wrong — the experiment tested the wrong variable. It checked whether removing S-1-15-2-1/S-1-15-2-2 from a clean install directory breaks Electron. It does not, and never would; that is how every normal Electron install ships.

The real precondition is the inverse: the install tree carries an orphan / unresolvable S-1-15-2-* package ACE while neither -1 nor -2 is present to satisfy it. Under that condition a healthy Electron 43.1.0 install flips to 10/10 launches crashing with exactly this signature on Windows 11 26200, and an additive icacls /grant *S-1-15-2-2:(OI)(CI)(RX) restores it — even when the orphan is inherited from a parent directory. Corroborated upstream by electron/electron#51761.

The WinSboxNoFakeGdiInit bisection was a lab artifact: that flag is FEATURE_DISABLED_BY_DEFAULT and Orca never sets it, and it cannot explain the GPU deaths. Instrumentation to detect the real condition in the field ships separately in #15107.

Root cause for those six reports is still open: we have no evidence either machine actually carries the precondition, and the ~80/20 field intermittency remains unexplained by a static DACL.

What this PR does is ensure that when a machine is stuck in a GPU crash loop, Orca can actually dig itself out.

The in-session GpuCrashFallbackTracker needs 3 GPU crashes inside one
process, but the Windows crash-at-startup shape delivers exactly one per
launch, so gpu-fallback.json was structurally unwritable. Persist the
crash evidence and derive the fallback decision before whenReady.
The 60s survival reset, the in-session decline, and the startup-crash flag all
acted on the whole file or vetoed each other. The unit of evidence is a launch:
each one drops its own entry by launchId and never another's. Also folds the
orphan-temp sweep behind the 60s timer and caps the history parse on read.
A failed read is not an absent decision. readGpuCrashHistory and
readGpuFallbackMarkerState collapsed "could not open" into the same null as
"contents are not ours" and deleted the file for both, so one Defender sharing
violation on the file a launch just published reset the distinct-launch counter
on the machine the rescue exists for. Reads are now classified
(missing/unreadable/invalid) and only 'invalid' deletes; recording a crash also
declines to publish a one-entry file over evidence it could not read.

The marker is now written fsync+rename with the crash history's temp cleanup and
an orphan sweep: both callers drop the durable history the instant that write
returns, so a torn marker used to leave the machine with neither artifact.

GpuFallbackStatus carries the marker source, so a user-pinned mode no longer
raises a toast blaming graphics crashes and Settings shows pinned copy; the
Settings row also offers "Keep on after updates", which converts an automatic
engagement into a pin without an intervening hardware launch on the driver that
kills startup.

A superseded-build record now expires with wall-clock age like the crash history
does, so a marker from a driver generation ago stops holding the post-update
threshold at one crash. A user pin never expires.
@nwparker
nwparker requested a review from brennanb2025 as a code owner August 17, 2026 07:57
@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds durable Windows GPU crash history and fallback markers. Startup evaluates persisted evidence and engages software rendering before Electron readiness when required. The main process records startup crashes, manages restart prompts, resets launch-scoped state, and exposes fallback controls through IPC. The renderer adds Safe Graphics Mode settings, platform-gated search entries, localized fallback notices, dismissal persistence, and web-safe API stubs. Extensive tests cover persistence, launch ordering, cross-launch behavior, durability, platform filtering, and UI interactions.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.93% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and on-topic, but it omits required Linked Issue and Visual Proof sections and the template checklist. Add the required issue link, attach UI or behavior proof or state N/A with a reason, and complete the testing, review, notes, and checklist sections.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the GPU fallback change and its cross-launch behavior.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch nwparker/win-gpu-fallback-cross-launch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (2)
src/main/startup/gpu-fallback-marker.test.ts (1)

110-129: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a backward clock-skew case for the superseded-marker expiry.

Both expiry tests move now forward from engagedAt. The source uses Math.abs and documents the opposite case: engagedAt stamped by a wrong RTC that W32Time later corrects backwards. That direction has no coverage, so a change from Math.abs(...) to nowEpochMs - marker.engagedAt would still pass.

♻️ Proposed additional test
  // Why: a wrong RTC can stamp engagedAt far in the future; W32Time then corrects now backwards.
  it('expires a superseded-build record stamped in the future by a corrected clock', () => {
    writeGpuFallbackMarker(userDataPath, { engagedAt: NOW, crashesInWindow: 4 }, environment)
    const updated = { ...environment, appVersion: '1.2.4' }
    const corrected = NOW - GPU_FALLBACK_SUPERSEDED_MARKER_MAX_AGE_MS - 1

    expect(readGpuFallbackMarkerState(userDataPath, updated, corrected)).toEqual({
      active: null,
      supersededBuild: null
    })
  })
src/renderer/src/components/settings/SafeGraphicsModeSetting.tsx (1)

15-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep rationale comments concise. Reduce the explanatory blocks to brief contract-focused statements that retain only the non-obvious constraint; move extended design history to documentation if needed.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a545d38c-a6ad-4784-88cd-fb956a1785c3

📥 Commits

Reviewing files that changed from the base of the PR and between 7c79890 and c80cf19.

📒 Files selected for processing (33)
  • src/main/crash-reporting/gpu-crash-fallback-across-launches.test.ts
  • src/main/crash-reporting/gpu-crash-fallback-decision.ts
  • src/main/index.ts
  • src/main/startup/desktop-startup-ordering.test.ts
  • src/main/startup/gpu-crash-history.test.ts
  • src/main/startup/gpu-crash-history.ts
  • src/main/startup/gpu-fallback-launch-decision.test.ts
  • src/main/startup/gpu-fallback-launch-decision.ts
  • src/main/startup/gpu-fallback-launch-engagement.ts
  • src/main/startup/gpu-fallback-marker-durability.test.ts
  • src/main/startup/gpu-fallback-marker.test.ts
  • src/main/startup/gpu-fallback-marker.ts
  • src/main/startup/gpu-fallback-unreadable-artifacts.test.ts
  • src/main/startup/persisted-json-read.ts
  • src/preload/api/app-api.ts
  • src/preload/index.ts
  • src/renderer/src/app-shell/AppBackgroundServices.tsx
  • src/renderer/src/components/settings/AdvancedPane.test.tsx
  • src/renderer/src/components/settings/AdvancedPane.tsx
  • src/renderer/src/components/settings/SafeGraphicsModeSetting.test.tsx
  • src/renderer/src/components/settings/SafeGraphicsModeSetting.tsx
  • src/renderer/src/components/settings/advanced-search.ts
  • src/renderer/src/hooks/GpuFallbackNoticeHost.tsx
  • src/renderer/src/hooks/gpu-fallback-notice-dismissal.ts
  • src/renderer/src/hooks/useGpuFallbackNotice.test.tsx
  • src/renderer/src/hooks/useGpuFallbackNotice.ts
  • src/renderer/src/hooks/useMacTccAttributionSeveredNotice.ts
  • src/renderer/src/hooks/useMacosTccPromptNotice.ts
  • src/renderer/src/hooks/useSettingsNavigationMetadata.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/localized-toast-readiness.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/gpu-fallback-status.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review.

Comment on lines +101 to +107
// Why: a GPU death precedes ready-to-show, so the flag has to be set before anything can
// throw — and scoped to the startup window that governs recording and counting.
expect(
handler.indexOf(
'gpuCrashedDuringStartupThisLaunch ||= msSinceLaunch <= GPU_CRASH_STARTUP_WINDOW_MS'
)
).toBeLessThan(evidenceIndex)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Bound the startup-flag anchor so a rename cannot pass silently.

handler.indexOf(...) returns -1 when the anchor string no longer matches. -1 is less than evidenceIndex, so this assertion passes when the anchor is renamed or removed. That defeats the ordering guarantee, and it is the same failure mode the comment at line 19 of this file warns about.

Add a lower bound on the index.

💚 Proposed fix
     // Why: a GPU death precedes ready-to-show, so the flag has to be set before anything can
     // throw — and scoped to the startup window that governs recording and counting.
-    expect(
-      handler.indexOf(
-        'gpuCrashedDuringStartupThisLaunch ||= msSinceLaunch <= GPU_CRASH_STARTUP_WINDOW_MS'
-      )
-    ).toBeLessThan(evidenceIndex)
+    const startupFlagIndex = handler.indexOf(
+      'gpuCrashedDuringStartupThisLaunch ||= msSinceLaunch <= GPU_CRASH_STARTUP_WINDOW_MS'
+    )
+    expect(startupFlagIndex).toBeGreaterThanOrEqual(0)
+    expect(startupFlagIndex).toBeLessThan(evidenceIndex)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Why: a GPU death precedes ready-to-show, so the flag has to be set before anything can
// throw — and scoped to the startup window that governs recording and counting.
expect(
handler.indexOf(
'gpuCrashedDuringStartupThisLaunch ||= msSinceLaunch <= GPU_CRASH_STARTUP_WINDOW_MS'
)
).toBeLessThan(evidenceIndex)
// Why: a GPU death precedes ready-to-show, so the flag has to be set before anything can
// throw — and scoped to the startup window that governs recording and counting.
const startupFlagIndex = handler.indexOf(
'gpuCrashedDuringStartupThisLaunch ||= msSinceLaunch <= GPU_CRASH_STARTUP_WINDOW_MS'
)
expect(startupFlagIndex).toBeGreaterThanOrEqual(0)
expect(startupFlagIndex).toBeLessThan(evidenceIndex)

Comment on lines +78 to +84
export function getAdvancedPaneSearchEntries(platform: {
isWindows: boolean
}): SettingsSearchEntry[] {
return [
...getAdvancedPaneCoreSearchEntries(),
...(platform.isWindows ? getSafeGraphicsModeSearchEntries() : [])
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Hide Safe Graphics Mode from Windows web-client search. AdvancedPane hides this setting for web clients, but the search catalog only tests isWindows. A Windows web client can receive a search result with no rendered target.

  • src/renderer/src/components/settings/advanced-search.ts#L78-L84: Accept web-client state and include the entry only when isWindows && !isWebClient.
  • src/renderer/src/components/settings/AdvancedPane.test.tsx#L50-L60: Add a Windows web-client assertion that the search catalog excludes Safe Graphics Mode.
📍 Affects 2 files
  • src/renderer/src/components/settings/advanced-search.ts#L78-L84 (this comment)
  • src/renderer/src/components/settings/AdvancedPane.test.tsx#L50-L60

},
"useGpuFallbackNotice": {
"title": "Orca started in Safe Graphics Mode",
"description": "Hardware acceleration is off because Orca's graphics process crashed on repeated launches. Rendering may be slower. Settings > Advanced explains it and can try hardware acceleration again.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Clarify the fallback notice description.

Settings > Advanced is the page, not the actor. Rewrite the sentence so the action is explicit.

Proposed wording
-        "description": "Hardware acceleration is off because Orca's graphics process crashed on repeated launches. Rendering may be slower. Settings > Advanced explains it and can try hardware acceleration again.",
+        "description": "Hardware acceleration is off because Orca's graphics process crashed on repeated launches. Rendering may be slower. Open Settings > Advanced to learn more and try hardware acceleration again.",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"description": "Hardware acceleration is off because Orca's graphics process crashed on repeated launches. Rendering may be slower. Settings > Advanced explains it and can try hardware acceleration again.",
"description": "Hardware acceleration is off because Orca's graphics process crashed on repeated launches. Rendering may be slower. Open Settings > Advanced to learn more and try hardware acceleration again.",

"keepAfterUpdates": "Keep on after updates",
"inactiveDescription": "Off. Orca is using hardware acceleration, and turns this on by itself only after repeated graphics crashes at startup.",
"confirmTitle": "Restart with hardware acceleration?",
"confirmDescription": "If the graphics driver still crashes, Orca returns to Safe Graphics Mode by itself after three failed launches.",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Match the restart description to the fallback eligibility rule.

The fallback requires three qualifying startup GPU crashes within the configured window. This text says “three failed launches,” which can include unsupported failure types and omits the time window.

@nwparker

Copy link
Copy Markdown
Contributor Author

Follow-up branch with the review comments addressed and a reduction pass: nwparker/win-gpu-fallback-cross-launch-v2 (rebased on current main).

I did not force-push over this PR's branch. To update #15059 in place:

git fetch origin nwparker/win-gpu-fallback-cross-launch-v2
git checkout nwparker/win-gpu-fallback-cross-launch
git reset --hard origin/nwparker/win-gpu-fallback-cross-launch-v2
git push --force-with-lease

⚠️ This PR currently fails on main

desktop-startup-ordering.test.ts asserts setNameIndex > applyIndex. main has since added a guarded, dev-only app.setName() before the GPU decision, so indexOf finds that one first and the assertion fails. Verified against the PR's own tree rebased on main.

The constraint that actually holds is initDataPath() before (it pins userData against a later setName) and whenReady after — getCanonicalUserDataPath already owns the setName ordering, so the GPU code never needed to.

Review comments

  • a — replaced every bare indexOf ordering assertion with anchorIndex/between helpers that fail loudly on a missing anchor. Fixes the whole class, not just the one site.
  • b — root cause was two places deciding visibility. Now one exported isSafeGraphicsModeSettingAvailable({ isWindows, isWebClient }), used by both AdvancedPane and the search catalog, so they cannot drift. Windows-web-client case asserted.
  • c — "Open Settings > Advanced to learn more and try hardware acceleration again."
  • d — "…once three launches within ten minutes have crashed graphics during startup." (was "three failed launches")

Reduction

33 files / +3230 −131 → 32 files / +3274 −185. Total is flat; the structural change is the point:

before after
src/main/index.ts +216 / −29 +48 / −48
production net 1283 1246
new modules 11 9
  • 168 lines of state machine out of index.ts into GpuFallbackLaunchSession — five module-level mutable flags, a timer, and seven functions became one object. Absorbed gpu-fallback-launch-engagement.ts.
  • The across-launches test now constructs a real session per launch instead of re-implementing index.ts's wiring by hand (~70 lines of harness that could silently stop matching the code it modelled).
  • Deleted the source-census assertions that are now internal to the session and replaced them with behavioural tests (gpu-fallback-launch-session.test.ts). The remaining census covers only claims no behavioural test can hold.
  • Two byte-identical orphan sweeps → one; both writers' temp-cleanup try/catch deleted (writeFileDurableSync already removes its own uncommitted temp).
  • Two node:fs-mocking test files → one gpu-fallback-artifact-io.test.ts (they were mocking the same seam twice).
  • SettingsRestartPrompt extracted — also deletes the copy already in AdvancedPane for HTTP/1.1 compatibility.
  • Three derived useStates → one GpuFallbackStatus; GPU_FALLBACK_INACTIVE_STATUS shared by main, web preload and both tests; GpuFallbackNoticeHost + notice dismissal folded into the hook.

Deliberately not reduced:

  • gpu-fallback-launch-decision.ts — pure, separately tested; merging it into the session would mix pure and impure in one 400-line file.
  • Hand-rolled parsers in gpu-crash-history.ts / gpu-fallback-marker.ts — zod would cut ~60 lines, but this runs before whenReady on the rescue path for already-broken machines. Not worth a schema library there.
  • persisted-json-read.ts — 41 lines, but the missing/unreadable/invalid distinction is the load-bearing insight of the second commit and both artifacts need it.
  • Test volume — the brief was elegance, not shrinkage, so nothing was deleted for line count.

Visual proof — not obtainable, not fabricated

I could not produce it and did not fake it. Safe Graphics Mode is hard-gated to win32 on both sides: maybeApplyGpuFallbackForThisLaunch() returns early on non-Windows, and AdvancedPane will not render the row. On this macOS host there is no path that exercises it. (npm run dev also fails here — no electron in node_modules.)

Forcing it would mean stubbing window.api.platform.get and getGpuFallbackStatus, which proves the component renders — exactly what SafeGraphicsModeSetting.test.tsx and useGpuFallbackNotice.test.tsx already assert. This needs a Windows host to screenshot honestly.

Verification

tsc (node + web) and oxlint clean. 8342 tests pass across src/main, src/shared, src/preload, src/renderer/{hooks,components/settings,app-shell,web}. Three files fail identically on main in this environment (run-electron-vite-dev, wsl-hook-relay-live, packaged-cli-assets) — all need a built app / Electron / WSL.

This branch has not been deployed

No deployments
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.

1 participant