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: #966

Marc Diaz89f89ff57464
diff --git a/electron/native-bridge/screen/macPickerSession.test.ts b/electron/native-bridge/screen/macPickerSession.test.ts
index adac0495b..3aba6cdb2 100644
--- a/electron/native-bridge/screen/macPickerSession.test.ts
+++ b/electron/native-bridge/screen/macPickerSession.test.ts
@@ -212,6 +212,35 @@ describe("MacPickerSession", () => {
expect(session.getSelection()).toBeNull();
});
+ it("keeps a screen pick that leaves out the whole app, new windows included (#996)", async () => {
+ const { helper, session } = await readySession();
+ // Picked in the editor's Record mode: the HUD does not exist yet.
+ const pick = session.present([7]);
+ await flush();
+ helper.say({ ...DISPLAY_PICK, excludesApp: true });
+ expect(await pick).not.toBeNull();
+
+ // Start recording brought the HUD back as a window the picker was never told about.
+ session.forgetSelectionUnlessExcluding([9]);
+ expect(session.getSelection()).not.toBeNull();
+ });
+
+ it("goes back to checking window ids once a later pick does not leave out the app", async () => {
+ const { helper, session } = await readySession();
+ const first = session.present([7]);
+ await flush();
+ helper.say({ ...DISPLAY_PICK, excludesApp: true });
+ expect(await first).not.toBeNull();
+
+ const second = session.present([7]);
+ await flush();
+ helper.say(DISPLAY_PICK);
+ expect(await second).not.toBeNull();
+
+ session.forgetSelectionUnlessExcluding([9]);
+ expect(session.getSelection()).toBeNull();
+ });
+
it("keeps the exclusions of the pick, not of a picker that was cancelled", async () => {
const { helper, session } = await pickDisplay();
const cancelled = session.present([9]);
diff --git a/electron/native-bridge/screen/macPickerSession.ts b/electron/native-bridge/screen/macPickerSession.ts
index 7b7aea758..e2e2f2603 100644
--- a/electron/native-bridge/screen/macPickerSession.ts
+++ b/electron/native-bridge/screen/macPickerSession.ts
@@ -190,6 +190,8 @@ export class MacPickerSession {
private presentedExclusions: readonly number[] = [];
/** The windows the retained pick leaves out: baked into its filter, fixed until the next pick. */
private selectionExclusions: readonly number[] = [];
+ /** Whether the retained pick leaves out the whole app, windows it opens later included. */
+ private selectionExcludesApp = false;
private take: TakeProcess | null = null;
private pendingPick: ((selection: MacPickerSelection | null) => void) | null = null;
private lineBuffer = "";
@@ -213,9 +215,18 @@ export class MacPickerSession {
* the editor -- the pick would record it, and only picking again leaves it out (#965).
* A window pick records that one window and is never affected, and neither is a take
* already running: its filter is set, and its cursor telemetry still reads the pick.
+ *
+ * Nor is a pick the helper reports as leaving out the whole app (`excludesApp`): that
+ * exclusion covers windows created after the pick, so a screen picked in the editor's
+ * Record mode, before the HUD exists, is still good at Start (#996). A helper that
+ * predates the flag never sends it, and its picks are checked by window id as before.
*/
forgetSelectionUnlessExcluding(windowIds: readonly number[]) {
- if (this.selection?.kind !== "display" || (this.take && !this.take.ended)) {
+ if (
+ this.selection?.kind !== "display" ||
+ this.selectionExcludesApp ||
+ (this.take && !this.take.ended)
+ ) {
return;
}
if (!windowIds.every((windowId) => this.selectionExclusions.includes(windowId))) {
@@ -361,6 +372,7 @@ export class MacPickerSession {
if (selection) {
this.selection = selection;
this.selectionExclusions = this.presentedExclusions;
+ this.selectionExcludesApp = event.excludesApp === true;
}
this.resolvePick(selection);
return;
diff --git a/electron/native/README.md b/electron/native/README.md
index 5f68fb254..52c4593a5 100644
--- a/electron/native/README.md
+++ b/electron/native/README.md
@@ -27,7 +27,7 @@ npm run build:native:mac
On non-macOS hosts this command exits successfully and does not affect Windows/Linux development. On macOS it builds the Swift package at `electron/native/screencapturekit`, writes the development binaries to `electron/native/screencapturekit/build`, and copies redistributable binaries to `electron/native/bin/darwin-${arch}`.
-The current helper implementation supports display/window ScreenCaptureKit video capture, control-window exclusion through the request's optional `excludedWindowIds` and `SCContentFilter(display:excludingWindows:)`, cursor exclusion through `SCStreamConfiguration.showsCursor`, H.264 encoding, MP4 muxing (with `AVAssetWriter.movieFragmentInterval` at 1s, so a helper that dies before `finishWriting()` still leaves a readable file — same reasoning as the Windows fragmented sink below), and ScreenCaptureKit system audio. Electron supplies only the HUD and an open Notes window as exclusions for full-display capture, so ordinary OpenScreen windows remain recordable. The helper adds Notification Center's windows on its own, and Finder's desktop-icon windows when the request sets `hideDesktopIcons`; a banner appears as a new window, so a direct capture re-reads the exclusion every 250 ms, while the system picker excludes Notification Center by bundle id. The helper also attempts native ScreenCaptureKit microphone capture when the running macOS version exposes that capability, which is macOS 15 and later. Below that it records the take without the microphone and emits a `microphone-unavailable` warning; the app does not offer the microphone there (`canRecordMicrophone` in `src/utils/platformUtils.ts`). Webcam recording currently stays as an Electron sidecar and is attached to the same recording session after the native screen capture stops.
+The current helper implementation supports display/window ScreenCaptureKit video capture, control-window exclusion through the request's optional `excludedWindowIds` and `SCContentFilter(display:excludingWindows:)`, cursor exclusion through `SCStreamConfiguration.showsCursor`, H.264 encoding, MP4 muxing (with `AVAssetWriter.movieFragmentInterval` at 1s, so a helper that dies before `finishWriting()` still leaves a readable file — same reasoning as the Windows fragmented sink below), and ScreenCaptureKit system audio. Electron supplies only the HUD and an open Notes window as exclusions for full-display capture, so ordinary OpenScreen windows remain recordable. The helper adds Notification Center's windows on its own, and Finder's desktop-icon windows when the request sets `hideDesktopIcons`; a banner appears as a new window, so a direct capture re-reads the exclusion every 250 ms, while the system picker excludes Notification Center by bundle id. It excludes OpenScreen itself the same way, so a screen picked in the editor's Record mode still leaves out the HUD that only appears at Start; the helper reports this as `excludesApp` on `picker-selected`. The helper also attempts native ScreenCaptureKit microphone capture when the running macOS version exposes that capability, which is macOS 15 and later. Below that it records the take without the microphone and emits a `microphone-unavailable` warning; the app does not offer the microphone there (`canRecordMicrophone` in `src/utils/platformUtils.ts`). Webcam recording currently stays as an Electron sidecar and is attached to the same recording session after the native screen capture stops.
Electron exposes `is-native-mac-capture-available` for capability probing. It resolves the same helper locations listed above and reports `missing-helper` until a Swift helper binary is present. When available, macOS recording routes screen/window capture through the native helper so editable cursor recordings do not bake the system cursor into the video. Cursor positions are sampled in Electron; when the cursor helper is available and Accessibility is granted, samples are also tagged with link/text cursor hints such as `pointer`.
diff --git a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/PickerSession.swift b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/PickerSession.swift
index 6b64fd2d5..ab7fe2026 100644
--- a/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/PickerSession.swift
+++ b/electron/native/screencapturekit/Sources/OpenScreenScreenCaptureKitHelper/PickerSession.swift
@@ -34,6 +34,8 @@ import ScreenCaptureKit
@available(macOS 15.2, *)
final class PickerSession: NSObject, SCContentSharingPickerObserver, @unchecked Sendable {
private var picked: PickedSource?
+ /// Whether the picker, as last shown, left out the whole app that owns this helper.
+ private var presentedExcludesApp = false
private var recorder: ScreenCaptureRecorder?
func run() -> Never {
@@ -98,8 +100,12 @@ final class PickerSession: NSObject, SCContentSharingPickerObserver, @unchecked
configuration.excludedWindowIDs =
excludedWindowIDs + Self.finderDesktopIconWindowIDs(hideDesktopIcons: hideDesktopIcons)
// By app, not by window: a banner is a window created after the pick, so no id
- // list taken now could name it.
- configuration.excludedBundleIDs = [notificationCenterBundleID]
+ // list taken now could name it. The same goes for the app's HUD, which is a new
+ // window after every trip through the editor: a pick made in Record mode, before
+ // that HUD exists, has to leave the app out whole to still be usable at Start (#996).
+ let appBundleID = NSRunningApplication(processIdentifier: getppid())?.bundleIdentifier
+ configuration.excludedBundleIDs = [notificationCenterBundleID] + [appBundleID].compactMap { $0 }
+ presentedExcludesApp = appBundleID != nil
let picker = SCContentSharingPicker.shared
picker.defaultConfiguration = configuration
@@ -158,6 +164,9 @@ final class PickerSession: NSObject, SCContentSharingPickerObserver, @unchecked
"height": frame.size.height,
],
"pointPixelScale": filter.pointPixelScale,
+ // Tells the app this pick also leaves out windows it opens later, so it need
+ // not ask again when the HUD comes back as a new one.
+ "excludesApp": presentedExcludesApp,
]
if let displayId {
event["displayId"] = displayId