Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(recording): stop native recording if late webcam recorder creation fails

Etienne Lescot5b67fd782109
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 676ddeb48..af95b4722 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -1039,10 +1039,18 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
// (~1s of pre-roll) into the webcam file, desyncing it from the
// screen/mic recording that the editor and exporter align at t=0.
if (webcamEnabled && webcamStream.current) {
- nativeWebcamRecorder = createRecorderHandle(webcamStream.current, {
- mimeType: selectMimeType(),
- videoBitsPerSecond: BITRATE_BASE,
- });
+ try {
+ nativeWebcamRecorder = createRecorderHandle(webcamStream.current, {
+ mimeType: selectMimeType(),
+ videoBitsPerSecond: BITRATE_BASE,
+ });
+ } catch (webcamError) {
+ // The native helper is already recording at this point; stop it before
+ // surfacing the error so we don't leave it running with no handle to
+ // finalize it (this creation moved after startNativeMacRecording).
+ await window.electronAPI.stopNativeMacRecording(true);
+ throw webcamError;
+ }
}
recordingId.current = result.recordingId;