Skip to content

fix(linux): keep main and GPU processes on X11 when launched under Wa… - #133

Open
vodinhht20 wants to merge 1 commit into
darrenprx:mainfrom
vodinhht20:fix/linux-ubuntu-wayland-x11
Open

vodinhht20 wants to merge 1 commit into
darrenprx:mainfrom
vodinhht20:fix/linux-ubuntu-wayland-x11

Conversation

@vodinhht20

@vodinhht20 vodinhht20 commented Oct 27, 2026 •

Copy link
Copy Markdown

…yland

In Electron 44+, Chromium chooses the Ozone platform in C++ before the main script runs. When WAYLAND_DISPLAY is set and --ozone-platform=x11 is not on argv, the main process starts on Wayland while the GPU process receives the X11 switch from app.commandLine.appendSwitch and crashes on Wayland surface IDs, leaving the settings window and overlays unrendered on Ubuntu desktops.

Pass --ozone-platform=x11 and --force-device-scale-factor=1 in the Linux desktop entry executableArgs, and re-exec once with those flags when a direct Linux launch under WAYLAND_DISPLAY omitted them. Also allow opting into XWayland testing in hook-helper with LOLPING_ALLOW_XWAYLAND=1.

Fixes #

What and why

How I tested it

Ran by hand on:

  • Windows 11
  • macOS (Apple Silicon)

Checklist

  • npm run typecheck, npm run test:helper and npm test pass
  • New logic has tests; a bug fix has a test that fails without it, or I explained why it can't
  • User-facing text is in both English and Chinese (src/shared/i18n.ts, both READMEs)
  • docs/design.md is updated if the behaviour it describes changed
  • Screenshot attached if something visible changed
  • If I used an AI tool, it had AGENTS.md in context and I read the whole diff. Tool:

…yland

In Electron 44+, Chromium chooses the Ozone platform in C++ before the
main script runs. When WAYLAND_DISPLAY is set and --ozone-platform=x11
is not on argv, the main process starts on Wayland while the GPU
process receives the X11 switch from app.commandLine.appendSwitch and
crashes on Wayland surface IDs, leaving the settings window and
overlays unrendered on Ubuntu desktops.

Pass --ozone-platform=x11 and --force-device-scale-factor=1 in the
Linux desktop entry executableArgs, and re-exec once with those flags
when a direct Linux launch under WAYLAND_DISPLAY omitted them. Also
allow opting into XWayland testing in hook-helper with
LOLPING_ALLOW_XWAYLAND=1.
@truongbo17

Copy link
Copy Markdown

Code review — Request changes before merge

The proposed Ozone startup fix makes sense, but I found two issues that should be addressed before merging.

P1 — AppImage relaunch path (src/main/index.ts:90)

On AppImage, process.execPath points to an executable inside a temporary mounted filesystem. The original process.env.APPIMAGE path is already used by linuxAutostart.ts.

Spawning from process.execPath and immediately exiting the original process risks losing access to the mount during startup.

Suggested fix: Use process.env.APPIMAGE ?? process.execPath, preferably with app.relaunch({ execPath, args }) to sequence the restart after exit. Add a direct AppImage launch regression test.

P2 — Conflicting Ozone flags (src/main/linuxX11Args.ts:15)

The current condition skips relaunch whenever any --ozone-platform flag exists.

For example, with WAYLAND_DISPLAY=wayland-0 and --ozone-platform=wayland, relaunch is skipped, while index.ts still appends ozone-platform=x11.

This may reproduce the original main/GPU backend mismatch.

Suggested fix: Handle non-X11 values explicitly and add regression tests covering wayland, auto, and split-form arguments.

Verification required

  • GitHub Actions CI is action_required; no jobs have executed.
  • Run npm run typecheck, npm run test:helper, and npm test.
  • Validate DEB desktop launch and direct AppImage launch on Ubuntu 24.04.
  • Verify Settings, overlays, and input helper behavior on X11/XWayland.
  • Update docs/design.md to reflect the test-only XWayland override.

Verdict: Request changes. Do not merge until the launch paths are validated and CI passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants