zed-industries/zed · error
Screen share failed
Error message
Screen share failed
What it means
In get_sources, the SCShareableContent completion handler receives mutually exclusive content/error pointers. If neither is present (both null), the code concludes the callback is in an impossible state and returns this bare error. The comment notes the two pointers are mutually exclusive, so this path should never occur in practice.
Source
Thrown at crates/gpui_macos/src/screen_capture.rs:277
// 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<_>>();
Ok(result)
} else {
// The two pointers are mutually exclusive, this should never happen
Err(anyhow!("Screen share failed"))
};
_ = tx.send(result);
},
);
unsafe {
SCShareableContent::getShareableContentExcludingDesktopWindows_onScreenWindowsOnly_completionHandler(true, true, &handler);
}
rx
}
#[ctor(unsafe)]
unsafe fn build_classes() {
let mut decl = ClassDecl::new("GPUIStreamDelegate", class!(NSObject)).unwrap();
unsafe {
decl.add_method(View on GitHub (pinned to 9d272b0363)
Solutions
- Retry get_sources; a one-off malformed callback usually succeeds on retry.
- Grant Screen Recording permission and retry, since odd framework states often stem from permission gaps.
- Update macOS — ScreenCaptureKit behavior bugs are fixed in point releases.
- If reproducible, file a bug with Apple including the macOS version and repro steps.
Defensive patterns
Strategy: retry
Try / catch
match get_sources() {
Err(e) if e.to_string() == "Screen share failed" => {
// Should be unreachable; retry once and report if it persists
match get_sources() {
Ok(v) => Ok(v),
Err(e2) => { report_screencapturekit_bug(e2); Err(e2) }
}
}
other => other,
} Prevention
- Treat this as a ScreenCaptureKit contract violation; retry once and escalate if persistent.
- Keep macOS updated so known ScreenCaptureKit bugs are patched.
- Grant Screen Recording permission first to avoid odd framework states.
- Log macOS version and repro details when this fires to support a framework bug report.
When it happens
Trigger: The ScreenCaptureKit completion callback fires with both the SCShareableContent pointer and the NSError pointer null — a defensive catch-all for a malformed/inconsistent ScreenCaptureKit response.
Common situations: Potential ScreenCaptureKit framework bugs or edge cases in unusual session states; theoretically unreachable in normal operation; encountered only if macOS violates its documented callback contract.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Screen share failed: {}
- Failed to get active display list. Result: {result}
- RealtimeAudio priority should use spawn_realtime, not dispat
- Failed to register: {}
- Device lost: {err}
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/deed56555c0b266e.
Report an issue: GitHub.