From c080b5f6530086955711226d00cd21dccb6a11f9 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Fri, 16 Oct 2026 11:47:58 +0800 Subject: [PATCH] Do not report a viewer-closed desktop stream as an error The final send after the viewer closes fails with "codec is not supported by remote", which read like an encoder negotiation bug. Co-Authored-By: Claude Opus 5.5 --- src/webrtc.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/webrtc.rs b/src/webrtc.rs index 2ff47f9..dad5009 100644 --- a/src/webrtc.rs +++ b/src/webrtc.rs @@ -273,9 +273,15 @@ impl WebRtcSession { let control_video_track = video_track.clone(); let stream_settings = video_settings.clone(); if desktop { + let state_pc = streaming_pc.clone(); tokio::spawn(async move { if let Err(e) = crate::video::stream_desktop(streaming_pc, video_track, capture_size, capture_display, portal, video_settings_rx, stream_settings, idr_request).await { - log::error!("Live desktop stream stopped: {}", e); + // A send racing the viewer's close fails with a misleading track error. + if matches!(state_pc.connection_state(), RTCPeerConnectionState::Closed | RTCPeerConnectionState::Failed) { + log::info!("Live desktop stream ended: peer connection closed ({})", e); + } else { + log::error!("Live desktop stream stopped: {}", e); + } } }); } else {