Create polished demo videos without editing skills. Mac/Windows/Linux
fix: TCC permission handling for native helpers on macOS 26
webadderallcac01261093b
diff --git a/build/entitlements.mac.inherit.plist b/build/entitlements.mac.inherit.plistindex 83d6db86..a0414705 100644--- a/build/entitlements.mac.inherit.plist+++ b/build/entitlements.mac.inherit.plist@@ -8,6 +8,10 @@<true/><key>com.apple.security.cs.disable-library-validation</key><true/>+ <key>com.apple.security.device.camera</key>+ <true/>+ <key>com.apple.security.device.audio-input</key>+ <true/><key>com.apple.security.inherit</key><true/></dict>diff --git a/build/entitlements.mac.plist b/build/entitlements.mac.plistindex 7fc6b03b..98652b7f 100644--- a/build/entitlements.mac.plist+++ b/build/entitlements.mac.plist@@ -8,6 +8,8 @@<true/><key>com.apple.security.cs.disable-library-validation</key><true/>+ <key>com.apple.security.device.camera</key>+ <true/><key>com.apple.security.device.audio-input</key><true/></dict>diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.tsindex 314d49cc..f9a9ed19 100644--- a/electron/electron-env.d.ts+++ b/electron/electron-env.d.ts@@ -78,7 +78,7 @@ interface Window {microphoneDeviceId?: string;microphoneLabel?: string;},- ) => Promise<{ success: boolean; path?: string; message?: string; error?: string }>;+ ) => Promise<{ success: boolean; path?: string; message?: string; error?: string; userNotified?: boolean }>;stopNativeScreenRecording: () => Promise<{success: boolean;path?: string;diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex b06969dc..58fd1a23 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -44,6 +44,9 @@ function getAssetRootPath() {}function getScreen() {+ if (!app.isReady()) {+ throw new Error("getScreen() called before app is ready. Ensure all screen access happens after app.whenReady().")+ }return nodeRequire('electron').screen as typeof import('electron').screen}@@ -222,10 +225,10 @@ function hasUsableSourceThumbnail(return size.width > 1 && size.height > 1}-function getMacPrivacySettingsUrl(pane: 'screen' | 'accessibility') {- return pane === 'screen'- ? 'x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'- : 'x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility'+function getMacPrivacySettingsUrl(pane: 'screen' | 'accessibility' | 'microphone') {+ if (pane === 'screen') return 'x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture'+ if (pane === 'microphone') return 'x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone'+ return 'x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility'}function isAutoRecordingPath(filePath: string) {@@ -3339,6 +3342,25 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}try {const recordingsDir = await getRecordingsDir()++ // Warm up TCC: trigger an Electron-level screen capture API call so macOS+ // activates the screen-recording grant for this process tree before the+ // native helper binary spawns and calls SCStream.startCapture().+ try {+ await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: { width: 1, height: 1 } })+ } catch {+ // non-fatal – the helper will report its own TCC status+ }++ // Ensure microphone TCC is granted for this process tree when mic capture+ // is requested, so the child helper inherits the grant.+ if (options?.capturesMicrophone) {+ const micStatus = systemPreferences.getMediaAccessStatus('microphone')+ if (micStatus !== 'granted') {+ await systemPreferences.askForMediaAccess('microphone')+ }+ }+const appName = normalizeDesktopSourceName(String(source?.appName ?? ''))const ownAppName = normalizeDesktopSourceName(app.getName())if (@@ -3431,6 +3453,65 @@ body{background:transparent;overflow:hidden;width:100vw;height:100vh}return { success: true }} catch (error) {console.error('Failed to start native ScreenCaptureKit recording:', error)+ const errorStr = String(error)++ // Detect TCC (screen recording permission) errors and show a helpful dialog+ if (errorStr.includes('declined TCC') || errorStr.includes('declined TCCs') || errorStr.includes('SCREEN_RECORDING_PERMISSION_DENIED')) {+ const { response } = await dialog.showMessageBox({+ type: 'warning',+ title: 'Screen Recording Permission Required',+ message: 'Recordly needs screen recording permission to capture your screen.',+ detail: 'Please open System Settings > Privacy & Security > Screen Recording, make sure Recordly is toggled ON, then try recording again.',+ buttons: ['Open System Settings', 'Cancel'],+ defaultId: 0,+ cancelId: 1,+ })+ if (response === 0) {+ await shell.openExternal(getMacPrivacySettingsUrl('screen'))+ }+ try { nativeCaptureProcess?.kill() } catch { /* ignore */ }+ nativeScreenRecordingActive = false+ nativeCaptureProcess = null+ nativeCaptureTargetPath = null+ nativeCaptureSystemAudioPath = null+ nativeCaptureMicrophonePath = null+ nativeCaptureStopRequested = false+ nativeCapturePaused = false+ return {+ success: false,+ message: 'Screen recording permission not granted. Please allow access in System Settings and restart the app.',+ userNotified: true,+ }+ }++ if (errorStr.includes('MICROPHONE_PERMISSION_DENIED')) {+ const { response } = await dialog.showMessageBox({+ type: 'warning',+ title: 'Microphone Permission Required',+ message: 'Recordly needs microphone permission to record audio.',+ detail: 'Please open System Settings > Privacy & Security > Microphone, make sure Recordly is toggled ON, then try recording again.',+ buttons: ['Open System Settings', 'Cancel'],+ defaultId: 0,+ cancelId: 1,+ })+ if (response === 0) {+ await shell.openExternal(getMacPrivacySettingsUrl('microphone'))+ }+ try { nativeCaptureProcess?.kill() } catch { /* ignore */ }+ nativeScreenRecordingActive = false+ nativeCaptureProcess = null+ nativeCaptureTargetPath = null+ nativeCaptureSystemAudioPath = null+ nativeCaptureMicrophonePath = null+ nativeCaptureStopRequested = false+ nativeCapturePaused = false+ return {+ success: false,+ message: 'Microphone permission not granted. Please allow access in System Settings.',+ userNotified: true,+ }+ }+recordNativeCaptureDiagnostics({backend: 'mac-screencapturekit',phase: 'start',diff --git a/electron/main.ts b/electron/main.tsindex 7e9ce79e..0909a18f 100644--- a/electron/main.ts+++ b/electron/main.ts@@ -100,9 +100,23 @@ function closeEditorWindowBypassingUnsavedPrompt(window: BrowserWindow | null) {window.close();}-// Tray Icons-const defaultTrayIcon = getTrayIcon("app-icons/recordly-32.png");-const recordingTrayIcon = getTrayIcon("rec-button.png");+// Tray Icons (lazily created after app is ready to avoid accessing Electron APIs too early)+let defaultTrayIcon: ReturnType<typeof getTrayIcon> | null = null;+let recordingTrayIcon: ReturnType<typeof getTrayIcon> | null = null;++function getDefaultTrayIcon() {+ if (!defaultTrayIcon) {+ defaultTrayIcon = getTrayIcon("app-icons/recordly-32.png");+ }+ return defaultTrayIcon;+}++function getRecordingTrayIcon() {+ if (!recordingTrayIcon) {+ recordingTrayIcon = getTrayIcon("rec-button.png");+ }+ return recordingTrayIcon;+}ipcMain.on("set-has-unsaved-changes", (_event, hasChanges: boolean) => {editorHasUnsavedChanges = hasChanges;@@ -272,7 +286,7 @@ function setupApplicationMenu() {}function createTray() {- tray = new Tray(defaultTrayIcon);+ tray = new Tray(getDefaultTrayIcon());tray.on("click", () => focusOrCreateMainWindow());}@@ -374,7 +388,7 @@ ipcMain.handle("preview-update-toast", () => {function updateTrayMenu(recording: boolean = false) {if (!tray) return;- const trayIcon = recording ? recordingTrayIcon : defaultTrayIcon;+ const trayIcon = recording ? getRecordingTrayIcon() : getDefaultTrayIcon();const trayToolTip = recording ? `Recording: ${selectedSourceName}` : "Recordly";const menuTemplate = recording? [@@ -493,16 +507,21 @@ app.on("second-instance", () => {// Register all IPC handlers when app is readyapp.whenReady().then(async () => {session.defaultSession.setPermissionCheckHandler((_webContents, permission) => {- const allowed = ["media", "audioCapture", "microphone"];+ const allowed = ["media", "audioCapture", "microphone", "camera", "videoCapture"];return allowed.includes(permission);});session.defaultSession.setPermissionRequestHandler((_webContents, permission, callback) => {- const allowed = ["media", "audioCapture", "microphone"];+ const allowed = ["media", "audioCapture", "microphone", "camera", "videoCapture"];callback(allowed.includes(permission));});if (process.platform === "darwin") {+ const cameraStatus = systemPreferences.getMediaAccessStatus("camera");+ if (cameraStatus !== "granted") {+ await systemPreferences.askForMediaAccess("camera");+ }+const micStatus = systemPreferences.getMediaAccessStatus("microphone");if (micStatus !== "granted") {await systemPreferences.askForMediaAccess("microphone");diff --git a/electron/native/ScreenCaptureKitRecorder.swift b/electron/native/ScreenCaptureKitRecorder.swiftindex 220b112b..c03e9415 100644--- a/electron/native/ScreenCaptureKitRecorder.swift+++ b/electron/native/ScreenCaptureKitRecorder.swift@@ -587,6 +587,42 @@ guard CommandLine.arguments.count >= 2 else {// CGS_REQUIRE_INIT because CGS is never initialised in a CLI tool.let _ = CGMainDisplayID()+// Pre-flight check: ensure screen recording permission is granted before+// attempting capture. On macOS 15+, a one-session grant may expire after the+// parent app restarts. CGRequestScreenCaptureAccess() will trigger the+// system-level permission dialog (or open System Settings) when not yet granted.+if !CGPreflightScreenCaptureAccess() {+ let granted = CGRequestScreenCaptureAccess()+ if !granted {+ fputs("SCREEN_RECORDING_PERMISSION_DENIED\n", stderr)+ fflush(stderr)+ exit(1)+ }+}++// Pre-flight check for microphone access when mic capture is requested.+if let configData = CommandLine.arguments[1].data(using: .utf8),+ let config = try? JSONDecoder().decode(CaptureConfig.self, from: configData),+ config.capturesMicrophone == true {+ switch AVCaptureDevice.authorizationStatus(for: .audio) {+ case .authorized:+ break+ case .notDetermined:+ let sem = DispatchSemaphore(value: 0)+ AVCaptureDevice.requestAccess(for: .audio) { _ in sem.signal() }+ sem.wait()+ if AVCaptureDevice.authorizationStatus(for: .audio) != .authorized {+ fputs("MICROPHONE_PERMISSION_DENIED\n", stderr)+ fflush(stderr)+ exit(1)+ }+ default:+ fputs("MICROPHONE_PERMISSION_DENIED\n", stderr)+ fflush(stderr)+ exit(1)+ }+}+let service = RecorderService()service.start(configJSON: CommandLine.arguments[1])diff --git a/electron/native/bin/darwin-arm64/openscreen-screencapturekit-helper b/electron/native/bin/darwin-arm64/openscreen-screencapturekit-helperindex 825dd53e..67e5898f 100755Binary files a/electron/native/bin/darwin-arm64/openscreen-screencapturekit-helper and b/electron/native/bin/darwin-arm64/openscreen-screencapturekit-helper differdiff --git a/electron/windows.ts b/electron/windows.tsindex ddcaf5d6..b0717266 100644--- a/electron/windows.ts+++ b/electron/windows.ts@@ -2,7 +2,7 @@ import fs from "node:fs";import { createRequire } from "node:module";import path from "node:path";import { fileURLToPath } from "node:url";-import { BrowserWindow, ipcMain } from "electron";+import { app, BrowserWindow, ipcMain } from "electron";import { USER_DATA_PATH } from "./appPaths";const __dirname = path.dirname(fileURLToPath(import.meta.url));@@ -82,6 +82,9 @@ function persistHudOverlayCaptureProtectionSetting(enabled: boolean): void {}function getScreen() {+ if (!app.isReady()) {+ throw new Error("getScreen() called before app is ready. Ensure all screen access happens after app.whenReady().");+ }return nodeRequire("electron").screen as typeof import("electron").screen;}diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.tsindex 3777dbe7..3af7bf2d 100644--- a/src/hooks/useScreenRecorder.ts+++ b/src/hooks/useScreenRecorder.ts@@ -706,10 +706,15 @@ export function useScreenRecorder(): UseScreenRecorderReturn {"Native Windows capture failed to start. Falling back to browser capture.",);}- } else {+ } else if (!nativeResult.userNotified) {throw new Error(nativeResult.error ?? nativeResult.message ?? "Failed to start native screen recording",);+ } else {+ setRecording(false);+ cleanupCapturedMedia();+ await stopWebcamRecorder();+ return;}}