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(macos): warn when recording the default microphone

Arham Wani29a099d4558e
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index 3b9266dcb..7f837ae19 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -2829,6 +2829,14 @@ export function registerIpcHandlers(
await waitForNativeMacCaptureStart(proc);
const captureStartedAtMs = Date.now();
+ const microphoneDefaulted =
+ request.audio.microphone.enabled && readMicrophoneDefaulted(nativeMacCaptureOutput);
+ if (microphoneDefaulted) {
+ console.warn("[native-sck] recording the default input; microphone was not resolved", {
+ deviceId: request.audio.microphone.deviceId,
+ deviceName: request.audio.microphone.deviceName,
+ });
+ }
nativeMacCursorOffsetMs =
cursorCaptureMode === "editable-overlay"
? Math.max(0, captureStartedAtMs - cursorStartTimeMs)
@@ -2844,6 +2852,7 @@ export function registerIpcHandlers(
recordingId,
path: outputPath,
helperPath,
+ microphoneDefaulted,
};
} catch (error) {
console.error("Failed to start native macOS recording:", error);
diff --git a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift
index dadbd8f4c..1491f2321 100644
--- a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift
+++ b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/ScreenCaptureRecorder.swift
@@ -481,6 +481,12 @@ final class ScreenCaptureRecorder: NSObject, SCStreamOutput, SCStreamDelegate {
configuration.setValue(true, forKey: "captureMicrophone")
if let deviceId = resolveMicrophoneCaptureDeviceID() {
configuration.setValue(deviceId, forKey: "microphoneCaptureDeviceID")
+ } else {
+ emit([
+ "event": "warning",
+ "code": "microphone-defaulted",
+ "message": "The requested microphone could not be resolved; capturing the default input.",
+ ])
}
} else {
nativeMicrophoneEnabled = false
diff --git a/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx
new file mode 100644
index 000000000..8770b4973
--- /dev/null
+++ b/src/hooks/useScreenRecorder.nativeMacStartWarning.test.tsx
@@ -0,0 +1,90 @@
+// @vitest-environment jsdom
+import { act, renderHook } from "@testing-library/react";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+vi.mock("@/contexts/I18nContext", () => ({
+ useScopedT: () => (key: string) => key,
+}));
+
+vi.mock("sonner", () => ({
+ toast: { error: vi.fn(), success: vi.fn(), info: vi.fn(), warning: vi.fn() },
+}));
+
+import { toast } from "sonner";
+import { useScreenRecorder } from "./useScreenRecorder";
+
+type ElectronAPI = Window["electronAPI"];
+
+const SOURCE = { id: "screen:0:0", name: "Screen 1", display_id: "1", thumbnail: "" };
+
+let api: Record<string, ReturnType<typeof vi.fn>>;
+
+function stubElectronAPI() {
+ api = {
+ getRecordingPrefs: vi.fn(async () => ({
+ micEnabled: true,
+ micDeviceId: "chromium-device-id",
+ micDeviceName: "USB Microphone",
+ camEnabled: false,
+ camDeviceId: null,
+ systemAudioEnabled: false,
+ cursorCaptureMode: "system",
+ })),
+ getPlatform: vi.fn(() => "darwin"),
+ getSelectedSource: vi.fn(async () => SOURCE),
+ isNativeMacCaptureAvailable: vi.fn(async () => ({ success: true, available: true })),
+ startNativeMacRecording: vi.fn(async () => ({
+ success: true,
+ recordingId: 7,
+ microphoneDefaulted: true,
+ })),
+ stopNativeMacRecording: vi.fn(async () => ({ success: true, discarded: true })),
+ showCountdownOverlay: vi.fn(async () => true),
+ setCountdownOverlayValue: vi.fn(async () => true),
+ hideCountdownOverlay: vi.fn(async () => true),
+ };
+ window.electronAPI = api as unknown as ElectronAPI;
+}
+
+async function settle(ms = 0) {
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(ms);
+ });
+}
+
+beforeEach(() => {
+ vi.useFakeTimers();
+ stubElectronAPI();
+});
+
+afterEach(() => {
+ vi.useRealTimers();
+ vi.restoreAllMocks();
+});
+
+describe("useScreenRecorder native macOS start warnings", () => {
+ it("warns but keeps recording when the selected microphone defaults", async () => {
+ const view = renderHook(() => useScreenRecorder());
+ await settle();
+
+ await act(async () => {
+ view.result.current.toggleRecording();
+ });
+ await settle(3_500);
+
+ expect(api.startNativeMacRecording).toHaveBeenCalledWith(
+ expect.objectContaining({
+ audio: {
+ system: { enabled: false },
+ microphone: expect.objectContaining({
+ enabled: true,
+ deviceId: "chromium-device-id",
+ deviceName: "USB Microphone",
+ }),
+ },
+ }),
+ );
+ expect(view.result.current.recording).toBe(true);
+ expect(toast.error).toHaveBeenCalledWith("recording.microphoneDefaulted");
+ });
+});
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 396866b0f..1e741a5e5 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -1365,6 +1365,9 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
if (!result.success || !result.recordingId) {
throw new Error(result.error ?? "Native macOS capture failed.");
}
+ if (result.microphoneDefaulted) {
+ toast.error(t("recording.microphoneDefaulted"));
+ }
if (!isCountdownRunActive(countdownRunToken)) {
await window.electronAPI.stopNativeMacRecording(true);
return true;
diff --git a/src/lib/nativeMacRecording.ts b/src/lib/nativeMacRecording.ts
index ff48674a3..2ad449270 100644
--- a/src/lib/nativeMacRecording.ts
+++ b/src/lib/nativeMacRecording.ts
@@ -90,6 +90,8 @@ export type NativeMacRecordingStartResult = {
recordingId?: number;
path?: string;
helperPath?: string;
+ /** The helper could not resolve the selected device and is using the system default. */
+ microphoneDefaulted?: boolean;
error?: string;
};