zed-industries/zed · error

failed to start screen capture stream {message:?}

Error message

failed to start screen capture stream {message:?}

What it means

Guard in the stream start completion handler: SCStream.startCapture finished with a non-nil NSError, so the screen capture stream never began producing frames. {message:?} carries ScreenCaptureKit's failure reason (e.g. user stopped sharing, display removed).

Source

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

                    .ok();
                return rx;
            }

            let tx = Rc::new(RefCell::new(Some(tx)));
            let handler = ConcreteBlock::new({
                move |error: id| {
                    let result = if error == nil {
                        let stream = MacScreenCaptureStream {
                            meta: meta.clone(),
                            sc_stream: stream,
                            sc_stream_output: output,
                        };
                        Ok(Box::new(stream) as Box<dyn ScreenCaptureStream>)
                    } else {
                        let _: () = msg_send![stream, release];
                        let _: () = msg_send![output, release];
                        let message: id = msg_send![error, localizedDescription];
                        Err(anyhow!("failed to start screen capture stream {message:?}"))
                    };
                    if let Some(tx) = tx.borrow_mut().take() {
                        tx.send(result).ok();
                    }
                }
            });
            let handler = handler.copy();
            let _: () = msg_send![stream, startCaptureWithCompletionHandler:handler];
            rx
        }
    }
}

impl ScreenCaptureStream for MacScreenCaptureStream {
    fn metadata(&self) -> Result<SourceMetadata> {
        Ok(self.meta.clone())
    }
}

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Inspect the NSError code; invalidate and rebuild the stream when displays change
  2. Re-prompt for screen-recording permission if the error indicates denial
  3. Deliver the error through the oneshot receiver so the caller shows a capture-failed state
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_macos/src/screen_capture.rs:145 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20). Data as JSON: /api/errors/6fd91405ad0f4d1b. Report an issue: GitHub.