{"record":{"id":"2ec1ff44f14b52e3","repo":"zed-industries/zed","slug":"screen-share-failed-capture","errorCode":null,"errorMessage":"Screen share failed: {}","messagePattern":"Screen share failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_macos/src/screen_capture.rs","lineNumber":254,"sourceCode":"\n    map\n}\n\npub(crate) fn get_sources(\n    marker: MainThreadMarker,\n) -> oneshot::Receiver<Result<Vec<Rc<dyn ScreenCaptureSource>>>> {\n    let (tx, rx) = oneshot::channel();\n    let tx = Rc::new(RefCell::new(Some(tx)));\n    let screen_id_to_label = screen_id_to_human_label(marker);\n\n    let handler = RcBlock::new(\n        move |content: *mut SCShareableContent, error: *mut NSError| {\n            let Some(tx) = tx.borrow_mut().take() else {\n                return;\n            };\n\n            let result = if let Some(error) = unsafe { error.as_ref() } {\n                Err(anyhow!(\n                    \"Screen share failed: {}\",\n                    error.localizedDescription()\n                ))\n            } else if let Some(content) = unsafe { content.as_ref() } {\n                // SAFETY: Marked unsafe conservatively by objc2\n                let result = unsafe { content.displays() }\n                    .into_iter()\n                    .map(|display| {\n                        // SAFETY: Marked unsafe conservatively by objc2\n                        let id = unsafe { display.displayID() };\n                        let metadata = screen_id_to_label.get(&id).cloned();\n                        let source = MacScreenCaptureSource {\n                            sc_display: display,\n                            meta: metadata,\n                        };\n                        Rc::new(source) as Rc<dyn ScreenCaptureSource>\n                    })\n                    .collect::<Vec<_>>();","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_macos/src/screen_capture.rs#L236-L272","documentation":"get_sources in the macOS screen-capture implementation calls SCShareableContent.getCompletionHandler; if ScreenCaptureKit returns an NSError the localized description is wrapped as \"Screen share failed: {description}\". It means macOS could not enumerate shareable content (displays/windows) for screen sharing.","triggerScenarios":"Requesting shareable content via get_sources when the SCShareableContent completion handler receives an error: missing Screen Recording permission, running on an unsupported macOS version, or ScreenCaptureKit failing internally.","commonSituations":"Screen Recording permission not granted (or revoked) in System Settings > Privacy & Security; running on macOS < 12.3 where ScreenCaptureKit is unavailable; TCC database inconsistencies after app updates or re-signing.","solutions":["Grant Screen Recording permission to the app in System Settings > Privacy & Security > Screen Recording, then restart the app.","Read the wrapped localizedDescription for the precise ScreenCaptureKit error.","Confirm the app runs on macOS 12.3+ where ScreenCaptureKit exists.","Reset TCC permissions for the app (tccutil reset ScreenCapture) and re-grant.","Re-sign/reinstall the app if permission grants stopped matching after a rebuild (changing signature invalidates grants)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check screen recording permission before requesting shareable content (macOS 15+)\n// or probe via CGRequestScreenCaptureAccess on older versions\nlet permitted = unsafe { CGPreflightScreenCaptureAccess() };","typeGuard":null,"tryCatchPattern":"match get_sources() {\n    Err(e) if e.to_string().starts_with(\"Screen share failed:\") => {\n        if !unsafe { CGPreflightScreenCaptureAccess() } {\n            prompt_user_to_grant_screen_recording_permission();\n        } else {\n            log::error!(\"ScreenCaptureKit error: {e}\");\n        }\n    }\n    other => other?,\n}","preventionTips":["Pre-flight Screen Recording permission (CGPreflightScreenCaptureAccess) and guide users to System Settings.","Require macOS 12.3+ before using ScreenCaptureKit-based APIs.","Reset TCC (tccutil reset ScreenCapture) when grants stop applying after rebuilds/re-signs.","Restart the app after the user grants permission; grants are not applied retroactively to running processes."],"tags":["macos","screen-capture","permissions","screencapturekit","gpui"],"backgroundTag":"permission-denied","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}