fix(macOS): add NSScreenCaptureUsageDescription and screen-capture entitlement#554
Conversation
…titlement Without NSScreenCaptureUsageDescription in Info.plist, macOS silently blocks desktopCapturer.getSources(), breaking window detection on macOS 10.15+. Also adds the com.apple.security.device.screen-capture entitlement to macos.entitlements alongside the existing camera and audio-input entries. Fixes siddharthvaddem#548
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds the missing macOS screen recording permission infrastructure—the OS entitlement that enables the capability and the user-facing permission description string. These changes directly address window detection failures on macOS by properly declaring the required permissions. ChangesmacOS Screen Recording Permissions
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What
Fixes #548
Adds the missing
NSScreenCaptureUsageDescriptionkey to the macOSextendInfoblock inelectron-builder.json5, and adds thecom.apple.security.device.screen-captureentitlement tomacos.entitlements.Root cause
macOS 10.15+ enforces TCC (Transparency, Consent, and Control) for screen recording. When an app calls
desktopCapturer.getSources(), the OS checks forNSScreenCaptureUsageDescriptioninInfo.plistto show the permission prompt. If the key is absent, the API fails silently — no error, no prompt, no sources returned — causing window detection to break completely.All other permission keys were already present:
NSAudioCaptureUsageDescriptionNSMicrophoneUsageDescriptionNSCameraUsageDescriptionNSScreenCaptureUsageDescription← was missingChanges
electron-builder.json5— one line added tomac.extendInfo:macos.entitlements— one entitlement added alongside the existingcameraandaudio-inputentries:Testing
Build the macOS DMG and launch on a clean macOS 10.15+ machine (or one where OpenScreen has not previously been granted screen recording access). On first launch, macOS should now display the screen recording permission prompt. Once granted,
desktopCapturer.getSources()returns window sources and window detection works correctly.Summary by CodeRabbit