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(capture-linux): keep the liveness check ahead of the capture latch
askalf77ede960b866
diff --git a/electron/native-bridge/capture/linuxNativeCaptureSession.test.ts b/electron/native-bridge/capture/linuxNativeCaptureSession.test.tsindex 97896479c..7bdebb2ae 100644--- a/electron/native-bridge/capture/linuxNativeCaptureSession.test.ts+++ b/electron/native-bridge/capture/linuxNativeCaptureSession.test.ts@@ -371,6 +371,31 @@ describe("LinuxNativeCaptureSession", () => {helper.emit("exit", 1, null);await flushStdout();+ await expect(session.waitUntilCapturing()).rejects.toThrow();+ });+ /**+ * The latch is a shortcut past the WAIT, never past the liveness check. A+ * helper that died after its first frame has stopped recording, so a caller+ * arriving late must still be told — answering "capturing" from a latch set+ * before the crash would report a recording that is no longer running.+ */+ it("rejects the capture wait when the helper died after its first frame", async () => {+ const session = newSession(true);+ await startReady(session);++ session.arm();+ helper.emitEvent({+ event: "capture-started",+ timestampMs: 1_200,+ path: "/tmp/recording.mp4",+ width: 800,+ height: 600,+ fps: 30,+ });+ await flushStdout();+ helper.emit("exit", 1, null);+ await flushStdout();+await expect(session.waitUntilCapturing()).rejects.toThrow();});});diff --git a/electron/native-bridge/capture/linuxNativeCaptureSession.ts b/electron/native-bridge/capture/linuxNativeCaptureSession.tsindex afe7a694f..689097392 100644--- a/electron/native-bridge/capture/linuxNativeCaptureSession.ts+++ b/electron/native-bridge/capture/linuxNativeCaptureSession.ts@@ -227,12 +227,16 @@ export class LinuxNativeCaptureSession {* answered the portal picker. No timeout, on purpose: see the class doc.*/waitUntilCapturing(): Promise<void> {- if (this.capturing) {- return Promise.resolve();- }if (!this.process) {return Promise.reject(new Error("The Linux capture helper is not running."));}+ // Checked AFTER the liveness test, unlike the latch in+ // [`waitUntilSourceSelected`]: a helper that died after its first frame+ // has stopped recording, so reporting a running capture would be worse+ // than the wait this latch exists to end.+ if (this.capturing) {+ return Promise.resolve();+ }return new Promise<void>((resolve, reject) => {this.startedResolve = resolve;this.startedReject = reject;