zed-industries/zed · error

Screen share failed: {}

Error message

Screen share failed: {}

What it means

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.

Source

Thrown at crates/gpui_macos/src/screen_capture.rs:254

    map
}

pub(crate) fn get_sources(
    marker: MainThreadMarker,
) -> oneshot::Receiver<Result<Vec<Rc<dyn ScreenCaptureSource>>>> {
    let (tx, rx) = oneshot::channel();
    let tx = Rc::new(RefCell::new(Some(tx)));
    let screen_id_to_label = screen_id_to_human_label(marker);

    let handler = RcBlock::new(
        move |content: *mut SCShareableContent, error: *mut NSError| {
            let Some(tx) = tx.borrow_mut().take() else {
                return;
            };

            let result = if let Some(error) = unsafe { error.as_ref() } {
                Err(anyhow!(
                    "Screen share failed: {}",
                    error.localizedDescription()
                ))
            } else if let Some(content) = unsafe { content.as_ref() } {
                // SAFETY: Marked unsafe conservatively by objc2
                let result = unsafe { content.displays() }
                    .into_iter()
                    .map(|display| {
                        // SAFETY: Marked unsafe conservatively by objc2
                        let id = unsafe { display.displayID() };
                        let metadata = screen_id_to_label.get(&id).cloned();
                        let source = MacScreenCaptureSource {
                            sc_display: display,
                            meta: metadata,
                        };
                        Rc::new(source) as Rc<dyn ScreenCaptureSource>
                    })
                    .collect::<Vec<_>>();

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Grant Screen Recording permission to the app in System Settings > Privacy & Security > Screen Recording, then restart the app.
  2. Read the wrapped localizedDescription for the precise ScreenCaptureKit error.
  3. Confirm the app runs on macOS 12.3+ where ScreenCaptureKit exists.
  4. Reset TCC permissions for the app (tccutil reset ScreenCapture) and re-grant.
  5. Re-sign/reinstall the app if permission grants stopped matching after a rebuild (changing signature invalidates grants).
Defensive patterns

Strategy: try-catch

Validate before calling

// Check screen recording permission before requesting shareable content (macOS 15+)
// or probe via CGRequestScreenCaptureAccess on older versions
let permitted = unsafe { CGPreflightScreenCaptureAccess() };

Try / catch

match get_sources() {
    Err(e) if e.to_string().starts_with("Screen share failed:") => {
        if !unsafe { CGPreflightScreenCaptureAccess() } {
            prompt_user_to_grant_screen_recording_permission();
        } else {
            log::error!("ScreenCaptureKit error: {e}");
        }
    }
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12). Data as JSON: /api/errors/2ec1ff44f14b52e3. Report an issue: GitHub.