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): don't content-protect windows on macOS 26 — it makes them invisible

Etienne Lescotad8fef3aa6b6
diff --git a/AGENTS.md b/AGENTS.md
index b4b873979..1f1a63d40 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -60,6 +60,7 @@ Unit/browser tests can't exercise real capture (native screen recording, a physi
**The HUD widget** (recording controller)
- **It is invisible in screenshots by default.** The HUD (and the Notes window) call `setContentProtection(true)` so the recording controls never end up baked into a recording — the same `SetWindowDisplayAffinity` that WGC honours also hides them from *your* screenshots. The window is there, and clicks land, but you are aiming blind at a rectangle you cannot see. Set **`OPENSCREEN_DISABLE_CONTENT_PROTECTION=1`** in the app's environment to turn it off for a session; every skipped window logs a warning. Unset it before recording anything real, or the HUD ends up in the video.
+- **On macOS 26+ content protection is auto-disabled, so the HUD *is* visible and screenshottable with no flag.** That OS never displays a content-protected window at all — not just absent from captures, but never painted, leaving a tray icon, a live renderer and nothing on screen (confirmed on macOS 26.5 / Electron 41.2.1). `applyContentProtection` therefore skips the call there and logs a warning per window; the trade-off is that the HUD can appear in recordings on that OS until the ScreenCaptureKit helper excludes our own windows via `SCContentFilter(excludingWindows:)`, which it currently passes as `[]`. `OPENSCREEN_FORCE_CONTENT_PROTECTION=1` re-enables it to re-test against a future Electron.
- The HUD is what opens the editor (clapper icon, tooltip *Open Studio*), so without that flag a whole slice of the app is unreachable from automation: killing the app to redeploy a native addon leaves you unable to reopen a project.
- Frameless, transparent, always-on-top, `skipTaskbar`, centered at the **bottom of the primary display** (`createHudOverlayWindow`, 600×160). It is **click-through** (`setIgnoreMouseEvents(true, { forward: true })`): moving the real cursor over an interactive control makes that region clickable and shows its tooltip, so `mouse_move` → screenshot → `left_click` works; a blind click on empty HUD area passes through to the desktop.
- Control row (left→right): layout preset, **source** button (`Screen`/`Window` → label becomes the picked source), system-audio toggle, mic toggle, **webcam toggle** (shows the detected camera name), cursor-highlight toggle, **record**, notes, open-editor, language, minimize, close. The record button is disabled until a source is chosen (tooltip: "Please select a source to record").
diff --git a/electron/windows.ts b/electron/windows.ts
index 129eb8757..32046fe36 100644
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@ -19,6 +19,49 @@ const HEADLESS = process.env["HEADLESS"] === "true";
// while it is set WILL contain the HUD.
const CONTENT_PROTECTION_DISABLED = process.env["OPENSCREEN_DISABLE_CONTENT_PROTECTION"] === "1";
+// Forces protection back on where it is auto-disabled below, so the macOS
+// regression can be re-tested against a future Electron without editing code.
+const CONTENT_PROTECTION_FORCED = process.env["OPENSCREEN_FORCE_CONTENT_PROTECTION"] === "1";
+
+/**
+ * macOS 26 (Darwin 25) never displays a window that has had
+ * `setContentProtection(true)` applied to it.
+ *
+ * Not "excludes it from captures" — which is the documented behaviour and the
+ * whole point — but never paints it for the user either. Confirmed on Darwin
+ * 25.5 / Electron 41.2.1 with the HUD: tray icon present, renderer alive and
+ * painting (React mounted, no console errors), `ready-to-show` fired, `show()`
+ * called, window at valid on-screen coordinates on the main display — and
+ * nothing on screen. `showMainWindow()` from the tray and the global shortcut
+ * were equally inert, because the window was already "visible" as far as
+ * Electron was concerned. Unsetting protection makes it appear instantly; the
+ * ordering of protect-vs-show makes no difference, so it is the call itself.
+ *
+ * `setContentProtection` maps to `NSWindow.sharingType = NSWindowSharingNone`,
+ * a path Electron has repeatedly churned on (electron/electron#45990, and
+ * PR #46886 reverting a macOS content-protection refactor).
+ *
+ * Gated on the Darwin major version rather than `darwin` wholesale: the
+ * breakage is only *confirmed* on 25.x, and silently dropping protection on
+ * older macOS — where it may well work — would be a privacy regression made on
+ * no evidence.
+ *
+ * NOTE: this leaves the HUD capturable on macOS 26. Apple already made that
+ * partly true regardless — ScreenCaptureKit ignores `sharingType`, so any
+ * SCK-based recorder (including *ours*, see
+ * `electron/native/screencapturekit/`) captures these windows anyway. The
+ * durable fix is to exclude our own windows via `SCContentFilter`'s
+ * `excludingWindows:`, which that helper currently passes as `[]`.
+ */
+const CONTENT_PROTECTION_BREAKS_DISPLAY = (() => {
+ if (process.platform !== "darwin") return false;
+ // getSystemVersion() reports the *macOS* version on darwin, not the Darwin
+ // kernel version: measured "26.5.0" here where `os.release()` is "25.5.0".
+ // So the affected major is 26, and the check must not be fed os.release().
+ const macOSMajor = Number.parseInt(process.getSystemVersion().split(".")[0] ?? "", 10);
+ return Number.isFinite(macOSMajor) && macOSMajor >= 26;
+})();
+
function applyContentProtection(win: BrowserWindow, label: string) {
if (CONTENT_PROTECTION_DISABLED) {
console.warn(
@@ -28,6 +71,15 @@ function applyContentProtection(win: BrowserWindow, label: string) {
);
return;
}
+ if (CONTENT_PROTECTION_BREAKS_DISPLAY && !CONTENT_PROTECTION_FORCED) {
+ console.warn(
+ `[content-protection] OFF for the ${label} window — macOS ` +
+ `${process.getSystemVersion()} never displays a content-protected window, so ` +
+ "enabling it would make this window permanently invisible. It may therefore appear " +
+ "in screen captures. Set OPENSCREEN_FORCE_CONTENT_PROTECTION=1 to re-test.",
+ );
+ return;
+ }
win.setContentProtection(true);
}