zed-industries/zed · error

failed to add stream output {message:?}

Error message

failed to add stream output {message:?}

What it means

Guard in MacScreenCaptureSource::stream: SCStream.addStreamOutput(_:type:sampleHandlerQueue:) returned an error, so the capture stream has no frame receiver attached and cannot deliver frames. {message:?} is the NSError from ScreenCaptureKit; commonly a delegate/queue or content-filter problem.

Source

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

            let _: id = msg_send![configuration, setWidth: meta.resolution.width.0 as i64];
            let _: id = msg_send![configuration, setHeight: meta.resolution.height.0 as i64];
            let stream: id = msg_send![stream, initWithFilter:filter configuration:configuration delegate:delegate];

            // Stream contains filter, configuration, and delegate internally so we release them here
            // to prevent a memory leak when steam is dropped
            let _: () = msg_send![filter, release];
            let _: () = msg_send![configuration, release];
            let _: () = msg_send![delegate, release];

            let (tx, rx) = oneshot::channel();

            let mut error: id = nil;
            let _: () = msg_send![stream, addStreamOutput:output type:SCStreamOutputTypeScreen sampleHandlerQueue:0 error:&mut error as *mut id];
            if error != nil {
                let message: id = msg_send![error, localizedDescription];
                let _: () = msg_send![stream, release];
                let _: () = msg_send![output, release];
                tx.send(Err(anyhow!("failed to add stream output {message:?}")))
                    .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];

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Verify the SCContentFilter and SCStreamConfiguration are valid before addStreamOutput
  2. Ensure the sample-handler queue is non-nil and the delegate retained for the stream lifetime
  3. Check ScreenCaptureKit authorization (CGPreflightScreenCaptureAccess) before creating streams
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_macos/src/screen_capture.rs:126 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/892126df18007693. Report an issue: GitHub.