Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Improve camera feed sender handling and logging
Richie McIlroy891b122a55f1
diff --git a/crates/recording/src/feeds/camera.rs b/crates/recording/src/feeds/camera.rsindex d75dde0b1..e8baae294 100644--- a/crates/recording/src/feeds/camera.rs+++ b/crates/recording/src/feeds/camera.rs@@ -577,6 +577,7 @@ impl Message<AddSender> for CameraFeed {type Reply = ();async fn handle(&mut self, msg: AddSender, _: &mut Context<Self, Self::Reply>) -> Self::Reply {+ debug!("CameraFeed: Adding new sender");self.senders.push(msg.0);}}@@ -624,6 +625,10 @@ impl Message<NewFrame> for CameraFeed {for (i, sender) in self.senders.iter().enumerate() {if let Err(flume::TrySendError::Disconnected(_)) = sender.try_send(msg.0.clone()) {warn!("Camera sender {} disconnected, will be removed", i);+ info!(+ "Camera sender {} disconnected (rx dropped), removing from list",+ i+ );to_remove.push(i);};}diff --git a/crates/recording/src/sources/camera.rs b/crates/recording/src/sources/camera.rsindex 48daae8e3..e60733ece 100644--- a/crates/recording/src/sources/camera.rs+++ b/crates/recording/src/sources/camera.rs@@ -22,7 +22,7 @@ impl VideoSource for Camera {whereSelf: Sized,{- let (tx, rx) = flume::bounded(8);+ let (tx, rx) = flume::bounded(32);feed_lock.ask(camera::AddSender(tx))@@ -30,9 +30,27 @@ impl VideoSource for Camera {.map_err(|e| anyhow!("Failed to add camera sender: {e}"))?;tokio::spawn(async move {- while let Ok(frame) = rx.recv_async().await {- let _ = video_tx.send(frame).await;+ tracing::debug!("Camera source task started");+ loop {+ match rx.recv_async().await {+ Ok(frame) => {+ if let Err(e) = video_tx.send(frame).await {+ tracing::warn!("Failed to send to video pipeline: {e}");+ // If pipeline is closed, we should stop?+ // But lets continue to keep rx alive for now to see if it helps,+ // or maybe break?+ // If we break, we disconnect from CameraFeed.+ // If pipeline is closed, we SHOULD disconnect.+ break;+ }+ }+ Err(e) => {+ tracing::debug!("Camera feed disconnected (rx closed): {e}");+ break;+ }+ }}+ tracing::debug!("Camera source task finished");});Ok(Self(feed_lock))