The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): gate the NVIDIA SwiftShader fallback on a witnessed GPU-process death, not the driver series (#124255)
Brooklyn Nicholsond9f0a399a085
diff --git a/apps/desktop/electron/linux-nvidia-egl-fallback.test.ts b/apps/desktop/electron/linux-nvidia-egl-fallback.test.tsindex 3ddd3aee97a..2ea66197cca 100644--- a/apps/desktop/electron/linux-nvidia-egl-fallback.test.ts+++ b/apps/desktop/electron/linux-nvidia-egl-fallback.test.ts@@ -1,106 +1,226 @@-import { describe, expect, it } from 'vitest'--import { decideNvidiaEglFallback, NVIDIA_BROKEN_EGL_MAJORS, parseNvidiaDriverMajor } from './linux-nvidia-egl-fallback'+import { mkdtempSync, rmSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'++import { afterEach, describe, expect, it } from 'vitest'++import {+ decideNvidiaEglFallback,+ NVIDIA_GPU_DEATH_REASONS,+ nvidiaEglFallbackMarker,+ nvidiaEglMarkerAfterSuccessfulBoot,+ parseNvidiaDriverMajor,+ parseNvidiaDriverVersion,+ readNvidiaEglMarker,+ shouldRelaunchForNvidiaGpuDeath,+ writeNvidiaEglMarker+} from './linux-nvidia-egl-fallback'const LINUX = { env: {}, platform: 'linux' as const, isWsl: false, remoteDisplayReason: null }+const PROBE = { ...LINUX, driverMajor: 580, driverVersion: '580.178.04', appVersion: '0.21.5', marker: null }++const tmpDirs: string[] = []++afterEach(() => {+ for (const dir of tmpDirs.splice(0)) {+ rmSync(dir, { recursive: true, force: true })+ }+})-describe('parseNvidiaDriverMajor', () => {- it('parses the major from /proc/driver/nvidia/version content', () => {+function tmpUserData(): string {+ const dir = mkdtempSync(join(tmpdir(), 'nvidia-egl-'))+ tmpDirs.push(dir)++ return dir+}++describe('parseNvidiaDriverMajor / parseNvidiaDriverVersion', () => {+ it('parses the major and full version from /proc/driver/nvidia/version content', () => {const text = 'NVRM version: NVIDIA UNIX x86_64 Kernel Module 580.82.09 Mon Jul 21 19:44:16 UTC 2025\n'expect(parseNvidiaDriverMajor(text)).toBe(580)- })-- it('parses 3-digit majors like 570 and 550', () => {- expect(parseNvidiaDriverMajor('NVRM version: ... 570.133.07 ...\n')).toBe(570)- expect(parseNvidiaDriverMajor('NVRM version: ... 550.107.02 ...\n')).toBe(550)+ expect(parseNvidiaDriverVersion(text)).toBe('580.82.09')})it('returns null for garbage or empty input', () => {expect(parseNvidiaDriverMajor('')).toBeNull()expect(parseNvidiaDriverMajor('no driver version here')).toBeNull()+ expect(parseNvidiaDriverVersion('')).toBeNull()+ expect(parseNvidiaDriverVersion('no driver version here')).toBeNull()})})-describe('decideNvidiaEglFallback', () => {- it('enables on linux with a known-broken series major (580)', () => {- const decision = decideNvidiaEglFallback({ ...LINUX, driverMajor: 580 })+// ─── the behavioral probe (#124255) ───────────────────────────────────────────+//+// The driver-major set gate burned 4-9 CPU cores on healthy 580 hosts whose+// session EGL lands on the iGPU; the same point release kills the GPU process+// on hosts where NVIDIA drives the display. Only a witnessed death may route+// ANGLE through SwiftShader.++describe('decideNvidiaEglFallback — behavioral probe', () => {+ it('boots with hardware GL on a first launch (no marker): the 580 series is probed, not assumed broken', () => {+ const decision = decideNvidiaEglFallback(PROBE)++ expect(decision.enable).toBe(false)+ expect(decision.nextMarker.state).toBe('booting')+ })++ it('a healthy prior boot (ok marker) keeps hardware GL', () => {+ const decision = decideNvidiaEglFallback({ ...PROBE, marker: { state: 'ok' } })++ expect(decision.enable).toBe(false)+ expect(decision.nextMarker.state).toBe('booting')+ })++ it('a witnessed GPU death (fallback marker, same app + driver) engages SwiftShader and stays sticky', () => {+ const marker = nvidiaEglFallbackMarker('0.21.5', '580.178.04')+ const decision = decideNvidiaEglFallback({ ...PROBE, marker })+expect(decision.enable).toBe(true)- expect(decision.reason).toContain('580')+ expect(decision.reason).toContain('witnessed')+ expect(decision.nextMarker).toEqual(marker)})- it('stays off on series without confirmed EGL reports (#123203)', () => {- // 570.x is the recommended downgrade from #40077; 615.x (two driver- // generations later) probes fine. An open-ended >= check wrongly forced- // these onto CPU SwiftShader rendering.- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: 570 }).enable).toBe(false)- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: 590 }).enable).toBe(false)- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: 615 }).enable).toBe(false)+ it('an app update re-probes hardware GL once instead of degrading forever', () => {+ const marker = nvidiaEglFallbackMarker('0.21.4', '580.178.04')+ const decision = decideNvidiaEglFallback({ ...PROBE, marker })++ expect(decision.enable).toBe(false)+ expect(decision.nextMarker.state).toBe('booting')})- it('the known-broken set is closed, not a floor', () => {- // Contract: only series with confirmed #40077-style reports belong in the- // set; adding one is a deliberate, evidence-backed change. Detection must- // follow set membership exactly, so no neighbouring series rides along.- expect(NVIDIA_BROKEN_EGL_MAJORS.has(580)).toBe(true)+ it('a driver update re-probes hardware GL once', () => {+ const marker = nvidiaEglFallbackMarker('0.21.5', '580.178.04')+ const decision = decideNvidiaEglFallback({ ...PROBE, marker, driverVersion: '580.182.10' })- for (let major = 500; major <= 700; major++) {- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: major }).enable).toBe(NVIDIA_BROKEN_EGL_MAJORS.has(major))- }+ expect(decision.enable).toBe(false)+ expect(decision.nextMarker.state).toBe('booting')})- it('stays off below the broken major and when detection finds no driver', () => {- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: 570 }).enable).toBe(false)- expect(decideNvidiaEglFallback({ ...LINUX, driverMajor: null }).enable).toBe(false)+ it('a leftover booting marker engages the fallback: the previous boot died mid-probe', () => {+ // Chromium's "GPU process isn't usable" FATAL abort can kill the process+ // before the child-process-gone handler runs; the unresolved `booting`+ // marker is the evidence it leaves behind.+ const decision = decideNvidiaEglFallback({ ...PROBE, marker: { state: 'booting' } })++ expect(decision.enable).toBe(true)+ expect(decision.reason).toContain('aborted')+ expect(decision.nextMarker.state).toBe('fallback')})- it('stays off on non-linux platforms', () => {- expect(decideNvidiaEglFallback({ ...LINUX, platform: 'darwin', driverMajor: 580 }).enable).toBe(false)- expect(decideNvidiaEglFallback({ ...LINUX, platform: 'win32', driverMajor: 580 }).enable).toBe(false)+ it('the healthy 580 hosts from the issue thread get hardware rendering back', () => {+ // #124255's reporter (Quadro P1000 + Intel UHD 630) and psukez on #123203+ // (940MX + Intel HD 520) both render on hardware with this driver; under+ // the old {580} series gate they were forced onto CPU SwiftShader.+ const healthy = decideNvidiaEglFallback({ ...PROBE, marker: { state: 'ok' } })++ expect(healthy.enable).toBe(false)})+})- it('stays off under WSLg', () => {- expect(decideNvidiaEglFallback({ ...LINUX, isWsl: true, driverMajor: 580 }).enable).toBe(false)+// ─── the same standing exclusions as before ────────────────────────────────++describe('decideNvidiaEglFallback — exclusions', () => {+ it('stays off on non-linux platforms and without an NVIDIA driver', () => {+ expect(decideNvidiaEglFallback({ ...PROBE, platform: 'darwin' }).enable).toBe(false)+ expect(decideNvidiaEglFallback({ ...PROBE, platform: 'win32' }).enable).toBe(false)+ expect(decideNvidiaEglFallback({ ...PROBE, driverMajor: null, marker: { state: 'booting' } }).enable).toBe(false)})- it('stays off when a remote display already forced software rendering', () => {+ it('stays off under WSLg and when a remote display already forced software rendering', () => {+ expect(decideNvidiaEglFallback({ ...PROBE, isWsl: true, marker: { state: 'booting' } }).enable).toBe(false)expect(- decideNvidiaEglFallback({- ...LINUX,- driverMajor: 580,- remoteDisplayReason: 'ssh-session'- }).enable+ decideNvidiaEglFallback({ ...PROBE, remoteDisplayReason: 'ssh-session', marker: { state: 'booting' } }).enable).toBe(false)})- it('HERMES_DESKTOP_DISABLE_GPU=0 keeps the GPU (and the fallback) off', () => {+ it('HERMES_DESKTOP_DISABLE_GPU=0 keeps the GPU on even over a witnessed marker', () => {+ const marker = nvidiaEglFallbackMarker('0.21.5', '580.178.04')+expect(- decideNvidiaEglFallback({- ...LINUX,- driverMajor: 580,- env: { HERMES_DESKTOP_DISABLE_GPU: '0' }- }).enable+ decideNvidiaEglFallback({ ...PROBE, marker, env: { HERMES_DESKTOP_DISABLE_GPU: '0' } }).enable).toBe(false)})- it('HERMES_DESKTOP_NVIDIA_SWIFTSHADER forces the fallback on without detection', () => {- const decision = decideNvidiaEglFallback({- ...LINUX,- driverMajor: null,- env: { HERMES_DESKTOP_NVIDIA_SWIFTSHADER: '1' }- })+ it('HERMES_DESKTOP_NVIDIA_SWIFTSHADER forces the fallback on without any marker', () => {+ const decision = decideNvidiaEglFallback({ ...PROBE, env: { HERMES_DESKTOP_NVIDIA_SWIFTSHADER: '1' }, marker: null })expect(decision.enable).toBe(true)expect(decision.reason).toContain('override')})- it('HERMES_DESKTOP_NVIDIA_SWIFTSHADER=0 opts out even on affected drivers', () => {+ it('HERMES_DESKTOP_NVIDIA_SWIFTSHADER=0 opts out even over a witnessed marker', () => {+ const marker = nvidiaEglFallbackMarker('0.21.5', '580.178.04')+expect(- decideNvidiaEglFallback({- ...LINUX,- driverMajor: 580,- env: { HERMES_DESKTOP_NVIDIA_SWIFTSHADER: 'off' }- }).enable+ decideNvidiaEglFallback({ ...PROBE, marker, env: { HERMES_DESKTOP_NVIDIA_SWIFTSHADER: 'off' } }).enable).toBe(false)})})++// ─── the runtime witness ────────────────────────────────────────────────────++describe('shouldRelaunchForNvidiaGpuDeath', () => {+ const BASE = { platform: 'linux' as const, fallbackActive: false, relaunchAttempted: false }++ it('relaunches on a GPU crash', () => {+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: { type: 'GPU', reason: 'crashed' } })).toBe(true)+ })++ it('relaunches on a GPU launch failure', () => {+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: { type: 'GPU', reason: 'launch-failure' } })).toBe(true)+ })++ it("counts `killed`: the #40077 GPU process died to Chromium's health-check SIGTERM (exit_code=15)", () => {+ expect(NVIDIA_GPU_DEATH_REASONS.has('killed')).toBe(true)+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: { type: 'GPU', reason: 'killed' } })).toBe(true)+ })++ it('never relaunches twice in one process, or when the fallback is already active', () => {+ const details = { type: 'GPU', reason: 'crashed' }++ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details, relaunchAttempted: true })).toBe(false)+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details, fallbackActive: true })).toBe(false)+ })++ it('ignores non-GPU deaths, clean exits, and other platforms', () => {+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: { type: 'renderer', reason: 'crashed' } })).toBe(false)+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: { type: 'GPU', reason: 'clean-exit' } })).toBe(false)+ expect(shouldRelaunchForNvidiaGpuDeath({ ...BASE, details: null })).toBe(false)+ expect(+ shouldRelaunchForNvidiaGpuDeath({ ...BASE, platform: 'darwin', details: { type: 'GPU', reason: 'crashed' } })+ ).toBe(false)+ })+})++// ─── marker lifecycle ───────────────────────────────────────────────────────++describe('marker persistence', () => {+ it('round-trips through the userData dir', () => {+ const dir = tmpUserData()+ const marker = nvidiaEglFallbackMarker('0.21.5', '580.178.04')++ writeNvidiaEglMarker(dir, marker)++ expect(readNvidiaEglMarker(dir)).toEqual(marker)+ })++ it('returns null for a missing or garbage marker', () => {+ const dir = tmpUserData()++ expect(readNvidiaEglMarker(dir)).toBeNull()+ expect(readNvidiaEglMarker(dir, { readFileSync: () => 'not json' as never })).toBeNull()+ })++ it('a healthy boot marks ok; a fallback boot keeps the sticky marker', () => {+ expect(nvidiaEglMarkerAfterSuccessfulBoot({ fallbackActive: false })).toEqual({ state: 'ok' })++ expect(+ nvidiaEglMarkerAfterSuccessfulBoot({+ fallbackActive: true,+ appVersion: '0.21.5',+ driverVersion: '580.178.04'+ })+ ).toEqual(nvidiaEglFallbackMarker('0.21.5', '580.178.04'))+ })+})diff --git a/apps/desktop/electron/linux-nvidia-egl-fallback.ts b/apps/desktop/electron/linux-nvidia-egl-fallback.tsindex 30734621982..527d3482aa9 100644--- a/apps/desktop/electron/linux-nvidia-egl-fallback.ts+++ b/apps/desktop/electron/linux-nvidia-egl-fallback.ts@@ -1,46 +1,133 @@/**- * Linux NVIDIA 580-series EGL fallback for #40077.+ * Linux NVIDIA EGL fallback for #40077 / #124255.*- * NVIDIA driver 580.x breaks ANGLE's EGL probing on X11/Wayland: the bundled- * ANGLE `libEGL.so` probes the driver's EGL implementation, hits the 580- * EGL/X11 bug ("Invalid visual ID requested"), and the GPU process dies —- * taking the app with it. Rendering through ANGLE's SwiftShader backend- * (`--use-angle=swiftshader`) skips the NVIDIA EGL probe entirely, so the app- * launches and stays up; the cost is CPU rendering (slow but stable).+ * History: NVIDIA driver 580.x breaks ANGLE's EGL probing on X11/Wayland+ * ("Invalid visual ID requested"), the GPU process dies, and the app goes down+ * with it. Rendering ANGLE through SwiftShader (`--use-angle=swiftshader`)+ * skips the NVIDIA EGL probe entirely, so the app launches and stays up — at+ * the cost of CPU compositing.+ *+ * The gate used to be a driver-major set (first `>= 580`, then the closed+ * `{580}` from #123213). But the same driver point release breaks one host and+ * not another — 580.178.04 kills the GPU process on a desktop where NVIDIA+ * drives the display (#40077, #124032) and renders fine on hybrid hosts whose+ * session EGL lands on the iGPU (#124255, psukez on #123203). A driver-series+ * bound cannot separate them, and the all-CPU SwiftShader fallback converts a+ * known Chromium stuck-Button-observer leak (~0 cost with GPU compositing)+ * into a 4–9 core burn on every healthy 580 host.+ *+ * So the gate is now behavioral (#124255 Option A): a Linux + NVIDIA host+ * boots with hardware GL and a `booting` marker; if the GPU process dies+ * before the first window is revealed, the marker turns `fallback` (sticky+ * per app version + full driver version) and the app relaunches once with+ * `--use-angle=swiftshader`. A healthy boot marks `ok` and keeps full+ * acceleration. An app update re-probes once instead of degrading forever.+ *+ * If Chromium's "GPU process isn't usable" FATAL abort wins the race and the+ * process dies before the handler runs, the leftover `booting` marker engages+ * the fallback on the next launch.** Deliberately NOT `app.disableHardwareAcceleration()`: on 580.173.02 +* Electron 40 that path SIGKILLs the renderer (see #40077 discussion, and the* closed #40119 which was rejected for exactly this). We only reroute ANGLE;* we never disable the GPU pipeline wholesale.*- * Skipped when a remote display already forced software rendering (the- * `--disable-gpu-compositing` path covers it), under WSLg (vGPU is healthy- * there), or when `HERMES_DESKTOP_DISABLE_GPU=0` keeps the GPU on.- * `HERMES_DESKTOP_NVIDIA_SWIFTSHADER=1` can force the fallback back on on an- * affected series that this closed set does not yet list (e.g. a future- * series that reintroduces the #40077 crash); it cannot force it on where an- * earlier gate already returned (remote display, WSLg, `DISABLE_GPU=0`).+ * Skipped when a remote display already forced software rendering, under WSLg+ * (vGPU is healthy there), or when `HERMES_DESKTOP_DISABLE_GPU=0` keeps the+ * GPU on. `HERMES_DESKTOP_NVIDIA_SWIFTSHADER=1` forces the fallback on;+ * `=0` opts out entirely.** Pure + dependency-free so it can be unit-tested and called before app ready.*/+import fs from 'node:fs'+import path from 'node:path'+const OVERRIDE_ON = new Set(['1', 'true', 'yes', 'on'])const OVERRIDE_OFF = new Set(['0', 'false', 'no', 'off'])+export const NVIDIA_EGL_FALLBACK_MARKER_FILENAME = 'nvidia-egl-fallback.json'+/**- * Driver major series known to carry the broken EGL/X11 probing (#40077).- * Only series with confirmed reports belong here: 580.159.03 and 580.173.02- * are the affected reports, 570.x is the recommended downgrade, and newer- * series (e.g. 615.x, #123203) probe fine — an open-ended `>= 580` wrongly- * forced them onto CPU SwiftShader rendering. That is the EGL probe only: 615.x- * still crashes on Wayland ozone (#126013), which is why wslg-launch.ts keeps- * the NVIDIA proprietary driver on XWayland by default.+ * `child-process-gone` reasons that witness a broken GPU child. `killed` is+ * included on purpose: in #40077 the GPU process exited with exit_code=15 —+ * Chromium's own GPU health check SIGTERM — not a crash reason.*/-export const NVIDIA_BROKEN_EGL_MAJORS: ReadonlySet<number> = new Set([580])+export const NVIDIA_GPU_DEATH_REASONS: ReadonlySet<string> = new Set(['crashed', 'launch-failure', 'killed'])-export interface NvidiaEglFallbackDecision {- enable: boolean- reason: string | null+export type NvidiaEglMarkerState = 'booting' | 'fallback' | 'ok'++export interface NvidiaEglMarker {+ state: NvidiaEglMarkerState+ /** App version that entered fallback — a version change triggers a re-probe. */+ version?: string+ /** Full driver version (e.g. "580.178.04") the fallback was witnessed on. */+ driverVersion?: string+}++export function nvidiaEglMarkerPath(userDataDir: string): string {+ return path.join(String(userDataDir || ''), NVIDIA_EGL_FALLBACK_MARKER_FILENAME)+}++export function parseNvidiaEglMarker(raw: unknown): NvidiaEglMarker | null {+ if (!raw || typeof raw !== 'object') {+ return null+ }++ const record = raw as Record<string, unknown>+ const state = record.state++ if (state !== 'booting' && state !== 'fallback' && state !== 'ok') {+ return null+ }++ const marker: NvidiaEglMarker = { state }++ if (typeof record.version === 'string' && record.version) {+ marker.version = record.version+ }++ if (typeof record.driverVersion === 'string' && record.driverVersion) {+ marker.driverVersion = record.driverVersion+ }++ return marker+}++export function readNvidiaEglMarker(+ userDataDir: string,+ { readFileSync = fs.readFileSync } = {}+): NvidiaEglMarker | null {+ try {+ return parseNvidiaEglMarker(JSON.parse(readFileSync(nvidiaEglMarkerPath(userDataDir), 'utf8')))+ } catch {+ return null+ }+}++export function writeNvidiaEglMarker(+ userDataDir: string,+ marker: NvidiaEglMarker,+ {+ mkdirSync = fs.mkdirSync,+ writeFileSync = fs.writeFileSync+ }: {+ mkdirSync?: typeof fs.mkdirSync+ writeFileSync?: typeof fs.writeFileSync+ } = {}+): void {+ const dir = String(userDataDir || '')++ if (!dir) {+ return+ }++ mkdirSync(dir, { recursive: true })+ writeFileSync(nvidiaEglMarkerPath(dir), `${JSON.stringify(marker)}\n`, 'utf8')+}++export function nvidiaEglFallbackMarker(appVersion: string, driverVersion: string): NvidiaEglMarker {+ return { state: 'fallback', version: appVersion, driverVersion }}/**@@ -59,8 +146,45 @@ export function parseNvidiaDriverMajor(procVersion: string): number | null {return Number.isFinite(major) ? major : null}+/**+ * Extract the FULL driver version ("580.178.04") from /proc/driver/nvidia/version.+ * The marker is keyed on it so a driver update re-probes like an app update.+ */+export function parseNvidiaDriverVersion(procVersion: string): string | null {+ const match = /\b(\d{3,}\.\d+\.\d+)\b/.exec(String(procVersion || ''))++ return match ? match[1] : null+}++export interface NvidiaEglFallbackDecision {+ enable: boolean+ reason: string | null+ /** Marker to persist immediately, before GPU children start. */+ nextMarker: NvidiaEglMarker+}++/**+ * Single launch-time transition: whether this Linux launch routes ANGLE+ * through SwiftShader, and what the marker becomes. The probe shape:+ *+ * - `fallback` marker matching this app version AND driver version → enable,+ * keep the marker (sticky until either version changes).+ * - `fallback` marker for a different app or driver version → re-probe once:+ * boot with hardware GL, write `booting`.+ * - `booting` marker left behind by a launch that died before it could mark+ * `ok` (the "GPU process isn't usable" FATAL abort) → enable; the previous+ * boot witnessed a GPU death by not surviving.+ * - `ok` or no marker → boot with hardware GL, write `booting` so a death+ * mid-boot is attributable.+ *+ * The env override `HERMES_DESKTOP_NVIDIA_SWIFTSHADER=1` forces the fallback+ * on regardless of the marker; `=0` keeps it off and clears the marker.+ */export function decideNvidiaEglFallback(options: {driverMajor: number | null+ driverVersion?: string | null+ marker?: NvidiaEglMarker | null+ appVersion?: stringenv?: NodeJS.ProcessEnvplatform?: NodeJS.PlatformisWsl?: boolean@@ -71,17 +195,23 @@ export function decideNvidiaEglFallback(options: {const isWsl = options.isWsl ?? falseconst remoteDisplayReason = options.remoteDisplayReason ?? nullconst driverMajor = options.driverMajor+ const driverVersion = options.driverVersion ?? null+ const appVersion = options.appVersion ?? ''+ const marker = options.marker ?? null++ const bootMarker: NvidiaEglMarker = { state: 'booting' }const nvidiaOverride = String(env.HERMES_DESKTOP_NVIDIA_SWIFTSHADER || '').trim().toLowerCase()if (OVERRIDE_OFF.has(nvidiaOverride)) {- return { enable: false, reason: null }+ return { enable: false, reason: null, nextMarker: bootMarker }}- if (platform !== 'linux') {- return { enable: false, reason: null }+ if (platform !== 'linux' || driverMajor === null) {+ // No NVIDIA driver to probe — nothing to persist either.+ return { enable: false, reason: null, nextMarker: bootMarker }}// A user who forced GPU back on (HERMES_DESKTOP_DISABLE_GPU=0) owns that call.@@ -90,30 +220,98 @@ export function decideNvidiaEglFallback(options: {.toLowerCase()if (OVERRIDE_OFF.has(gpuOverride)) {- return { enable: false, reason: null }+ return { enable: false, reason: null, nextMarker: bootMarker }}// The remote-display path already forces full software rendering; don't pile// ANGLE switches on top of `disableHardwareAcceleration`.if (remoteDisplayReason) {- return { enable: false, reason: null }+ return { enable: false, reason: null, nextMarker: bootMarker }}- // WSLg reports a healthy vGPU; NVIDIA 580 EGL probing hasn't been reported+ // WSLg reports a healthy vGPU; NVIDIA EGL probing hasn't been reported// broken there. Keep the WSL GPU passthrough path untouched.if (isWsl) {- return { enable: false, reason: null }+ return { enable: false, reason: null, nextMarker: bootMarker }}- const detected = driverMajor !== null && NVIDIA_BROKEN_EGL_MAJORS.has(driverMajor)+ if (OVERRIDE_ON.has(nvidiaOverride)) {+ return { enable: true, reason: 'override (HERMES_DESKTOP_NVIDIA_SWIFTSHADER)', nextMarker: bootMarker }+ }++ // Witnessed brokenness: sticky only for the same app AND driver version.+ if (+ marker?.state === 'fallback' &&+ marker.version === (appVersion || marker.version) &&+ marker.driverVersion === (driverVersion ?? marker.driverVersion)+ ) {+ return {+ enable: true,+ reason: `witnessed GPU-process death (app ${marker.version ?? '?'}, driver ${marker.driverVersion ?? '?'})`,+ nextMarker: marker+ }+ }- if (!detected && !OVERRIDE_ON.has(nvidiaOverride)) {- return { enable: false, reason: null }+ // A booting marker that never resolved: the previous launch died before it+ // could mark a healthy boot — on this driver that means the GPU process+ // took the app down (the "GPU process isn't usable" FATAL abort wins the+ // race against our relaunch handler). Trust it and engage.+ if (marker?.state === 'booting') {+ return {+ enable: true,+ reason: 'previous launch aborted mid-boot with the GPU probe live',+ nextMarker: nvidiaEglFallbackMarker(appVersion, driverVersion ?? String(driverMajor))+ }}- const reason = detected- ? `NVIDIA driver ${driverMajor} (known-broken EGL series)`- : 'override (HERMES_DESKTOP_NVIDIA_SWIFTSHADER)'+ // ok, stale fallback (app or driver updated), or first boot: probe the GPU.+ return { enable: false, reason: null, nextMarker: bootMarker }+}++export interface NvidiaGpuDeathOptions {+ platform?: NodeJS.Platform | string+ details: { type?: string; reason?: string } | null+ /** The fallback is already active this launch (sticky marker or override). */+ fallbackActive: boolean+ /** This process already attempted the one-shot relaunch. */+ relaunchAttempted: boolean+}++/**+ * Whether a `child-process-gone` event witnesses the #40077 GPU death and+ * should trigger the one-shot SwiftShader relaunch. `killed` counts: the+ * #40077 GPU process exited with exit_code=15, Chromium's health-check+ * SIGTERM, not a crash reason.+ */+export function shouldRelaunchForNvidiaGpuDeath({+ platform = process.platform,+ details,+ fallbackActive,+ relaunchAttempted+}: NvidiaGpuDeathOptions): boolean {+ if (platform !== 'linux' || fallbackActive || relaunchAttempted) {+ return false+ }++ const type = String(details?.type ?? '').toLowerCase()+ const reason = String(details?.reason ?? '').toLowerCase()++ return (type === 'gpu' || type === 'gpu-process') && NVIDIA_GPU_DEATH_REASONS.has(reason)+}++/**+ * After the first window is revealed: the GPU survived this boot. Keep a+ * sticky fallback when we launched with SwiftShader, otherwise mark a clean+ * boot so future launches trust the GPU again.+ */+export function nvidiaEglMarkerAfterSuccessfulBoot(options: {+ fallbackActive: boolean+ appVersion?: string+ driverVersion?: string | null+}): NvidiaEglMarker {+ if (options.fallbackActive) {+ return nvidiaEglFallbackMarker(options.appVersion ?? '', options.driverVersion ?? '')+ }- return { enable: true, reason }+ return { state: 'ok' }}diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 50410d66833..885465bddaa 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -323,7 +323,16 @@ import { isAuthWall, resolveLinkTitle } from './link-title-wall'import { createLinkTitleWindow, guardLinkTitleSession, readLinkTitleWindowTitle } from './link-title-window'import { CHROMIUM_LOG_FILENAME, enableLinuxCrashDiagnostics, linuxCrashDiagnostics } from './linux-crash-diagnostics'import { notifyLauncherWindowRevealed } from './linux-launcher-ready'-import { decideNvidiaEglFallback, parseNvidiaDriverMajor } from './linux-nvidia-egl-fallback'+import {+ decideNvidiaEglFallback,+ nvidiaEglFallbackMarker,+ nvidiaEglMarkerAfterSuccessfulBoot,+ parseNvidiaDriverMajor,+ parseNvidiaDriverVersion,+ readNvidiaEglMarker,+ shouldRelaunchForNvidiaGpuDeath,+ writeNvidiaEglMarker+} from './linux-nvidia-egl-fallback'import { createLocalBackendLifecycle, waitForTeardown } from './local-backend-lifecycle'import { resolveIpcFileReadPath, resolveMediaStreamFile, resolvePreviewTargetPath } from './local-read-path'import { localSkinProfileKey, readLocalSkinPayload } from './local-skin'@@ -773,38 +782,110 @@ if (IS_WSL && !REMOTE_DISPLAY_REASON && fs.existsSync('/dev/dxg')) {console.log('[hermes] WSL GPU passthrough (/dev/dxg) detected; enabling GPU acceleration')}-// #40077: NVIDIA driver 580.x breaks ANGLE's EGL probing (Invalid visual ID),-// killing the GPU process at startup. Route ANGLE through its SwiftShader-// backend instead — the app then launches and stays up (CPU rendering, slow-// but stable). Deliberately NOT disableHardwareAcceleration(): on 580.173.02 +-// Electron 40 that SIGKILLs the renderer (see the closed #40119). Must run-// before app `ready` — the switch only applies pre-launch. Override with-// HERMES_DESKTOP_NVIDIA_SWIFTSHADER (1/true → force on, 0/false → never).+// #40077 / #124255: NVIDIA driver 580.x breaks ANGLE's EGL probing (Invalid+// visual ID), killing the GPU process at startup. Route ANGLE through its+// SwiftShader backend when the breakage is WITNESSED, not assumed: the same+// point release breaks hosts where NVIDIA drives the display and renders fine+// on hybrid hosts whose session EGL lands on the iGPU, so a driver-series gate+// burns 4-9 CPU cores on healthy hosts (#124255). The gate is now behavioral —+// boot with hardware GL and a marker; a GPU-process death before the first+// window flips the marker sticky (per app + full driver version) and relaunches+// once with SwiftShader. Deliberately NOT disableHardwareAcceleration(): on+// 580.173.02 + Electron 40 that SIGKILLs the renderer (see the closed #40119).+// Must run before app `ready` — the switch only applies pre-launch. Override+// with HERMES_DESKTOP_NVIDIA_SWIFTSHADER (1/true → force on, 0/false → never).+const NVIDIA_PROC_VERSION = (() => {+ try {+ return fs.readFileSync('/proc/driver/nvidia/version', 'utf8')+ } catch {+ return ''+ }+})()++const NVIDIA_DRIVER_MAJOR = parseNvidiaDriverMajor(NVIDIA_PROC_VERSION)+const NVIDIA_DRIVER_VERSION = parseNvidiaDriverVersion(NVIDIA_PROC_VERSION)++let nvidiaEglFallbackActive = false+let nvidiaEglRelaunchAttempted = false+const NVIDIA_EGL_FALLBACK = decideNvidiaEglFallback({- driverMajor: parseNvidiaDriverMajor(- (() => {- try {- return fs.readFileSync('/proc/driver/nvidia/version', 'utf8')- } catch {- return ''- }- })()- ),+ driverMajor: NVIDIA_DRIVER_MAJOR,+ driverVersion: NVIDIA_DRIVER_VERSION,+ marker: readNvidiaEglMarker(app.getPath('userData')),+ appVersion: app.getVersion(),env: process.env,platform: process.platform,isWsl: IS_WSL,remoteDisplayReason: REMOTE_DISPLAY_REASON})+nvidiaEglFallbackActive = NVIDIA_EGL_FALLBACK.enable++// Persist the launch decision before GPU children start: a `booting` marker+// left behind by a launch that never reached first paint is itself evidence+// of a GPU death (the "GPU process isn't usable" FATAL abort wins the race+// against our relaunch handler), and the next launch engages from it.+if (NVIDIA_DRIVER_MAJOR !== null) {+ try {+ writeNvidiaEglMarker(app.getPath('userData'), NVIDIA_EGL_FALLBACK.nextMarker)+ } catch {+ void 0+ }+}+if (NVIDIA_EGL_FALLBACK.enable) {app.commandLine.appendSwitch('use-angle', 'swiftshader')console.log(`[hermes] NVIDIA EGL fallback enabled (${NVIDIA_EGL_FALLBACK.reason}); routing ANGLE ` +- 'through SwiftShader to avoid the NVIDIA 580-series EGL probe crash (#40077). ' +- 'HERMES_DESKTOP_NVIDIA_SWIFTSHADER=0 to opt out.'+ 'through SwiftShader. Witnessed GPU-process death probe (#40077, #124255); an app or ' ++ 'driver update re-probes hardware GL once. HERMES_DESKTOP_NVIDIA_SWIFTSHADER=0 to opt out.')}+// The behavioral half of the gate: a GPU-process death on a Linux NVIDIA host+// that booted with hardware GL is the #40077 signature. Catch it before+// Chromium's "GPU process isn't usable" FATAL abort ends the process, flip the+// marker sticky, and relaunch once with SwiftShader. `killed` counts (the+// #40077 GPU process died to Chromium's health-check SIGTERM, exit_code=15).+if (NVIDIA_DRIVER_MAJOR !== null && process.platform === 'linux') {+ app.on('child-process-gone', (_event, details) => {+ if (+ !shouldRelaunchForNvidiaGpuDeath({+ details,+ fallbackActive: nvidiaEglFallbackActive,+ relaunchAttempted: nvidiaEglRelaunchAttempted+ })+ ) {+ return+ }++ nvidiaEglRelaunchAttempted = true++ try {+ writeNvidiaEglMarker(+ app.getPath('userData'),+ nvidiaEglFallbackMarker(app.getVersion(), NVIDIA_DRIVER_VERSION ?? String(NVIDIA_DRIVER_MAJOR))+ )+ } catch {+ void 0+ }++ console.warn(+ `[hermes] NVIDIA GPU process died (reason=${details?.reason}, exit=${details?.exitCode}); ` ++ 'relaunching once with --use-angle=swiftshader (#40077, #124255)'+ )++ try {+ app.relaunch({+ args: [...process.argv.slice(1), '--use-angle=swiftshader']+ })+ void exitAfterBackendShutdown(0)+ } catch (error) {+ console.error(`[hermes] NVIDIA SwiftShader relaunch failed: ${error?.message || error}`)+ }+ })+}+// Linux: point Chromium at the session's keychain backend so safeStorage can// encrypt remote gateway tokens (hardening.ts refuses to persist them without// it). The value arrives via HERMES_DESKTOP_PASSWORD_STORE, bridged by the@@ -15038,6 +15119,24 @@ function createWindow() {// window is on screen (a STARTING gnome-shell app must not see its entry change).notifyLauncherWindowRevealed()+ // #124255: the first revealed window means the GPU survived this boot.+ // Keep a sticky SwiftShader marker when we launched with the fallback;+ // otherwise mark the probe healthy so future launches trust hardware GL.+ if (NVIDIA_DRIVER_MAJOR !== null) {+ try {+ writeNvidiaEglMarker(+ app.getPath('userData'),+ nvidiaEglMarkerAfterSuccessfulBoot({+ fallbackActive: nvidiaEglFallbackActive,+ appVersion: app.getVersion(),+ driverVersion: NVIDIA_DRIVER_VERSION+ })+ )+ } catch {+ void 0+ }+ }+// #38216: clear the mid-boot marker only after a window is actually usable.// Keep sticky `fallback` when we launched with --no-sandbox so the next// Start Menu click does not re-enter the GPU FATAL crash loop. The marker