Skip to content

The agent that grows with you

fix(desktop): keep the NVIDIA proprietary driver on XWayland by default

Austin Pickette050902e7c03
diff --git a/apps/desktop/electron/entry.ts b/apps/desktop/electron/entry.ts
index 2b0c151c70e..4ed38a1e199 100644
--- a/apps/desktop/electron/entry.ts
+++ b/apps/desktop/electron/entry.ts
@@ -1,4 +1,4 @@
-import { readFileSync } from 'node:fs'
+import { existsSync, readFileSync } from 'node:fs'
import os from 'node:os'
import path from 'node:path'
@@ -30,8 +30,19 @@ function configuredElectronFlags(env: NodeJS.ProcessEnv): string[] {
}
}
-const electronFlags = process.platform === 'linux' ? configuredElectronFlags(process.env) : []
-const args = wslgLaunchArgs(process.argv.slice(1), process.env, process.platform, electronFlags)
+const linux = process.platform === 'linux'
+const electronFlags = linux ? configuredElectronFlags(process.env) : []
+// Present only when the NVIDIA proprietary kernel module is loaded (not
+// nouveau, not WSL's dxg passthrough).
+const nvidiaProprietaryDriver = linux && existsSync('/proc/driver/nvidia/version')
+
+const args = wslgLaunchArgs(
+ process.argv.slice(1),
+ process.env,
+ process.platform,
+ electronFlags,
+ nvidiaProprietaryDriver
+)
if (args) {
// Keep the launcher alive until the child exits: npm's concurrently must not
diff --git a/apps/desktop/electron/linux-nvidia-egl-fallback.ts b/apps/desktop/electron/linux-nvidia-egl-fallback.ts
index 7843b601d7d..30734621982 100644
--- a/apps/desktop/electron/linux-nvidia-egl-fallback.ts
+++ b/apps/desktop/electron/linux-nvidia-egl-fallback.ts
@@ -32,7 +32,9 @@ const OVERRIDE_OFF = new Set(['0', 'false', 'no', 'off'])
* 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.
+ * 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.
*/
export const NVIDIA_BROKEN_EGL_MAJORS: ReadonlySet<number> = new Set([580])
diff --git a/apps/desktop/electron/wslg-launch.test.ts b/apps/desktop/electron/wslg-launch.test.ts
index 24cdb8e0440..96c414a34a8 100644
--- a/apps/desktop/electron/wslg-launch.test.ts
+++ b/apps/desktop/electron/wslg-launch.test.ts
@@ -76,4 +76,24 @@ describe('native Wayland launch arguments', () => {
expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'x11', DISPLAY: ':0' }, 'linux')).toBeNull()
expect(wslgLaunchArgs([], { ...nativeWayland, SSH_CONNECTION: 'remote' }, 'linux')).toBeNull()
})
+
+ // #126013: the NVIDIA proprietary driver's GPU process dies on Wayland ozone.
+ it('defaults the NVIDIA proprietary driver to x11 unless the user chose wayland', () => {
+ expect(wslgLaunchArgs(['.'], nativeWayland, 'linux', [], true)).toEqual(['.', '--ozone-platform=x11'])
+ expect(wslgLaunchArgs([], { ...nativeWayland, ELECTRON_OZONE_PLATFORM_HINT: 'auto' }, 'linux', [], true)).toEqual([
+ '--ozone-platform=x11'
+ ])
+
+ expect(
+ wslgLaunchArgs([], { ...nativeWayland, ELECTRON_OZONE_PLATFORM_HINT: 'wayland' }, 'linux', [], true)
+ ).toEqual(['--ozone-platform=wayland'])
+ expect(wslgLaunchArgs([], nativeWayland, 'linux', ['--ozone-platform-hint=wayland'], true)).toEqual([
+ '--ozone-platform=wayland'
+ ])
+ expect(wslgLaunchArgs([], nativeWayland, 'linux', ['--ozone-platform=wayland'], true)).toEqual([
+ '--ozone-platform=wayland'
+ ])
+ expect(wslgLaunchArgs(['--ozone-platform=wayland'], nativeWayland, 'linux', [], true)).toBeNull()
+ expect(wslgLaunchArgs([], { XDG_SESSION_TYPE: 'x11', DISPLAY: ':0' }, 'linux', [], true)).toBeNull()
+ })
})
diff --git a/apps/desktop/electron/wslg-launch.ts b/apps/desktop/electron/wslg-launch.ts
index e769344ec43..765dfcc25fe 100644
--- a/apps/desktop/electron/wslg-launch.ts
+++ b/apps/desktop/electron/wslg-launch.ts
@@ -6,7 +6,8 @@ export function wslgLaunchArgs(
argv: readonly string[],
env: NodeJS.ProcessEnv,
platform: NodeJS.Platform,
- electronFlags: readonly string[] = []
+ electronFlags: readonly string[] = [],
+ nvidiaProprietaryDriver = false
): string[] | null {
const displayEnv = { ...env, HERMES_DESKTOP_DISABLE_GPU: undefined }
@@ -35,9 +36,20 @@ export function wslgLaunchArgs(
const hintArg = findOzoneHint(argv) ?? findOzoneHint(electronFlags)
const hint = hintArg ?? env.ELECTRON_OZONE_PLATFORM_HINT
- const backend = hint === 'x11' ? 'x11' : 'wayland'
- return [...argv, `--ozone-platform=${backend}`]
+ return [...argv, `--ozone-platform=${defaultBackend(hint, nvidiaProprietaryDriver)}`]
+}
+
+// An explicit x11/wayland hint always wins. Without one, the NVIDIA proprietary
+// driver stays on XWayland: its GPU process dies on Wayland ozone under the
+// bundled Chromium (615.x, #126013) while x11 launches. Everyone else gets
+// native Wayland (#83578).
+function defaultBackend(hint: string | undefined, nvidiaProprietaryDriver: boolean): 'wayland' | 'x11' {
+ if (hint === 'x11' || hint === 'wayland') {
+ return hint
+ }
+
+ return nvidiaProprietaryDriver ? 'x11' : 'wayland'
}
function hasOzonePlatform(args: readonly string[]): boolean {