Skip to content

Commit b148009

Browse files
committed
fix: address review feedback
- Add tests for ELECTRON_OZONE_PLATFORM_HINT env var override - Fix Snap docs: Auto-detect → Force X11 (allowNativeWayland: false) - Fix date: January 2025 → January 2026 - Add 'The Solution That Actually Worked' section to postmortem
1 parent e4881a3 commit b148009

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

docs/linux-display-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If any check fails, the wrapper forces X11 mode via `--ozone-platform=x11`.
2929
|--------------|---------------|-------|
3030
| **deb/rpm** | Auto-detect via wrapper | Native Wayland when available, safe X11 fallback |
3131
| **AppImage** | Auto-detect via wrapper | Native Wayland when available, safe X11 fallback |
32-
| **Snap** | Auto-detect | Uses Snap's display server access |
32+
| **Snap** | Force X11 | Wayland disabled via `allowNativeWayland: false` |
3333

3434
## Why a Wrapper Script?
3535

docs/linux-wayland-bug-postmortem.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Issue Reference
44
- **GitHub Issue**: [#3154](https://github.com/RocketChat/Rocket.Chat.Electron/issues/3154)
55
- **Related PR**: [#3171](https://github.com/RocketChat/Rocket.Chat.Electron/pull/3171)
6-
- **Date**: January 2025
6+
- **Date**: January 2026
77
- **Severity**: Critical (application crash/segfault)
88

99
## Executive Summary
@@ -12,6 +12,25 @@ Rocket.Chat Desktop crashes with SEGFAULT when environment variables suggest a W
1212

1313
---
1414

15+
## The Solution That Actually Worked
16+
17+
### Problem
18+
Rocket.Chat Desktop crashes with SEGFAULT when environment variables suggest a Wayland session but no valid Wayland compositor is available, because Chromium's display platform initialization occurs before any Electron JavaScript code executes.
19+
20+
### Solution
21+
Implement a shell wrapper script (`build/linux/wrapper.sh`) that detects the display server situation before the binary starts. The wrapper checks XDG_SESSION_TYPE, WAYLAND_DISPLAY, and socket existence, then passes `--ozone-platform=x11` when needed.
22+
23+
### Result
24+
All test scenarios pass on Ubuntu 22.04 and Fedora 42 (physical and VM). The wrapper correctly:
25+
- Allows native Wayland when valid socket exists
26+
- Forces X11 in all failure scenarios (fake socket, missing display, X11 session, etc.)
27+
- Prevents all previously occurring segfaults
28+
29+
### PR
30+
[#3171](https://github.com/RocketChat/Rocket.Chat.Electron/pull/3171)
31+
32+
---
33+
1534
## Problem Description
1635

1736
### Symptoms

src/app/main/app.main.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,37 @@ describe('performElectronStartup - Platform Detection', () => {
137137
expect(waylandLogs).toHaveLength(0);
138138
expect(x11Logs).toHaveLength(0);
139139
});
140+
141+
it('should respect ELECTRON_OZONE_PLATFORM_HINT environment variable', () => {
142+
process.env.ELECTRON_OZONE_PLATFORM_HINT = 'x11';
143+
process.env.XDG_SESSION_TYPE = 'wayland';
144+
process.env.WAYLAND_DISPLAY = 'wayland-0';
145+
146+
performElectronStartup();
147+
148+
const ozonePlatformCalls = appendSwitchMock.mock.calls.filter(
149+
(call) => call[0] === 'ozone-platform'
150+
);
151+
expect(ozonePlatformCalls).toHaveLength(0);
152+
});
153+
154+
it('should ignore empty ELECTRON_OZONE_PLATFORM_HINT', () => {
155+
process.env.ELECTRON_OZONE_PLATFORM_HINT = '';
156+
process.env.XDG_SESSION_TYPE = 'x11';
157+
158+
performElectronStartup();
159+
160+
expect(appendSwitchMock).toHaveBeenCalledWith('ozone-platform', 'x11');
161+
});
162+
163+
it('should ignore whitespace-only ELECTRON_OZONE_PLATFORM_HINT', () => {
164+
process.env.ELECTRON_OZONE_PLATFORM_HINT = ' ';
165+
process.env.XDG_SESSION_TYPE = 'x11';
166+
167+
performElectronStartup();
168+
169+
expect(appendSwitchMock).toHaveBeenCalledWith('ozone-platform', 'x11');
170+
});
140171
});
141172

142173
describe('Wayland Detection', () => {

0 commit comments

Comments
 (0)