Skip to content

Commit 55efccf

Browse files
committed
refactor(gpuFallback): Enhance Wayland handling and logging for X11 fallback
- Introduced a check for Wayland sessions in handleLinuxDisplayServer to default to XWayland for stability, addressing potential GPU issues on virtual machines. - Updated logging messages to clarify the use of XWayland when a Wayland session is detected, improving user guidance on display server settings. - Removed redundant Wayland session checks from performElectronStartup, streamlining the GPU fallback logic.
1 parent 6afd8e1 commit 55efccf

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/app/main/app.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,7 @@ export const performElectronStartup = (): void => {
215215
// Read GPU fallback mode (may have been set by previous GPU crash or user setting)
216216
const gpuFallbackMode = readGpuFallbackMode();
217217

218-
// Detect Wayland session
219-
const sessionType = process.env.XDG_SESSION_TYPE;
220-
const isWaylandSession = sessionType === 'wayland';
221-
222-
// Apply display server mode based on settings and environment
218+
// Apply display server mode based on settings
223219
if (gpuFallbackMode === 'x11') {
224220
console.log('Display server mode: forcing X11');
225221
app.commandLine.appendSwitch('ozone-platform', 'x11');
@@ -230,14 +226,9 @@ export const performElectronStartup = (): void => {
230226
console.log('Display server mode: GPU disabled');
231227
app.disableHardwareAcceleration();
232228
app.commandLine.appendSwitch('disable-gpu');
233-
} else if (gpuFallbackMode === 'none' && isWaylandSession) {
234-
// On Wayland sessions, default to X11 to avoid GPU initialization issues
235-
// Users can set gpuFallbackMode to 'wayland' in settings to use native Wayland
236-
console.log(
237-
'Wayland session detected, using X11 fallback for stability (XDG_SESSION_TYPE=wayland)'
238-
);
239-
app.commandLine.appendSwitch('ozone-platform', 'x11');
240229
}
230+
// Note: 'none' mode on Wayland is handled by handleLinuxDisplayServer() in main.ts
231+
// which relaunches with --ozone-platform=x11 before Electron initializes
241232
}
242233
};
243234

src/main.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,26 @@ const handleLinuxDisplayServer = (): void => {
7979
// Determine if we need to relaunch with X11 flag
8080
let needsX11 = false;
8181

82+
const isWaylandSession = process.env.XDG_SESSION_TYPE === 'wayland';
83+
8284
if (gpuFallbackMode === 'x11') {
8385
needsX11 = true;
8486
} else if (gpuFallbackMode === 'wayland') {
8587
// User explicitly wants native Wayland, don't add X11 flag
8688
needsX11 = false;
89+
} else if (gpuFallbackMode === 'none' && isWaylandSession) {
90+
// Default to XWayland on Wayland sessions for stability.
91+
// Native Wayland can hang on VMs/systems with GPU issues.
92+
// Users can opt-in to native Wayland via Settings > General > Display Server Mode.
93+
// XWayland remains available even on Wayland-only distros (Fedora 43+).
94+
needsX11 = true;
8795
}
88-
// If gpuFallbackMode is 'none', try native mode and let crash handler decide
8996

9097
if (needsX11) {
91-
console.log('GPU fallback mode set to X11, relaunching with X11');
98+
console.log(
99+
'Wayland detected, using XWayland for stability. To use native Wayland, change Display Server Mode in Settings.',
100+
{ gpuFallbackMode, isWaylandSession }
101+
);
92102
relaunchApp('--ozone-platform=x11');
93103
}
94104
};

0 commit comments

Comments
 (0)