fix(snap): default to XWayland, opt back into Wayland with an env var (#3878)

This commit is contained in:
debpalash committed 2026-11-10 05:12:37 +05:30
1 parent fea32bbfad
commit feba49c599
5 files changed
+27 -10

No files matched your search

+1
View File
@@ -0,0 +1 @@
The Snap now starts under XWayland by default instead of crashing on native Wayland; set `VOICESTUDIO_SNAP_OZONE_PLATFORM=wayland` to opt back in. (#3878)
+4
View File
@@ -40,6 +40,10 @@ microphone interface; if VoiceStudio cannot hear you, connect it once:
sudo snap connect voicestudio:audio-record
```
The snap runs through XWayland by default because native Wayland crashed it on
some GNOME releases. To try native Wayland, launch it with
`VOICESTUDIO_SNAP_OZONE_PLATFORM=wayland voicestudio`.
<a id="install-appimage"></a>
Download a package from the
+8 -5
View File
@@ -2,7 +2,11 @@
// Chromium's inner sandbox. Apply this only to the packaged Snap command.sh.
// https://snapcraft.io/docs/reference/interfaces/browser-support-interface/
// electron-builder appends the flag itself, shell-quoted, when allow-sandbox is false.
const invocation = /^exec "\$SNAP\/desktop-init\.sh" "\$SNAP\/desktop-common\.sh" "\$SNAP\/desktop-gnome-specific\.sh" "\$SNAP\/voicestudio"( (?:--no-sandbox|'--no-sandbox'))? "\$@"[\t ]*$/gm;
const invocation = /^exec "\$SNAP\/desktop-init\.sh" "\$SNAP\/desktop-common\.sh" "\$SNAP\/desktop-gnome-specific\.sh" "\$SNAP\/voicestudio"( (?:--no-sandbox|'--no-sandbox'))?( --ozone-platform="\$\{VOICESTUDIO_SNAP_OZONE_PLATFORM:-x11\}")? "\$@"[\t ]*$/gm;
// Native Wayland segfaults in the Snap (GNOME 50, #3878), so the Snap defaults
// to XWayland. VOICESTUDIO_SNAP_OZONE_PLATFORM=wayland (or auto) opts back in.
const OZONE_ARG = ' --ozone-platform="${VOICESTUDIO_SNAP_OZONE_PLATFORM:-x11}"';
function executableLine(command) {
const matches = [...command.matchAll(invocation)];
@@ -14,16 +18,15 @@ function executableLine(command) {
export function verifySnapLauncher(command) {
const match = executableLine(command);
if (!match[1] || command.includes('snapctl is-connected browser-support')) {
if (!match[1] || !match[2] || command.includes('snapctl is-connected browser-support')) {
throw new Error('Snap launcher must use strict confinement without a Chromium sandbox permission gate');
}
}
export function configureSnapLauncher(command) {
const match = executableLine(command);
const configured = match[1]
? command
: command.slice(0, match.index) + match[0].replace(' "$@"', ' --no-sandbox "$@"') + command.slice(match.index + match[0].length);
const line = match[0].replace(' "$@"', `${match[1] ? '' : ' --no-sandbox'}${match[2] ? '' : OZONE_ARG} "$@"`);
const configured = command.slice(0, match.index) + line + command.slice(match.index + match[0].length);
verifySnapLauncher(configured);
return configured;
}
+11 -4
View File
@@ -20,8 +20,13 @@ test('Snap launches without a sandbox permission probe and preserves desktop ini
env: { SNAP: dir, PATH: dir }, encoding: 'utf8',
});
assert.equal(result.status, 0, result.stderr);
assert.equal(result.stdout, '--no-sandbox\na b\n--example\n');
assert.equal(result.stdout, '--no-sandbox\n--ozone-platform=x11\na b\n--example\n');
assert.equal(result.stderr, '');
// Opt back into native Wayland (#3878).
const optIn = spawnSync('/bin/bash', ['-c', configureSnapLauncher(command), 'launcher'], {
env: { SNAP: dir, PATH: dir, VOICESTUDIO_SNAP_OZONE_PLATFORM: 'wayland' }, encoding: 'utf8',
});
assert.equal(optIn.stdout, '--no-sandbox\n--ozone-platform=wayland\n');
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -35,8 +40,10 @@ test('accepts the launcher electron-builder generates for allow-sandbox: false',
executableName: 'voicestudio',
extraAppArgs: ['--no-sandbox'],
});
assert.doesNotThrow(() => verifySnapLauncher(generated));
assert.equal(configureSnapLauncher(generated), generated);
assert.throws(() => verifySnapLauncher(generated), /launcher/);
const configured = configureSnapLauncher(generated);
assert.match(configured, /--no-sandbox --ozone-platform="\$\{VOICESTUDIO_SNAP_OZONE_PLATFORM:-x11\}" "\$@"/);
assert.equal(configureSnapLauncher(configured), configured);
});
test('launcher configuration is idempotent', () => {
@@ -59,7 +66,7 @@ test('comments cannot satisfy or bypass validation of the executed command', ()
const commented = [shebang, comment.trimEnd(), ...lines].join('\n');
assert.throws(() => verifySnapLauncher(commented), /launcher/);
const configured = configureSnapLauncher(commented);
assert.match(configured, /^exec .*"\$SNAP\/voicestudio" --no-sandbox "\$@"$/m);
assert.match(configured, /^exec .*"\$SNAP\/voicestudio" --no-sandbox --ozone-platform=\S+ "\$@"$/m);
assert.equal(configureSnapLauncher(configured), configured);
assert.throws(() => verifySnapLauncher(`#!/bin/sh\n${comment}`), /launcher/);
});
+3 -1
View File
@@ -33,7 +33,9 @@ plugs:
apps:
voicestudio:
command: opt/VoiceStudio/voicestudio-electron --no-sandbox
# XWayland by default: native Wayland segfaults (#3878). A later
# --ozone-platform=wayland on the command line wins.
command: opt/VoiceStudio/voicestudio-electron --no-sandbox --ozone-platform=x11
desktop: usr/share/applications/voicestudio.desktop
extensions: [gnome]
environment: