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): respect an explicit Ozone display backend
mcmah309f13253f8a0bb
diff --git a/electron/main.ts b/electron/main.tsindex e525aa064..e8e983044 100644--- a/electron/main.ts+++ b/electron/main.ts@@ -71,6 +71,7 @@ import { offersStarPrompt, REPO_URL, storeReviewUrl } from "./star-prompt";import { registerSttIpc, shutdownStt } from "./stt";import { checkLatestRelease } from "./update-checker";import { loadUpdateMode, saveUpdateMode } from "./update-settings";+import { configureWaylandSupport } from "./wayland";import {createCountdownOverlayWindow,createEditorWindow,@@ -92,21 +93,9 @@ if (process.platform === "darwin") {app.commandLine.appendSwitch("disable-features", "MacCatapLoopbackAudioForScreenShare");}-// Wayland support for screen capture and window management on Wayland compositors.+// Keep the session default while allowing explicit Xwayland launches.if (process.platform === "linux") {- const isWayland =- process.env.XDG_SESSION_TYPE === "wayland" || process.env.WAYLAND_DISPLAY !== undefined;- if (isWayland) {- app.commandLine.appendSwitch("ozone-platform", "wayland");- // Enable WebRTCPipeWireCapturer for screen capture on Wayland- app.commandLine.appendSwitch("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".)- app.commandLine.appendSwitch("disable-features", "Vulkan");- }+ configureWaylandSupport(app.commandLine, process.env);}disableHttpCacheForDevServer(app.commandLine, process.env);diff --git a/electron/wayland.test.ts b/electron/wayland.test.tsnew file mode 100644index 000000000..5868f165e--- /dev/null+++ b/electron/wayland.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it, vi } from "vitest";+import { configureWaylandSupport } from "./wayland";++describe("Wayland startup configuration", () => {+ it.each([+ { 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) };+ configureWaylandSupport(commandLine, env);+ expect(commandLine.appendSwitch).toHaveBeenCalledWith("ozone-platform", "wayland");+ expect(commandLine.appendSwitch).toHaveBeenCalledWith("disable-features", "Vulkan");+ });++ it.each(["x11", "wayland", "auto"])("preserves an explicit ozone-platform=%s", (platform) => {+ const switches = new Map([["ozone-platform", platform]]);+ const commandLine = {+ hasSwitch: (name: string) => switches.has(name),+ appendSwitch: vi.fn((name: string, value?: string) => {+ switches.set(name, value ?? "");+ }),+ };+ configureWaylandSupport(commandLine, { XDG_SESSION_TYPE: "wayland" });+ expect(switches.get("ozone-platform")).toBe(platform);+ expect(commandLine.appendSwitch).not.toHaveBeenCalledWith("ozone-platform", expect.anything());+ });++ it.each([{}, { XDG_SESSION_TYPE: "x11" }])("leaves a non-Wayland session alone: %j", (env) => {+ const commandLine = { appendSwitch: vi.fn(), hasSwitch: vi.fn(() => false) };+ configureWaylandSupport(commandLine, env);+ expect(commandLine.appendSwitch).not.toHaveBeenCalled();+ });+});diff --git a/electron/wayland.ts b/electron/wayland.tsnew file mode 100644index 000000000..85e6e235a--- /dev/null+++ b/electron/wayland.ts@@ -0,0 +1,17 @@+type CommandLine = Pick<Electron.CommandLine, "appendSwitch" | "hasSwitch">;++/** Prefer Wayland in a Wayland session, while respecting an explicit backend. */+export function configureWaylandSupport(+ commandLine: CommandLine,+ env: Readonly<Record<string, string | undefined>>,+): void {+ const isWayland = env.XDG_SESSION_TYPE === "wayland" || env.WAYLAND_DISPLAY !== undefined;+ if (!isWayland) return;+ if (!commandLine.hasSwitch("ozone-platform")) {+ commandLine.appendSwitch("ozone-platform", "wayland");+ }+ commandLine.appendSwitch("enable-features", "WaylandWindowDrag,WebRTCPipeWireCapturer");+ // Chromium's Wayland backend cannot import PipeWire DMA-BUF frames through+ // Vulkan. Keep the existing GL/EGL capture path for Wayland sessions.+ commandLine.appendSwitch("disable-features", "Vulkan");+}