Skip to content

The agent that grows with you

fix(desktop): bound Linux GPU-child init retry with one-shot software fallback

finn7636a2b23b04cff
diff --git a/apps/desktop/electron/linux-gpu-fallback.test.ts b/apps/desktop/electron/linux-gpu-fallback.test.ts
new file mode 100644
index 00000000000..13e448c5200
--- /dev/null
+++ b/apps/desktop/electron/linux-gpu-fallback.test.ts
@@ -0,0 +1,210 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ decideLinuxGpuLaunch,
+ linuxGpuFallbackMarker,
+ linuxGpuMarkerAfterSuccessfulBoot,
+ parseLinuxGpuMarker,
+ shouldRelaunchForLinuxGpuCrash
+} from './linux-gpu-fallback'
+
+const LINUX = {
+ platform: 'linux' as const,
+ argv: [] as string[],
+ env: {} as NodeJS.ProcessEnv,
+ marker: null,
+ appVersion: '0.21.5',
+ remoteDisplayReason: null as string | null,
+ nvidiaFallbackActive: false
+}
+
+describe('parseLinuxGpuMarker', () => {
+ it('accepts a well-formed fallback marker', () => {
+ expect(
+ parseLinuxGpuMarker({ state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' })
+ ).toEqual({ state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' })
+ })
+
+ it('rejects garbage', () => {
+ expect(parseLinuxGpuMarker(null)).toBeNull()
+ expect(parseLinuxGpuMarker({ state: 'nope' })).toBeNull()
+ expect(parseLinuxGpuMarker('fallback')).toBeNull()
+ })
+})
+
+describe('decideLinuxGpuLaunch', () => {
+ it('stays off on a clean first boot and records booting', () => {
+ const decision = decideLinuxGpuLaunch(LINUX)
+
+ expect(decision.enable).toBe(false)
+ expect(decision.nextMarker.state).toBe('booting')
+ })
+
+ it('stays off on non-linux platforms', () => {
+ const decision = decideLinuxGpuLaunch({ ...LINUX, platform: 'darwin' })
+
+ expect(decision.enable).toBe(false)
+ })
+
+ it('re-engages software rendering from a sticky fallback marker', () => {
+ const decision = decideLinuxGpuLaunch({
+ ...LINUX,
+ marker: { state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' }
+ })
+
+ expect(decision.enable).toBe(true)
+ expect(decision.reason).toContain('sticky')
+ expect(decision.nextMarker.state).toBe('fallback')
+ })
+
+ it('re-probes the GPU once after an app update instead of degrading forever', () => {
+ const decision = decideLinuxGpuLaunch({
+ ...LINUX,
+ marker: { state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.4' }
+ })
+
+ expect(decision.enable).toBe(false)
+ expect(decision.nextMarker).toMatchObject({ state: 'booting', reprobe: true })
+ })
+
+ it('engages after two consecutive aborted boots, not one', () => {
+ const first = decideLinuxGpuLaunch({ ...LINUX, marker: { state: 'booting' } })
+
+ expect(first.enable).toBe(false)
+ expect(first.nextMarker).toMatchObject({ state: 'booting', bootAborts: 1 })
+
+ const second = decideLinuxGpuLaunch({
+ ...LINUX,
+ marker: { state: 'booting', bootAborts: 1 }
+ })
+
+ expect(second.enable).toBe(true)
+ expect(second.reason).toContain('boot-loop')
+ })
+
+ it('HERMES_DESKTOP_DISABLE_GPU=0 keeps the GPU on and clears the stale fallback marker', () => {
+ const decision = decideLinuxGpuLaunch({
+ ...LINUX,
+ env: { HERMES_DESKTOP_DISABLE_GPU: '0' },
+ marker: { state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' }
+ })
+
+ expect(decision.enable).toBe(false)
+ // The override boot is the recovery path the file documents: it must not leave the sticky
+ // marker behind, or the next override-free launch re-engages software rendering from it
+ // and only an app-version change would ever clear it.
+ expect(decision.nextMarker).toEqual({ state: 'booting' })
+ })
+
+ it('keeps the relaunch path sticky when --disable-gpu is already on argv', () => {
+ // Same marker, different entry point: the one-shot relaunch writes `fallback` and re-execs
+ // with --disable-gpu, so that boot must preserve it — clearing it here would re-arm the
+ // GPU-child retry loop this fallback exists to stop.
+ const decision = decideLinuxGpuLaunch({
+ ...LINUX,
+ argv: ['--disable-gpu'],
+ marker: { state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' }
+ })
+
+ expect(decision.reason).toBe('already-enabled')
+ expect(decision.nextMarker).toMatchObject({
+ state: 'fallback',
+ reason: 'gpu-launch-failure',
+ version: '0.21.5'
+ })
+ })
+
+ it('stays off when software rendering is already forced', () => {
+ expect(decideLinuxGpuLaunch({ ...LINUX, remoteDisplayReason: 'ssh-session' }).enable).toBe(false)
+ expect(decideLinuxGpuLaunch({ ...LINUX, nvidiaFallbackActive: true }).enable).toBe(false)
+ expect(
+ decideLinuxGpuLaunch({ ...LINUX, argv: ['--disable-gpu'] }).reason
+ ).toBe('already-enabled')
+ })
+})
+
+describe('shouldRelaunchForLinuxGpuCrash', () => {
+ it('relaunches once on a GPU launch failure (error_code=1002 class)', () => {
+ expect(
+ shouldRelaunchForLinuxGpuCrash({
+ platform: 'linux',
+ details: { type: 'GPU', reason: 'launch-failure' },
+ alreadySoftware: false,
+ relaunchAttempted: false
+ })
+ ).toBe(true)
+ })
+
+ it('relaunches once on a GPU crash (SIGTRAP class)', () => {
+ expect(
+ shouldRelaunchForLinuxGpuCrash({
+ platform: 'linux',
+ details: { type: 'gpu', reason: 'crashed' },
+ alreadySoftware: false,
+ relaunchAttempted: false
+ })
+ ).toBe(true)
+ })
+
+ it('never relaunches twice in one process', () => {
+ expect(
+ shouldRelaunchForLinuxGpuCrash({
+ platform: 'linux',
+ details: { type: 'GPU', reason: 'launch-failure' },
+ alreadySoftware: false,
+ relaunchAttempted: true
+ })
+ ).toBe(false)
+ })
+
+ it('ignores non-GPU deaths and clean exits', () => {
+ const base = { platform: 'linux' as const, alreadySoftware: false, relaunchAttempted: false }
+
+ expect(
+ shouldRelaunchForLinuxGpuCrash({ ...base, details: { type: 'renderer', reason: 'crashed' } })
+ ).toBe(false)
+ expect(
+ shouldRelaunchForLinuxGpuCrash({ ...base, details: { type: 'GPU', reason: 'clean-exit' } })
+ ).toBe(false)
+ expect(shouldRelaunchForLinuxGpuCrash({ ...base, details: null })).toBe(false)
+ })
+
+ it('stays off when software rendering is already active or off linux', () => {
+ expect(
+ shouldRelaunchForLinuxGpuCrash({
+ platform: 'linux',
+ details: { type: 'GPU', reason: 'crashed' },
+ alreadySoftware: true,
+ relaunchAttempted: false
+ })
+ ).toBe(false)
+ expect(
+ shouldRelaunchForLinuxGpuCrash({
+ platform: 'win32',
+ details: { type: 'GPU', reason: 'crashed' },
+ alreadySoftware: false,
+ relaunchAttempted: false
+ })
+ ).toBe(false)
+ })
+})
+
+describe('linuxGpuMarkerAfterSuccessfulBoot', () => {
+ it('marks a clean boot ok', () => {
+ expect(linuxGpuMarkerAfterSuccessfulBoot({ fallbackActive: false })).toEqual({ state: 'ok' })
+ })
+
+ it('keeps the sticky fallback after a software-rendered boot', () => {
+ expect(
+ linuxGpuMarkerAfterSuccessfulBoot({ fallbackActive: true, appVersion: '0.21.5' })
+ ).toEqual({ state: 'fallback', reason: 'gpu-launch-failure', version: '0.21.5' })
+ })
+
+ it('round-trips the fallback marker helper', () => {
+ expect(linuxGpuFallbackMarker('gpu-launch-failure', '0.21.5')).toEqual({
+ state: 'fallback',
+ reason: 'gpu-launch-failure',
+ version: '0.21.5'
+ })
+ })
+})
diff --git a/apps/desktop/electron/linux-gpu-fallback.ts b/apps/desktop/electron/linux-gpu-fallback.ts
new file mode 100644
index 00000000000..8b95ef9bf66
--- /dev/null
+++ b/apps/desktop/electron/linux-gpu-fallback.ts
@@ -0,0 +1,291 @@
+/**
+ * Linux GPU-child software fallback for #124843.
+ *
+ * On Mesa/Wayland (Intel iGPU, no NVIDIA driver) the Chromium GPU child can
+ * fail initialization (`GPU process launch failed: error_code=1002`) and —
+ * instead of crashing — retry inside a sub-zygote forever: ~20 spinning
+ * threads, repeated `/dev/dri/renderD128` opens, no `--type=gpu-process`,
+ * ~350% CPU from launch with no recovery. Chromium never surfaces a fatal,
+ * so the app must bound the retry itself: one relaunch into software
+ * rendering, then a sticky per-version marker so the next boot goes straight
+ * to software. An app update re-probes the GPU once instead of degrading
+ * forever.
+ *
+ * Deliberately reactive, not proactive: a healthy Mesa/Wayland stack (Brave
+ * renders the same node at ~1% CPU) keeps full acceleration. The fallback
+ * engages only on a witnessed GPU launch failure/crash, two consecutive
+ * mid-boot aborts, or a sticky marker from a prior recovery.
+ *
+ * Skipped when software rendering is already on (remote-display path,
+ * NVIDIA SwiftShader path, `HERMES_DESKTOP_DISABLE_GPU=1`, `--disable-gpu`),
+ * and never when `HERMES_DESKTOP_DISABLE_GPU=0` keeps the GPU on.
+ *
+ * Pure + dependency-free so it can be unit-tested and called before app ready.
+ * `--disable-gpu` argv helpers are reused from windows-stack-cookie-fallback
+ * (one spelling per concept) — they are platform-agnostic despite the name.
+ */
+
+import fs from 'node:fs'
+import path from 'node:path'
+
+import { alreadyHasDisableGpu, isHermesDesktopGpuOverrideOff } from './windows-stack-cookie-fallback'
+
+export const LINUX_GPU_FALLBACK_MARKER_FILENAME = 'linux-gpu-fallback.json'
+
+/** Consecutive mid-boot aborts required before falling back to software. */
+export const BOOT_ABORTS_BEFORE_LINUX_GPU_FALLBACK = 2
+
+/** `child-process-gone` reasons that witness a broken GPU child. */
+const GPU_FAILURE_REASONS = new Set(['crashed', 'launch-failure'])
+
+export type LinuxGpuMarkerState = 'booting' | 'fallback' | 'ok'
+
+export type LinuxGpuFallbackReason = 'gpu-launch-failure' | 'gpu-crash' | 'boot-loop'
+
+export interface LinuxGpuMarker {
+ state: LinuxGpuMarkerState
+ /** Why the fallback engaged (state === 'fallback'). */
+ reason?: LinuxGpuFallbackReason
+ /** App version that entered fallback — a version change triggers a re-probe. */
+ version?: string
+ /** Consecutive aborted boots observed so far (state === 'booting'). */
+ bootAborts?: number
+ /** This boot is a GPU re-probe after an app update; an abort returns
+ * straight to fallback instead of restarting the two-strike count. */
+ reprobe?: boolean
+}
+
+export function linuxGpuMarkerPath(userDataDir: string): string {
+ return path.join(String(userDataDir || ''), LINUX_GPU_FALLBACK_MARKER_FILENAME)
+}
+
+const FALLBACK_REASONS: readonly string[] = ['gpu-launch-failure', 'gpu-crash', 'boot-loop']
+
+export function parseLinuxGpuMarker(raw: unknown): LinuxGpuMarker | 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: LinuxGpuMarker = { state }
+
+ if (typeof record.reason === 'string' && FALLBACK_REASONS.includes(record.reason)) {
+ marker.reason = record.reason as LinuxGpuFallbackReason
+ }
+
+ if (typeof record.version === 'string' && record.version) {
+ marker.version = record.version
+ }
+
+ const aborts = Number(record.bootAborts)
+
+ if (Number.isInteger(aborts) && aborts > 0) {
+ marker.bootAborts = aborts
+ }
+
+ if (record.reprobe === true) {
+ marker.reprobe = true
+ }
+
+ return marker
+}
+
+export function readLinuxGpuMarker(
+ userDataDir: string,
+ { readFileSync = fs.readFileSync } = {}
+): LinuxGpuMarker | null {
+ try {
+ const raw = JSON.parse(readFileSync(linuxGpuMarkerPath(userDataDir), 'utf8'))
+
+ return parseLinuxGpuMarker(raw)
+ } catch {
+ return null
+ }
+}
+
+export function writeLinuxGpuMarker(
+ userDataDir: string,
+ marker: LinuxGpuMarker,
+ {
+ 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(linuxGpuMarkerPath(dir), `${JSON.stringify(marker)}\n`, 'utf8')
+}
+
+export function linuxGpuFallbackMarker(reason: LinuxGpuFallbackReason, appVersion?: string): LinuxGpuMarker {
+ const marker: LinuxGpuMarker = { state: 'fallback', reason }
+
+ if (appVersion) {
+ marker.version = appVersion
+ }
+
+ return marker
+}
+
+/**
+ * After the main window is revealed: keep the sticky fallback when we
+ * launched with software rendering, otherwise mark a clean boot so future
+ * launches trust the GPU again.
+ */
+export function linuxGpuMarkerAfterSuccessfulBoot(options: {
+ fallbackActive: boolean
+ appVersion?: string
+}): LinuxGpuMarker {
+ if (!options.fallbackActive) {
+ return { state: 'ok' }
+ }
+
+ return linuxGpuFallbackMarker('gpu-launch-failure', options.appVersion)
+}
+
+export interface LinuxGpuLaunchDecision {
+ enable: boolean
+ reason: string | null
+ /** Marker to persist immediately, before GPU children start. */
+ nextMarker: LinuxGpuMarker
+}
+
+/**
+ * Single launch-time transition: decide whether this Linux launch disables
+ * GPU hardware acceleration AND what the marker becomes for crash-detection
+ * on the next launch. Same lifecycle as the Windows sandbox fallback:
+ * sticky per app version, two-strike boot-loop detection, one post-update
+ * re-probe.
+ */
+export function decideLinuxGpuLaunch(
+ options: {
+ platform?: NodeJS.Platform | string
+ argv?: readonly string[]
+ env?: NodeJS.ProcessEnv
+ marker?: LinuxGpuMarker | null
+ appVersion?: string
+ remoteDisplayReason?: string | null
+ nvidiaFallbackActive?: boolean
+ } = {}
+): LinuxGpuLaunchDecision {
+ const appVersion = String(options.appVersion || '')
+
+ if ((options.platform ?? process.platform) !== 'linux') {
+ return { enable: false, reason: null, nextMarker: { state: 'booting' } }
+ }
+
+ const argv = options.argv ?? process.argv
+ const env = options.env ?? process.env
+ const marker = options.marker ?? null
+
+ // A user who forced GPU back on owns that call — even over a sticky marker. That boot is
+ // the recovery path this file documents, so it must not leave the stale fallback marker
+ // behind: keeping it makes `main.ts` sticky again, the next override-free launch re-engages
+ // software rendering (`sticky-fallback`) and only an app-version change would clear it.
+ if (isHermesDesktopGpuOverrideOff(env)) {
+ return { enable: false, reason: null, nextMarker: { state: 'booting' } }
+ }
+
+ if (alreadyHasDisableGpu(argv, env)) {
+ // Honor the explicit flag; keep the marker lifecycle unchanged. When the
+ // relaunch path set the flag, the fallback marker it wrote is preserved.
+ const nextMarker: LinuxGpuMarker = marker?.state === 'fallback' ? marker : { state: 'booting' }
+
+ return { enable: true, reason: 'already-enabled', nextMarker }
+ }
+
+ // The remote-display and NVIDIA paths already force software rendering;
+ // don't pile a second fallback on top of theirs.
+ if (options.remoteDisplayReason || options.nvidiaFallbackActive) {
+ return { enable: false, reason: null, nextMarker: { state: 'booting' } }
+ }
+
+ if (marker?.state === 'fallback') {
+ if (marker.version && appVersion && marker.version !== appVersion) {
+ // App updated since the fallback engaged — re-probe the GPU once.
+ return {
+ enable: false,
+ reason: null,
+ nextMarker: { state: 'booting', reprobe: true, bootAborts: 0 }
+ }
+ }
+
+ return {
+ enable: true,
+ reason: `sticky-fallback (${marker.reason ?? 'gpu-launch-failure'})`,
+ nextMarker: { ...marker, version: marker.version || appVersion || undefined }
+ }
+ }
+
+ if (marker?.state === 'booting') {
+ const abortsObserved = (marker.bootAborts ?? 0) + 1
+
+ if (marker.reprobe) {
+ // The one post-update GPU re-probe aborted → back to fallback.
+ return {
+ enable: true,
+ reason: 'reprobe-failed (boot-loop)',
+ nextMarker: linuxGpuFallbackMarker('boot-loop', appVersion)
+ }
+ }
+
+ if (abortsObserved >= BOOT_ABORTS_BEFORE_LINUX_GPU_FALLBACK) {
+ return {
+ enable: true,
+ reason: 'boot-loop',
+ nextMarker: linuxGpuFallbackMarker('boot-loop', appVersion)
+ }
+ }
+
+ return {
+ enable: false,
+ reason: null,
+ nextMarker: { state: 'booting', bootAborts: abortsObserved }
+ }
+ }
+
+ // No marker, or a clean `ok` from the previous run.
+ return { enable: false, reason: null, nextMarker: { state: 'booting' } }
+}
+
+/**
+ * True when a Linux GPU child died with launch-failure/crash evidence and we
+ * should one-shot relaunch with `--disable-gpu` before Chromium's retry loop
+ * burns the machine (#124843). Bounded: once per process (caller tracks
+ * `relaunchAttempted`), sticky across boots via the marker the caller writes.
+ */
+export function shouldRelaunchForLinuxGpuCrash(options: {
+ platform?: NodeJS.Platform | string
+ details?: { type?: string; reason?: string } | null
+ alreadySoftware?: boolean
+ relaunchAttempted?: boolean
+}): boolean {
+ if ((options.platform ?? process.platform) !== 'linux') {
+ return false
+ }
+
+ if (options.alreadySoftware || options.relaunchAttempted) {
+ return false
+ }
+
+ const type = String(options.details?.type || '').toLowerCase()
+
+ if (type !== 'gpu') {
+ return false
+ }
+
+ return GPU_FAILURE_REASONS.has(String(options.details?.reason || '').toLowerCase())
+}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 420f27aff0b..48026b85d6c 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -668,6 +668,14 @@ import {
shouldSurfaceErrorForRendererStackCookieCrashLoop,
writeGpuStackCookieMarker
} from './windows-stack-cookie-fallback'
+import {
+ decideLinuxGpuLaunch,
+ linuxGpuFallbackMarker,
+ linuxGpuMarkerAfterSuccessfulBoot,
+ readLinuxGpuMarker,
+ shouldRelaunchForLinuxGpuCrash,
+ writeLinuxGpuMarker
+} from './linux-gpu-fallback'
import { readWindowsUserEnvVar } from './windows-user-env'
import { isPackagedInstallPath as isPackagedInstallPathUnderRoots } from './workspace-cwd'
import { readWslWindowsClipboardImage } from './wsl-clipboard-image'
@@ -909,6 +917,51 @@ if (NVIDIA_DRIVER_MAJOR !== null && process.platform === 'linux') {
})
}
+// #124843: on Mesa/Wayland the Chromium GPU child can fail init
+// (error_code=1002) and retry inside a sub-zygote forever — ~350% CPU, no
+// gpu-process, no crash. Bound it: one relaunch into software rendering,
+// then a sticky per-version marker so the next boot goes straight there.
+// Reactive only — healthy Mesa/Wayland stacks keep full acceleration. Must
+// run before app `ready`. Override with HERMES_DESKTOP_DISABLE_GPU
+// (1/true → always software, 0/false → keep GPU on).
+let linuxGpuFallbackActive = false
+let linuxGpuFallbackSticky = false
+let linuxGpuRelaunchAttempted = false
+
+const LINUX_GPU_SOFTWARE_ACTIVE =
+ Boolean(REMOTE_DISPLAY_REASON) || NVIDIA_EGL_FALLBACK.enable || alreadyHasDisableGpu(process.argv, process.env)
+
+if (process.platform === 'linux') {
+ const linuxGpuUserData = app.getPath('userData')
+
+ const linuxGpuDecision = decideLinuxGpuLaunch({
+ argv: process.argv,
+ env: process.env,
+ marker: readLinuxGpuMarker(linuxGpuUserData),
+ appVersion: app.getVersion(),
+ remoteDisplayReason: REMOTE_DISPLAY_REASON,
+ nvidiaFallbackActive: NVIDIA_EGL_FALLBACK.enable
+ })
+
+ linuxGpuFallbackActive = linuxGpuDecision.enable
+ linuxGpuFallbackSticky = linuxGpuDecision.nextMarker.state === 'fallback'
+
+ try {
+ writeLinuxGpuMarker(linuxGpuUserData, linuxGpuDecision.nextMarker)
+ } catch {
+ void 0
+ }
+
+ if (linuxGpuDecision.enable && linuxGpuDecision.reason !== 'already-enabled' && !LINUX_GPU_SOFTWARE_ACTIVE) {
+ app.disableHardwareAcceleration()
+ app.commandLine.appendSwitch('disable-gpu-compositing')
+ console.log(
+ `[hermes] Linux GPU software fallback enabled (${linuxGpuDecision.reason}); disabling GPU ` +
+ 'hardware acceleration after a GPU-child init failure (#124843). HERMES_DESKTOP_DISABLE_GPU=0 to opt out.'
+ )
+ }
+}
+
// 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
@@ -1026,6 +1079,49 @@ if (IS_WINDOWS) {
})
}
+// #124843: catch a Linux GPU-child launch failure/crash and relaunch once
+// with --disable-gpu before Chromium's init-retry loop burns the machine.
+// No-op when software rendering is already on.
+if (process.platform === 'linux') {
+ app.on('child-process-gone', (_event, details) => {
+ const alreadySoftware =
+ LINUX_GPU_SOFTWARE_ACTIVE || linuxGpuFallbackActive || alreadyHasDisableGpu(process.argv, process.env)
+
+ if (
+ !shouldRelaunchForLinuxGpuCrash({
+ details,
+ alreadySoftware,
+ relaunchAttempted: linuxGpuRelaunchAttempted
+ })
+ ) {
+ return
+ }
+
+ linuxGpuRelaunchAttempted = true
+ linuxGpuFallbackActive = true
+ linuxGpuFallbackSticky = true
+
+ const reason = String(details?.reason || '').toLowerCase() === 'launch-failure' ? 'gpu-launch-failure' : 'gpu-crash'
+
+ try {
+ writeLinuxGpuMarker(app.getPath('userData'), linuxGpuFallbackMarker(reason, app.getVersion()))
+ } catch {
+ void 0
+ }
+
+ console.warn(
+ `[hermes] Linux GPU child gone (reason=${details?.reason}); relaunching once with --disable-gpu (#124843)`
+ )
+
+ try {
+ app.relaunch({ args: buildDisableGpuRelaunchArgs(process.argv.slice(1)) })
+ void exitAfterBackendShutdown(0)
+ } catch (error) {
+ console.error(`[hermes] --disable-gpu relaunch failed: ${error?.message || error}`)
+ }
+ })
+}
+
ipcMain.handle('hermes:get-remote-display-reason', () => REMOTE_DISPLAY_REASON)
// Keep the renderer's PROCESS priority normal while its windows are hidden —
@@ -15121,6 +15217,23 @@ function createWindow() {
rememberLog(`[gpu] stack-cookie marker update after main-window reveal failed: ${error?.message || error}`)
}
}
+
+ // #124843: clear the mid-boot marker only after a window is actually
+ // usable. Keep sticky `fallback` when we launched with software
+ // rendering so the next launch skips the GPU-child retry loop.
+ if (process.platform === 'linux') {
+ try {
+ writeLinuxGpuMarker(
+ app.getPath('userData'),
+ linuxGpuMarkerAfterSuccessfulBoot({
+ fallbackActive: linuxGpuFallbackSticky,
+ appVersion: app.getVersion()
+ })
+ )
+ } catch (error) {
+ rememberLog(`[gpu] linux marker update after main-window reveal failed: ${error?.message || error}`)
+ }
+ }
}
})
@@ -19487,6 +19600,16 @@ app.on('before-quit', event => {
}
}
+ // #124843: a clean quit mid-boot must not trip next-launch --disable-gpu.
+ // Keyed on sticky (not active) so an engaged fallback keeps its marker.
+ if (process.platform === 'linux' && !linuxGpuFallbackSticky) {
+ try {
+ writeLinuxGpuMarker(app.getPath('userData'), linuxGpuMarkerAfterSuccessfulBoot({ fallbackActive: false }))
+ } catch {
+ void 0
+ }
+ }
+
// The always-on-top overlay isn't a "real" app window; close it so a stray
// pet can't keep the process alive or float over a quit app.
closePetOverlay()