fix(video-streamer): improve unified shutdown correctness#1703
Conversation
Let maintainers know that an action is required on their side
|
…ion shadowing The existing keyframe detection only handled VP8 frames. This adds proper VP9 keyframe detection based on the VP9 bitstream specification, supporting all profiles (0-3). The codec type is now threaded through the iterator and block tag layers so keyframe checks use the correct codec-specific logic. Also sets VpxEncoderPreset::BestPerformance for improved re-encoding throughput. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Replace scattered shutdown mechanisms (Arc<Notify> stop_notifier, mpsc error channel, implicit channel close, handle.abort()) with a single tokio::sync::watch channel as the source of truth. Key changes: - Add StreamShutdown enum (Running/ClientDisconnected/ExternalShutdown/Error) - Bridge external Arc<Notify> into watch channel at webm_stream level - Handle task now signals ClientDisconnected on client disconnect - Handle task uses select! on ws_frame.next() for shutdown awareness - Handle task best-effort delivers ServerMessage::End before socket shutdown - control_task simplified to single shutdown_rx.changed() await - Abort bridge task on webm_stream exit to prevent control_task hang - Add tokio "time" feature (was missing, pre-existing issue) Co-Authored-By: Claude Opus 4.6 <[email protected]>
9a35416 to
b60bd2a
Compare
- Send Error (not End) to client when shutdown is caused by a stream error - Use AbortOnDrop guard for bridge task to handle early returns/bails - Remove dead UserFriendlyError::UnexpectedEOF variant Co-Authored-By: Claude Opus 4.6 <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR refactors the video-streamer shutdown orchestration to use a single tokio::sync::watch channel as the “source of truth”, aiming to eliminate scattered shutdown/error mechanisms and improve task shutdown behavior (including awareness of silent clients and disconnects).
Changes:
- Replace mixed shutdown/error signaling with a unified
watch-basedStreamShutdownstate. - Update sending/control tasks to react to shutdown via
select!and propagate client disconnects into shutdown state. - Enable Tokio’s
timefeature to support newtokio::time::*usage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
crates/video-streamer/src/streamer/protocol.rs |
Adjust UserFriendlyError traits/variants for use in shutdown signaling. |
crates/video-streamer/src/streamer/mod.rs |
Introduce StreamShutdown watch channel; refactor tasks to use it and improve shutdown coordination. |
crates/video-streamer/Cargo.toml |
Add Tokio time feature required by new timeouts/sleeps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Benoît Cortier (CBenoit)
left a comment
There was a problem hiding this comment.
LGTM. I also asked another review batch from Copilot.
|
Note: if you use |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
9e417f9
into
master
Summary
Arc<Notify>stop_notifier,mpscerror channel, implicit channel close,handle.abort()) with a singletokio::sync::watchchannel as the source of truthClientDisconnectedon client disconnect (was silent before)select!onws_frame.next()for shutdown awareness (no longer blocks on silent clients)ServerMessage::Endbefore socket shutdownwebm_streamexit to preventcontrol_taskfrom hanging indefinitelytimefeature (pre-existing issue)🤖 Generated with Claude Code