Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(linux): keep the user's --enable/--disable-features on Wayland
EtienneLescotbfd5bc329245
diff --git a/electron/wayland.test.ts b/electron/wayland.test.tsindex 01624872d..56c2c0b08 100644--- a/electron/wayland.test.ts+++ b/electron/wayland.test.ts@@ -6,7 +6,11 @@ describe("Wayland startup configuration", () => {{ XDG_SESSION_TYPE: "wayland" },{ WAYLAND_DISPLAY: "wayland-1" },])("defaults to Wayland when the environment advertises a Wayland session: %j", (env) => {- const commandLine = { appendSwitch: vi.fn(), hasSwitch: vi.fn(() => false) };+ const commandLine = {+ appendSwitch: vi.fn(),+ hasSwitch: vi.fn(() => false),+ getSwitchValue: vi.fn(() => ""),+ };configureWaylandSupport(commandLine, env);expect(commandLine.appendSwitch).toHaveBeenCalledWith("ozone-platform", "wayland");expect(commandLine.appendSwitch).toHaveBeenCalledWith("disable-features", "Vulkan");@@ -16,6 +20,7 @@ describe("Wayland startup configuration", () => {const switches = new Map([["ozone-platform", platform]]);const commandLine = {hasSwitch: (name: string) => switches.has(name),+ getSwitchValue: (name: string) => switches.get(name) ?? "",appendSwitch: vi.fn((name: string, value?: string) => {switches.set(name, value ?? "");}),@@ -30,8 +35,30 @@ describe("Wayland startup configuration", () => {);});+ it("keeps the features passed on the command line (#1452)", () => {+ // Chromium keeps only the last value of a repeated switch.+ const switches = new Map([+ ["enable-features", "WebRtcPipeWireCamera"],+ ["disable-features", "WebRtcPipeWireCamera"],+ ]);+ const commandLine = {+ hasSwitch: (name: string) => switches.has(name),+ getSwitchValue: (name: string) => switches.get(name) ?? "",+ appendSwitch: (name: string, value?: string) => switches.set(name, value ?? ""),+ };+ configureWaylandSupport(commandLine, { XDG_SESSION_TYPE: "wayland" });+ expect(switches.get("enable-features")).toBe(+ "WebRtcPipeWireCamera,WaylandWindowDrag,WebRTCPipeWireCapturer",+ );+ expect(switches.get("disable-features")).toBe("WebRtcPipeWireCamera,Vulkan");+ });+it.each([{}, { XDG_SESSION_TYPE: "x11" }])("leaves a non-Wayland session alone: %j", (env) => {- const commandLine = { appendSwitch: vi.fn(), hasSwitch: vi.fn(() => false) };+ const commandLine = {+ appendSwitch: vi.fn(),+ hasSwitch: vi.fn(() => false),+ getSwitchValue: vi.fn(() => ""),+ };configureWaylandSupport(commandLine, env);expect(commandLine.appendSwitch).not.toHaveBeenCalled();});diff --git a/electron/wayland.ts b/electron/wayland.tsindex c89e70da7..abe25e030 100644--- a/electron/wayland.ts+++ b/electron/wayland.ts@@ -1,4 +1,4 @@-type CommandLine = Pick<Electron.CommandLine, "appendSwitch" | "hasSwitch">;+type CommandLine = Pick<Electron.CommandLine, "appendSwitch" | "hasSwitch" | "getSwitchValue">;type Env = Readonly<Record<string, string | undefined>>;export function isWaylandSession(env: Env): boolean {@@ -29,11 +29,21 @@ export function configureWaylandSupport(commandLine: CommandLine, env: Env): voicommandLine.appendSwitch("ozone-platform", "wayland");}// Enable WebRTCPipeWireCapturer for screen capture on Wayland- commandLine.appendSwitch("enable-features", "WaylandWindowDrag,WebRTCPipeWireCapturer");+ appendFeatures(commandLine, "enable-features", "WaylandWindowDrag,WebRTCPipeWireCapturer");// Chromium's Wayland Ozone backend can't use Vulkan. When it tries, the WebRTC// PipeWire capturer fails to import DMA-BUF frames into EGL (EGL_BAD_MATCH), the// stream renegotiates, and screen recording yields no usable frames. Force the// GL/EGL path so DMA-BUF import works. (Chromium itself logs this suggestion:// "'--ozone-platform=wayland' is not compatible with Vulkan ... disabling Vulkan".)- commandLine.appendSwitch("disable-features", "Vulkan");+ appendFeatures(commandLine, "disable-features", "Vulkan");+}++/**+ * Add to a feature list instead of replacing it. Chromium keeps only the last value of a+ * repeated switch, so a bare appendSwitch silently dropped whatever the user passed as+ * `--enable-features=` or `--disable-features=` on the command line.+ */+function appendFeatures(commandLine: CommandLine, name: string, features: string): void {+ const existing = commandLine.getSwitchValue(name);+ commandLine.appendSwitch(name, existing ? `${existing},${features}` : features);}