Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Increase SCK queue depth to avoid timeouts (#1344)
Brendan Allan79aa1ba23f9d
diff --git a/crates/recording/src/sources/screen_capture/macos.rs b/crates/recording/src/sources/screen_capture/macos.rsindex 4cc228a41..2482d49ab 100644--- a/crates/recording/src/sources/screen_capture/macos.rs+++ b/crates/recording/src/sources/screen_capture/macos.rs@@ -68,7 +68,8 @@ impl ScreenCaptureConfig<CMSampleBufferCapture> {&self,) -> anyhow::Result<(VideoSourceConfig, Option<SystemAudioSourceConfig>)> {let (error_tx, error_rx) = broadcast::channel(1);- let (video_tx, video_rx) = flume::bounded(4);+ // Increased from 4 to 12 to provide more buffer tolerance for frame processing delays+ let (video_tx, video_rx) = flume::bounded(12);let (mut audio_tx, audio_rx) = if self.system_audio {let (tx, rx) = mpsc::channel(32);(Some(tx), Some(rx))@@ -128,12 +129,16 @@ impl ScreenCaptureConfig<CMSampleBufferCapture> {debug!("size: {:?}", size);+ let queue_depth = ((self.config.fps as f32 / 30.0 * 5.0).ceil() as isize).clamp(3, 8);+ debug!("Using queue depth: {}", queue_depth);+let mut settings = scap_screencapturekit::StreamCfgBuilder::default().with_width(size.width() as usize).with_height(size.height() as usize).with_fps(self.config.fps as f32).with_shows_cursor(self.config.show_cursor).with_captures_audio(self.system_audio)+ .with_queue_depth(queue_depth).build();settings.set_pixel_format(cv::PixelFormat::_32_BGRA);diff --git a/crates/scap-screencapturekit/src/config.rs b/crates/scap-screencapturekit/src/config.rsindex 5787959c7..e99e4a9a7 100644--- a/crates/scap-screencapturekit/src/config.rs+++ b/crates/scap-screencapturekit/src/config.rs@@ -35,6 +35,13 @@ impl StreamCfgBuilder {self.0.set_captures_audio(captures_audio);}+ /// Sets the queue depth (number of frames to buffer).+ /// Higher values provide more tolerance for processing delays but use more memory.+ /// Apple's default is 3. Maximum is 8.+ pub fn set_queue_depth(&mut self, depth: isize) {+ self.0.set_queue_depth(depth.min(8));+ }+/// Logical width of the capture areapub fn with_width(mut self, width: usize) -> Self {self.set_width(width);@@ -68,6 +75,11 @@ impl StreamCfgBuilder {self}+ pub fn with_queue_depth(mut self, depth: isize) -> Self {+ self.set_queue_depth(depth);+ self+ }+pub fn build(self) -> arc::R<sc::StreamCfg> {self.0}