From 6ddbdd3f986fa5c0fd0e06ba6ecf50751e868856 Mon Sep 17 00:00:00 2001 From: EtienneLescot Date: Sat, 21 Nov 2026 21:53:52 +0100 Subject: [PATCH] fix(recording): record the only X11 display when Electron's display_id matches no screen Electron derives desktopCapturer's X11 display_id with its own copy of Chromium's EDID logic, which falls back to the output index when the RandR output id is above 0xff (NVIDIA). That id matches no screen.getAllDisplays() id, so Entire screen failed with "The selected X11 display is no longer available". With a single display, the picked screen can only be that one. Refs #1629 --- electron/recording/linuxCaptureBackend.test.ts | 12 ++++++++++++ electron/recording/linuxCaptureBackend.ts | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/electron/recording/linuxCaptureBackend.test.ts b/electron/recording/linuxCaptureBackend.test.ts index 465fa5e71b..221d24eecf 100644 --- a/electron/recording/linuxCaptureBackend.test.ts +++ b/electron/recording/linuxCaptureBackend.test.ts @@ -92,6 +92,18 @@ describe("X11 source resolution", () => { y: 0, }); }); + it("records the only display when Electron's X11 display_id matches no screen id (#1629)", () => { + const laptop = [ + { id: 2_147_483_648, bounds: { x: 0, y: 0, width: 1920, height: 1080 }, scaleFactor: 1 }, + ]; + expect(resolveX11CaptureSource({ id: "screen:383:0", display_id: "2" }, laptop)).toEqual({ + kind: "display", + x: 0, + y: 0, + width: 1920, + height: 1080, + }); + }); it("rejects stale, missing and malformed sources instead of recording something else", () => { expect(() => resolveX11CaptureSource(null, displays)).toThrow(); expect(() => diff --git a/electron/recording/linuxCaptureBackend.ts b/electron/recording/linuxCaptureBackend.ts index ce0b91c39a..aee71dd6d1 100644 --- a/electron/recording/linuxCaptureBackend.ts +++ b/electron/recording/linuxCaptureBackend.ts @@ -92,7 +92,14 @@ export function resolveX11CaptureSource( return { kind: "window", windowId }; } if (!source.id.startsWith("screen:")) throw new Error("Unsupported X11 recording source."); - const display = displays.find((candidate) => String(candidate.id) === source.display_id); + // Electron derives desktopCapturer's X11 display_id with its own copy of Chromium's + // EDID logic, which falls back to the output index for an output id above 0xff + // (NVIDIA): it then matches no `screen` id (#1629). A single display is still the + // one picked. ponytail: several displays still need the id to match; resolving the + // RandR monitor atom of `screen::0` in the helper would cover them. + const display = + displays.find((candidate) => String(candidate.id) === source.display_id) ?? + (displays.length === 1 ? displays[0] : undefined); if (!display) throw new Error("The selected X11 display is no longer available."); const { bounds, scaleFactor } = display; if (displays.some((candidate) => candidate.scaleFactor !== scaleFactor)) {