Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ca15ab7
fix(desktop): disable GPU acceleration on NVIDIA Wayland
SaahiilM Nov 4, 2026
ef0661d
fix(desktop): persist disableGpuAcceleration opt-out in settings model
SaahiilM Nov 4, 2026
6ecee77
fix(desktop): honor explicit ozone-platform in NVIDIA Wayland GPU fal…
SaahiilM Nov 4, 2026
817fad6
fix(desktop): detect Wayland via WAYLAND_DISPLAY and live socket
SaahiilM Nov 4, 2026
8f79f40
test(desktop): cover pre-ready disable-gpu wiring end to end
SaahiilM Nov 4, 2026
74d0087
fix(desktop): honor the ozone platform hint in the NVIDIA Wayland guard
SaahiilM Nov 5, 2026
14ce315
fix(desktop): treat --ozone-platform=auto as auto-detected
SaahiilM Nov 5, 2026
e772b8d
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
45485ac
Merge branch 'pingdotgg:main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
7bacf60
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
10b9d16
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
1ff4a66
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
4a5e408
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 5, 2026
043a424
Merge remote-tracking branch 'github/main' into fix/nvidia-wayland-gp…
maria-rcks Nov 5, 2026
979bdad
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 6, 2026
6c2120e
fix(desktop): use the resolved Ozone backend for the GPU fallback
SaahiilM Nov 6, 2026
eab8fb1
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 9, 2026
9782817
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 9, 2026
911a029
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 10, 2026
0986df9
Merge branch 'main' into fix/nvidia-wayland-gpu-fallback
SaahiilM Nov 13, 2026
9c83acc
merge: update nvidia wayland fallback with main
maria-rcks Nov 15, 2026
855402e
fix(desktop): preserve password store with malformed gpu preference
maria-rcks Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 127 additions & 12 deletions apps/desktop/src/app/DesktopEarlyElectronStartup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ import {
restoreEarlyLinuxDeviceScaleFactor,
resolveEarlyLinuxPasswordStorePreference,
resolveLinuxDisableFeaturesSwitch,
shouldDisableGpuOnNvidiaWayland,
} from "./DesktopEarlyElectronStartup.ts";

describe("DesktopEarlyElectronStartup", () => {
const joinPath = NodePath.posix.join;

it("reads the persisted linux password-store preference before Electron is ready", () => {
const preference = resolveEarlyLinuxPasswordStorePreference({
env: { T3CODE_HOME: "/home/user/.t3-test" },
homeDirectory: "/home/user",
joinPath,
readFileString: (path) => {
assert.equal(path, "/home/user/.t3-test/userdata/desktop-settings.json");
return JSON.stringify({ linuxPasswordStore: "kwallet6" });
},
});
it.each([undefined, false, true, null, "false"])(
"reads the persisted linux password-store preference with GPU setting %j",
(disableGpuAcceleration) => {
const preference = resolveEarlyLinuxPasswordStorePreference({
env: { T3CODE_HOME: "/home/user/.t3-test" },
homeDirectory: "/home/user",
joinPath,
readFileString: (path) => {
assert.equal(path, "/home/user/.t3-test/userdata/desktop-settings.json");
return JSON.stringify({ linuxPasswordStore: "kwallet6", disableGpuAcceleration });
},
});

assert.equal(preference, "kwallet6");
});
assert.equal(preference, "kwallet6");
},
);

it("accepts JSONC in the early desktop settings file", () => {
const preference = resolveEarlyLinuxPasswordStorePreference({
Expand Down Expand Up @@ -196,4 +200,115 @@ describe("Linux device scale persistence failures", () => {
assert.deepEqual(reads, []);
assert.deepEqual(applied, []);
});

describe("shouldDisableGpuOnNvidiaWayland", () => {
const base = {
ozonePlatform: "wayland",
homeDirectory: "/home/user",
joinPath: NodePath.posix.join,
existsSync: (path: string) => path === "/dev/nvidiactl",
readFileString: () => "{}",
hasSwitch: () => false,
};

it("is true on NVIDIA Wayland with no explicit GPU switch", () => {
assert.isTrue(
shouldDisableGpuOnNvidiaWayland({ ...base, env: { XDG_SESSION_TYPE: "wayland" } }),
);
});

it("is false on X11", () => {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "x11" },
ozonePlatform: "x11",
}),
);
});

it("respects an explicit --ozone-platform=x11 override in a Wayland session", () => {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
ozonePlatform: "x11",
}),
);
});

it("respects an explicit --ozone-platform=wayland when the session variable is absent", () => {
assert.isTrue(
shouldDisableGpuOnNvidiaWayland({ ...base, env: {}, ozonePlatform: "wayland" }),
);
});

it.each([null, "auto", "headless"])(
"does not infer Wayland from the environment for unresolved platform %s",
(ozonePlatform) => {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland", WAYLAND_DISPLAY: "wayland-0" },
ozonePlatform,
}),
);
},
);

it("uses Electron's resolved Wayland backend without session or display variables", () => {
assert.isTrue(shouldDisableGpuOnNvidiaWayland({ ...base, env: {} }));
});

it("is false without NVIDIA devices", () => {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
existsSync: () => false,
}),
);
});

it("is false when --disable-gpu or --enable-gpu was passed explicitly", () => {
for (const name of ["disable-gpu", "enable-gpu"]) {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
hasSwitch: (switchName) => switchName === name,
}),
);
}
});

it("is false when the user opts out via disableGpuAcceleration=false", () => {
assert.isFalse(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
readFileString: () => JSON.stringify({ disableGpuAcceleration: false }),
}),
);
});

it("is true when the setting is explicit true or missing file", () => {
assert.isTrue(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
readFileString: () => JSON.stringify({ disableGpuAcceleration: true }),
}),
);
assert.isTrue(
shouldDisableGpuOnNvidiaWayland({
...base,
env: { XDG_SESSION_TYPE: "wayland" },
readFileString: () => {
throw new Error("missing");
},
}),
);
});
});
});
28 changes: 28 additions & 0 deletions apps/desktop/src/app/DesktopEarlyElectronStartup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const trimNonEmpty = (value: string | undefined): string | null => {

const EarlyDesktopSettingsJson = fromLenientJson(
Schema.Struct({
disableGpuAcceleration: Schema.optionalKey(Schema.Unknown),
linuxPasswordStore: Schema.optionalKey(Schema.Unknown),
}),
);
Expand Down Expand Up @@ -80,6 +81,33 @@ export function resolveEarlyLinuxPasswordStorePreference(
}
}

const isNvidiaPresent = (existsSync: (path: string) => boolean): boolean =>
existsSync("/dev/nvidiactl") || existsSync("/dev/nvidia0");

export function shouldDisableGpuOnNvidiaWayland(input: {
readonly env: NodeJS.ProcessEnv;
readonly ozonePlatform: string | null;
readonly homeDirectory: string;
readonly joinPath: JoinPath;
readonly existsSync: (path: string) => boolean;
readonly readFileString: (path: string) => string;
readonly hasSwitch: (name: string) => boolean;
}): boolean {
// Electron resolves --ozone-platform before loading the main module, including auto selection.
if (input.ozonePlatform !== "wayland") return false;
if (input.hasSwitch("disable-gpu") || input.hasSwitch("enable-gpu")) return false;
const settingsPath = resolveEarlyDesktopSettingsPath({
env: input.env,
homeDirectory: input.homeDirectory,
joinPath: input.joinPath,
});
try {
const parsed = decodeEarlyDesktopSettingsJson(input.readFileString(settingsPath));
if (parsed.disableGpuAcceleration === false) return false;
Comment thread
SaahiilM marked this conversation as resolved.
Resolved
} catch {}
return isNvidiaPresent(input.existsSync);
}

const WAYLAND_COLOR_MANAGER_FEATURE = "WaylandWpColorManagerV1";

const featureListNames = (value: string | null): ReadonlyArray<string> =>
Expand Down
75 changes: 75 additions & 0 deletions apps/desktop/src/app/DesktopPreReadyPlatform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
copyFileSyncMock,
execFileSyncMock,
readFileSyncMock,
existsSyncMock,
symlinkSyncMock,
} = vi.hoisted(() => ({
appendSwitchMock: vi.fn(),
Expand All @@ -28,6 +29,7 @@ const {
copyFileSyncMock: vi.fn(),
execFileSyncMock: vi.fn(),
readFileSyncMock: vi.fn(),
existsSyncMock: vi.fn(),
symlinkSyncMock: vi.fn(),
}));

Expand All @@ -53,6 +55,7 @@ vi.mock("node:fs", () => ({
mkdirSync: mkdirSyncMock,
writeFileSync: writeFileSyncMock,
copyFileSync: copyFileSyncMock,
existsSync: existsSyncMock,
symlinkSync: symlinkSyncMock,
}));

Expand All @@ -75,9 +78,81 @@ describe("DesktopPreReadyPlatform", () => {
copyFileSyncMock.mockReset();
execFileSyncMock.mockReset();
readFileSyncMock.mockReset().mockReturnValue("{}");
existsSyncMock.mockReset().mockReturnValue(false);
symlinkSyncMock.mockReset();
});

it.effect.each([
{ settings: "{}", label: "disables GPU on NVIDIA Wayland", expected: true },
{
settings: JSON.stringify({ disableGpuAcceleration: false }),
label: "honors disableGpuAcceleration:false opt-out",
expected: false,
},
])("pre-ready GPU switch: $label", ({ settings, expected }) => {
vi.stubEnv("T3CODE_HOME", "/isolated");
vi.stubEnv("VITE_DEV_SERVER_URL", "");
vi.stubEnv("XDG_SESSION_TYPE", "wayland");
vi.stubEnv("XDG_DATA_HOME", "/xdg");
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
existsSyncMock.mockReturnValue(true);
readFileSyncMock.mockReturnValue(settings);
getSwitchValueMock.mockImplementation((name: string) =>
name === "ozone-platform" ? "wayland" : "",
);
hasSwitchMock.mockImplementation((name: string) => name === "ozone-platform");

return Effect.scoped(
Effect.gen(function* () {
yield* Layer.build(
DesktopPreReadyPlatform.layer.pipe(
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
),
);
const appended = appendSwitchMock.mock.calls.some(([name]) => name === "disable-gpu");
assert.equal(appended, expected);
}),
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
});

it.effect.each([
{ session: "wayland", platform: "wayland", hint: "x11", expected: true },
{ session: "x11", platform: "x11", hint: "wayland", expected: false },
])(
"pre-ready GPU switch: ignores stale hint=$hint on $session",
({ session, platform, hint, expected }) => {
vi.stubEnv("T3CODE_HOME", "/isolated");
vi.stubEnv("VITE_DEV_SERVER_URL", "");
vi.stubEnv("XDG_SESSION_TYPE", session);
vi.stubEnv("XDG_DATA_HOME", "/xdg");
vi.stubEnv("APPIMAGE", "/Applications/current.AppImage");
existsSyncMock.mockReturnValue(true);
readFileSyncMock.mockReturnValue("{}");
getSwitchValueMock.mockImplementation((name: string) =>
name === "ozone-platform" ? platform : name === "ozone-platform-hint" ? hint : "",
);
hasSwitchMock.mockImplementation(
(name: string) => name === "ozone-platform" || name === "ozone-platform-hint",
);

return Effect.scoped(
Effect.gen(function* () {
yield* Layer.build(
DesktopPreReadyPlatform.layer.pipe(
Layer.provide(Layer.succeed(HostProcess.Platform, "linux")),
),
);
const appended = appendSwitchMock.mock.calls.some(([name]) => name === "disable-gpu");
assert.equal(appended, expected);
assert.isFalse(
getSwitchValueMock.mock.calls.some(([name]) => name === "ozone-platform-hint"),
);
assert.isFalse(hasSwitchMock.mock.calls.some(([name]) => name === "ozone-platform-hint"));
}),
).pipe(Effect.ensuring(Effect.sync(() => vi.unstubAllEnvs())));
},
);

it.effect("persists Linux scaling synchronously across relaunches and settings rewrites", () => {
vi.stubEnv("T3CODE_HOME", "/isolated");
vi.stubEnv("VITE_DEV_SERVER_URL", "");
Expand Down
13 changes: 13 additions & 0 deletions apps/desktop/src/app/DesktopPreReadyPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,19 @@ export const make = Effect.gen(function* () {
} catch {}
// Chromium caches portal identity; set it before any asynchronous initialization.
Electron.app.setDesktopName(linux.linuxDesktopEntryName);
if (
DesktopEarlyElectronStartup.shouldDisableGpuOnNvidiaWayland({
env: process.env,
ozonePlatform: readCommandLineSwitchValue(Electron.app.commandLine, "ozone-platform"),
homeDirectory,
joinPath: NodePath.posix.join,
existsSync: (path) => NodeFS.existsSync(path),
readFileString: (path) => NodeFS.readFileSync(path, "utf8"),
hasSwitch: (name) => Electron.app.commandLine.hasSwitch(name),
})
) {
Electron.app.commandLine.appendSwitch("disable-gpu");
}
if (linux.passwordStore !== null && linuxPasswordStoreCommandLine === null) {
Electron.app.commandLine.appendSwitch("password-store", linux.passwordStore);
}
Expand Down
28 changes: 28 additions & 0 deletions apps/desktop/src/settings/DesktopAppSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@ describe("DesktopSettings", () => {
),
);

it.effect("preserves disableGpuAcceleration:false across unrelated settings writes", () =>
withSettings(
Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
const settings = yield* DesktopAppSettings.DesktopAppSettings;
yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
yield* fileSystem.writeFileString(
environment.desktopSettingsPath,
`${JSON.stringify({ disableGpuAcceleration: false })}\n`,
);
assert.equal((yield* settings.load).disableGpuAcceleration, false);
yield* settings.setMainWindowBounds({ x: 10, y: 20, width: 900, height: 600 }, true);
yield* settings.setServerExposureMode("network-accessible");
const reloaded = yield* settings.load;
assert.equal(reloaded.disableGpuAcceleration, false);
assert.equal(reloaded.serverExposureMode, "network-accessible");
const raw = yield* fileSystem.readFileString(environment.desktopSettingsPath);
assert.include(raw, `"disableGpuAcceleration":false`);
yield* settings.setWslBackendEnabled(true);
assert.equal((yield* settings.load).disableGpuAcceleration, false);
}),
),
);

it.effect("falls back to defaults when the settings file is malformed", () =>
withSettings(
Effect.gen(function* () {
Expand Down Expand Up @@ -223,6 +248,7 @@ describe("DesktopSettings", () => {
);

assert.deepEqual(yield* settings.load, {
disableGpuAcceleration: undefined,
linuxPasswordStore: "auto",
localEnvironmentEnabled: true,
mainWindowBounds: { x: 120, y: 80, width: 1280, height: 900 },
Expand Down Expand Up @@ -376,6 +402,7 @@ describe("DesktopSettings", () => {
});

assert.deepEqual(yield* settings.load, {
disableGpuAcceleration: undefined,
linuxPasswordStore: "auto",
localEnvironmentEnabled: true,
mainWindowBounds: null,
Expand Down Expand Up @@ -405,6 +432,7 @@ describe("DesktopSettings", () => {
});

assert.deepEqual(yield* settings.load, {
disableGpuAcceleration: undefined,
linuxPasswordStore: "auto",
localEnvironmentEnabled: true,
mainWindowBounds: null,
Expand Down
Loading
Loading