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 reporting an unrunnable helper as a denied permission

Etienne Lescot6442845850ba
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index 4eb288e14..c4ccbaa8c 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -81,7 +81,10 @@ interface Window {
requestNativeMacCursorAccess: () => Promise<{
success: boolean;
granted: boolean;
- status: string;
+ // "not-determined" is the only genuine denial; the rest mean the helper
+ // never got to ask. See macNativeCursorRecordingSession.ts.
+ status: "granted" | "not-determined" | "missing-helper" | "error" | "exited" | "timeout";
+ accessibilityTrusted: boolean;
error?: string;
}>;
assetBaseUrl: string;
@@ -132,7 +135,7 @@ interface Window {
success: boolean;
available: boolean;
helperPath?: string;
- reason?: "unsupported-platform" | "missing-helper" | string;
+ reason?: "unsupported-platform" | "unsupported-os" | "missing-helper" | string;
error?: string;
}>;
startNativeWindowsRecording: (
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index 958ef6d96..22586f140 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -69,7 +69,10 @@ import {
LinuxNativeCaptureSession,
} from "../native-bridge/capture/linuxNativeCaptureSession";
import { createCursorRecordingSession } from "../native-bridge/cursor/recording/factory";
-import { requestMacCursorAccessibilityAccess } from "../native-bridge/cursor/recording/macNativeCursorRecordingSession";
+import {
+ isMacCursorHelperUnavailable,
+ requestMacCursorAccessibilityAccess,
+} from "../native-bridge/cursor/recording/macNativeCursorRecordingSession";
import { findPipeWireCursorHelperPath } from "../native-bridge/cursor/recording/pipeWireCursorRecordingSession";
import type { CursorRecordingSession } from "../native-bridge/cursor/recording/session";
import { toHelperRect } from "../native-bridge/helperCoordinates";
@@ -978,6 +981,24 @@ async function findNativeMacCaptureHelperPath() {
return null;
}
+/**
+ * ScreenCaptureRecorder is `@available(macOS 13.0, *)` and its `main()` hard-guards
+ * `#available(macOS 13.0, *)`, so on macOS 12 the helper binary exists, execs, and then
+ * exits with `unsupportedMacOS`. Answering that here lets the renderer take the browser
+ * fallback deliberately, the way Windows and Linux already do, instead of discovering it
+ * as an opaque spawn failure (#515).
+ */
+function isMacScreenCaptureKitOsSupported() {
+ if (process.platform !== "darwin") {
+ return false;
+ }
+
+ const [major] = process.getSystemVersion().split(".").map(Number);
+ // Fail OPEN on an unparseable version: refusing would push every healthy Mac onto
+ // the browser pipeline, which is far worse than letting the helper answer for itself.
+ return !Number.isFinite(major) || major >= 13;
+}
+
function isWindowsGraphicsCaptureOsSupported() {
if (process.platform !== "win32") {
return false;
@@ -1913,14 +1934,27 @@ export function registerIpcHandlers(
ipcMain.handle("request-native-mac-cursor-access", async () => {
const access = await requestMacCursorAccessibilityAccess();
- // When the editable cursor can't get Accessibility trust, pop a native dialog
- // that deep-links to the Accessibility pane (mirrors the Screen Recording flow).
+ // Pop the native Accessibility dialog ONLY for a genuine denial — the helper ran,
+ // asked, and was told no. Every other !granted status means the helper never got
+ // to ask (absent from the build, killed by the loader, crashed, hung), and telling
+ // the user to grant a permission they may well already hold is what made #515
+ // impossible to escape. Those degrade silently instead; the recorder falls back to
+ // position-only cursor telemetry and the countdown still runs.
if (process.platform === "darwin" && !access.granted) {
+ if (isMacCursorHelperUnavailable(access.status)) {
+ console.warn(
+ `[cursor-macos] editable cursor unavailable (status=${access.status}${
+ access.error ? `, error=${access.error}` : ""
+ }); the app ${
+ access.accessibilityTrusted ? "does" : "does not"
+ } hold Accessibility trust. Recording continues with position-only cursor telemetry.`,
+ );
+ return access;
+ }
+
const mainWin = getMainWindow();
const detail =
- access.status === "missing-helper"
- ? "The cursor helper couldn't be found in this build, so the editable cursor can't be enabled. Rebuild the native helper (npm run build:native:mac) or switch the HUD cursor mode to system."
- : "Allow OpenScreen under System Settings → Privacy & Security → Accessibility, then press record again to start the countdown.";
+ "Allow OpenScreen under System Settings → Privacy & Security → Accessibility, then press record again to start the countdown.";
const messageOptions = {
type: "warning",
buttons: ["Open Accessibility Settings", "Cancel"],
@@ -2089,6 +2123,10 @@ export function registerIpcHandlers(
return { success: true, available: false, reason: "unsupported-platform" };
}
+ if (!isMacScreenCaptureKitOsSupported()) {
+ return { success: true, available: false, reason: "unsupported-os" };
+ }
+
const helperPath = await findNativeMacCaptureHelperPath();
return helperPath
? { success: true, available: true, helperPath }
diff --git a/electron/native-bridge/cursor/recording/macNativeCursorRecordingSession.ts b/electron/native-bridge/cursor/recording/macNativeCursorRecordingSession.ts
index e274b681f..7baa33474 100644
--- a/electron/native-bridge/cursor/recording/macNativeCursorRecordingSession.ts
+++ b/electron/native-bridge/cursor/recording/macNativeCursorRecordingSession.ts
@@ -80,98 +80,131 @@ export function findMacCursorHelperPath() {
return null;
}
-export async function requestMacCursorAccessibilityAccess() {
+/**
+ * Why `granted: false` is not the same question as "did the user deny Accessibility".
+ *
+ * `not-determined` is the ONLY genuine denial: the helper ran, asked, and was told no.
+ * The other four mean the helper never got to ask — it is absent from the build, the
+ * loader killed it, it crashed, or it hung. Reporting those as a denial is what made
+ * #515 unfixable from the user's side: on macOS 12 the helper died in dyld, and the app
+ * answered by telling the user to grant a permission they had already granted.
+ */
+export type MacCursorAccessStatus =
+ | "granted"
+ | "not-determined"
+ | "missing-helper"
+ | "error"
+ | "exited"
+ | "timeout";
+
+export interface MacCursorAccessResult {
+ success: boolean;
+ granted: boolean;
+ status: MacCursorAccessStatus;
+ /**
+ * Whether *the app* holds Accessibility trust, read from the main process rather
+ * than from the helper. This is what separates the two failure modes: a helper that
+ * could not run while this is `true` is a broken build, not a missing grant.
+ */
+ accessibilityTrusted: boolean;
+ error?: string;
+}
+
+/** True when the helper never got far enough to answer the permission question. */
+export function isMacCursorHelperUnavailable(status: MacCursorAccessStatus) {
+ return (
+ status === "missing-helper" || status === "error" || status === "exited" || status === "timeout"
+ );
+}
+
+export async function requestMacCursorAccessibilityAccess(): Promise<MacCursorAccessResult> {
if (process.platform !== "darwin") {
- return { success: true, granted: true, status: "granted" };
+ return { success: true, granted: true, status: "granted", accessibilityTrusted: true };
}
+ // The return value is the signal, not a side effect: it says whether OpenScreen.app
+ // itself is trusted, independently of whether the child helper can be launched.
+ let accessibilityTrusted = false;
try {
- systemPreferences.isTrustedAccessibilityClient(true);
+ accessibilityTrusted = systemPreferences.isTrustedAccessibilityClient(true);
} catch {
// Continue with helper probing; it can trigger the same macOS prompt.
}
const helperPath = findMacCursorHelperPath();
if (!helperPath) {
- return { success: true, granted: false, status: "missing-helper" };
+ return { success: true, granted: false, status: "missing-helper", accessibilityTrusted };
}
- return new Promise<{ success: boolean; granted: boolean; status: string; error?: string }>(
- (resolve) => {
- const child = spawn(helperPath, [JSON.stringify({ sampleIntervalMs: 250 })], {
- stdio: ["ignore", "pipe", "pipe"],
+ return new Promise<MacCursorAccessResult>((resolve) => {
+ const child = spawn(helperPath, [JSON.stringify({ sampleIntervalMs: 250 })], {
+ stdio: ["ignore", "pipe", "pipe"],
+ });
+ let settled = false;
+ let lineBuffer = "";
+ const finish = (result: Omit<MacCursorAccessResult, "accessibilityTrusted">) => {
+ if (settled) {
+ return;
+ }
+ settled = true;
+ clearTimeout(timer);
+ if (!child.killed) {
+ child.kill("SIGTERM");
+ }
+ resolve({ ...result, accessibilityTrusted });
+ };
+ const timer = setTimeout(() => {
+ finish({
+ success: false,
+ granted: false,
+ status: "timeout",
+ error: "Timed out waiting for macOS cursor helper",
});
- let settled = false;
- let lineBuffer = "";
- const finish = (result: {
- success: boolean;
- granted: boolean;
- status: string;
- error?: string;
- }) => {
- if (settled) {
- return;
- }
- settled = true;
- clearTimeout(timer);
- if (!child.killed) {
- child.kill("SIGTERM");
- }
- resolve(result);
- };
- const timer = setTimeout(() => {
- finish({
- success: false,
- granted: false,
- status: "timeout",
- error: "Timed out waiting for macOS cursor helper",
- });
- }, READY_TIMEOUT_MS);
+ }, READY_TIMEOUT_MS);
- child.stdout.setEncoding("utf8");
- child.stdout.on("data", (chunk: string) => {
- lineBuffer += chunk;
- const lines = lineBuffer.split(/\r?\n/);
- lineBuffer = lines.pop() ?? "";
- for (const line of lines) {
- const trimmed = line.trim();
- if (!trimmed) {
- continue;
- }
- try {
- const event = JSON.parse(trimmed) as MacCursorEvent;
- if (event.type === "ready") {
- finish({
- success: true,
- granted: event.accessibilityTrusted === true,
- status: event.accessibilityTrusted === true ? "granted" : "not-determined",
- });
- return;
- }
- } catch {
- // Ignore non-JSON helper output.
+ child.stdout.setEncoding("utf8");
+ child.stdout.on("data", (chunk: string) => {
+ lineBuffer += chunk;
+ const lines = lineBuffer.split(/\r?\n/);
+ lineBuffer = lines.pop() ?? "";
+ for (const line of lines) {
+ const trimmed = line.trim();
+ if (!trimmed) {
+ continue;
+ }
+ try {
+ const event = JSON.parse(trimmed) as MacCursorEvent;
+ if (event.type === "ready") {
+ finish({
+ success: true,
+ granted: event.accessibilityTrusted === true,
+ status: event.accessibilityTrusted === true ? "granted" : "not-determined",
+ });
+ return;
}
+ } catch {
+ // Ignore non-JSON helper output.
}
- });
+ }
+ });
- child.once("error", (error) => {
- finish({
- success: false,
- granted: false,
- status: "error",
- error: error.message,
- });
+ child.once("error", (error) => {
+ finish({
+ success: false,
+ granted: false,
+ status: "error",
+ error: error.message,
});
- child.once("exit", (code, signal) => {
- finish({
- success: false,
- granted: false,
- status: "exited",
- error: `macOS cursor helper exited before ready (code=${code}, signal=${signal})`,
- });
+ });
+ child.once("exit", (code, signal) => {
+ finish({
+ success: false,
+ granted: false,
+ status: "exited",
+ error: `macOS cursor helper exited before ready (code=${code}, signal=${signal})`,
});
- },
- );
+ });
+ });
}
function normalizeCursorType(value: unknown): NativeCursorType | null {
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 14eec5ab4..a1154c13b 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -1216,6 +1216,14 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
return false;
}
+ // macOS 12: the helper is present but ScreenCaptureKit capture is gated to
+ // 13+, so fall back to the browser pipeline rather than refusing to record.
+ // Windows does the same at the equivalent branch above, and Linux below.
+ if (availability.reason === "unsupported-os") {
+ console.warn("Native macOS capture needs macOS 13 or later; using browser capture.");
+ return false;
+ }
+
throw new Error(
availability.reason === "missing-helper"
? "Native macOS capture helper is not available."
@@ -1546,13 +1554,26 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
try {
const platform = window.electronAPI.getPlatform();
if (platform === "darwin" && cursorCaptureMode === "editable-overlay") {
- // The main process shows a native dialog that deep-links to the
- // Accessibility settings pane when access is missing, so we just stop
- // here and let the user grant it and press record again.
+ // Stop before the countdown ONLY when the user genuinely denied
+ // Accessibility — the main process is showing them a dialog that
+ // deep-links to the settings pane, so pressing record again after
+ // granting it will work.
+ //
+ // When the helper simply could not run (missing from the build, killed
+ // by the loader, crashed, hung) there is nothing for the user to grant,
+ // and blocking here is what left macOS 12 unable to record at all
+ // (#515). Recording degrades on its own: the session falls back to
+ // position-only cursor telemetry and the editor draws the cursor from
+ // its bundled sprites, so only the pointer/text shape hints are lost.
const access = await window.electronAPI.requestNativeMacCursorAccess();
- if (!access.granted) {
+ if (!access.granted && access.status === "not-determined") {
return;
}
+ if (!access.granted) {
+ console.warn(
+ `Editable cursor unavailable (${access.status}); recording with position-only cursor telemetry.`,
+ );
+ }
}
} catch (error) {
console.warn("Failed to preflight macOS cursor accessibility before countdown:", error);
@@ -1654,6 +1675,21 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
countdownRunToken?: number,
preparedRecordingId?: number | null,
) => {
+ const platform = window.electronAPI.getPlatform();
+
+ // Only the win32 branch below reaches the browser pipeline through
+ // getDisplayMedia, which is the sole browser API here that can exclude the
+ // system cursor (`cursor: "never"`). Everywhere else the desktop-capture
+ // stream bakes the real cursor into the pixels, so reporting
+ // "editable-overlay" to the main process would start cursor telemetry and
+ // have the editor composite a SECOND, synthetic cursor on top of it.
+ //
+ // This only bites when a platform falls back to browser capture with the
+ // editable cursor selected — on macOS 12 that is now the normal path (#515),
+ // and on Linux it is the no-PipeWire path, where the same latent defect lives.
+ const browserCursorCaptureMode: CursorCaptureMode =
+ platform === "win32" ? cursorCaptureMode : "system";
+
try {
if (!isCountdownRunActive(countdownRunToken)) {
teardownMedia();
@@ -1688,8 +1724,6 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
// `getUserMedia` calls is the dominant source of the mic-vs-video lag at the
// start of the recording (issue #57).
const screenCapture = (async (): Promise<MediaStream> => {
- const platform = window.electronAPI.getPlatform();
-
if (platform === "win32") {
// getDisplayMedia + setDisplayMediaRequestHandler (main.ts) supplies the
// pre-selected source. Editable cursor mode excludes the system cursor so
@@ -1920,7 +1954,7 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
setRecording(true);
setPaused(false);
setElapsedSeconds(0);
- window.electronAPI?.setRecordingState(true, recordingId.current, cursorCaptureMode);
+ window.electronAPI?.setRecordingState(true, recordingId.current, browserCursorCaptureMode);
const activeScreenRecorder = screenRecorder.current;
const activeWebcamRecorder = webcamRecorder.current;