-
Notifications
You must be signed in to change notification settings - Fork 22
fix(dgw): fix adaptive frame skipping during EOF waits in session shadowing #1678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,7 +99,7 @@ pub fn webm_stream( | |
| } | ||
| } | ||
|
|
||
| const MAX_RETRY_COUNT: usize = 3; | ||
| const MAX_RETRY_COUNT: usize = 25; | ||
| // To make sure we don't retry forever | ||
| // Retry is set to 0 when we successfully read a tag | ||
| let mut retry_count = 0; | ||
|
|
@@ -190,6 +190,10 @@ pub fn webm_stream( | |
| }, | ||
| _ = stop_notifier.notified() => { | ||
| let _ = tx.send(WhenEofControlFlow::Break); | ||
| }, | ||
| _ = tokio::time::sleep(std::time::Duration::from_secs(3)) => { | ||
| info!("EOF wait timed out, retrying"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Probably not a good idea to use an info! log at this place. I would suggest trace! unless you think debug! is better |
||
| let _ = tx.send(WhenEofControlFlow::Continue); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||
| use std::time::Instant; | ||||||||||||||
| use std::time::{Duration, Instant}; | ||||||||||||||
|
|
||||||||||||||
| use anyhow::Context; | ||||||||||||||
| use cadeau::xmf::vpx::{VpxCodec, VpxDecoder, VpxEncoder}; | ||||||||||||||
|
|
@@ -14,7 +14,7 @@ use crate::debug::mastroka_spec_name; | |||||||||||||
| const VPX_EFLAG_FORCE_KF: u32 = 0x00000001; | ||||||||||||||
|
|
||||||||||||||
| #[cfg(feature = "perf-diagnostics")] | ||||||||||||||
| fn duration_as_millis_u64(duration: std::time::Duration) -> u64 { | ||||||||||||||
| fn duration_as_millis_u64(duration: Duration) -> u64 { | ||||||||||||||
| u64::try_from(duration.as_millis()).unwrap_or(u64::MAX) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -105,7 +105,9 @@ where | |||||||||||||
| last_encoded_abs_time: Option<u64>, | ||||||||||||||
|
|
||||||||||||||
| // Adaptive frame skipping state | ||||||||||||||
| #[cfg(feature = "perf-diagnostics")] | ||||||||||||||
| stream_start: Instant, | ||||||||||||||
| processing_time: Duration, | ||||||||||||||
| last_ratio: f64, | ||||||||||||||
| frames_since_last_encode: u32, | ||||||||||||||
| adaptive_frame_skip: bool, | ||||||||||||||
|
|
@@ -192,7 +194,9 @@ where | |||||||||||||
| decoder, | ||||||||||||||
| cut_block_state: CutBlockState::HaventMet, | ||||||||||||||
| last_encoded_abs_time: None, | ||||||||||||||
| #[cfg(feature = "perf-diagnostics")] | ||||||||||||||
| stream_start: Instant::now(), | ||||||||||||||
| processing_time: Duration::ZERO, | ||||||||||||||
| last_ratio: 1.0, | ||||||||||||||
| frames_since_last_encode: 0, | ||||||||||||||
| adaptive_frame_skip: config.adaptive_frame_skip, | ||||||||||||||
|
|
@@ -263,7 +267,9 @@ where | |||||||||||||
| "VideoBlock created" | ||||||||||||||
| ); | ||||||||||||||
|
|
||||||||||||||
| let processing_started = Instant::now(); | ||||||||||||||
| self.process_current_block(&video_block)?; | ||||||||||||||
| self.processing_time += processing_started.elapsed(); | ||||||||||||||
|
|
||||||||||||||
| Ok(WriterResult::Continue) | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -371,11 +377,11 @@ where | |||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| // Calculates the ratio of media time advanced to active processing time. | |
| // This uses `processing_time`, which is intended to exclude idle waits (for example, | |
| // time spent waiting for file growth during EOF retries), so that temporary stalls | |
| // do not permanently corrupt the frame skip decision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MAX_RETRY_COUNT increase from 3 to 25 combined with the 3-second timeout per retry creates a maximum potential wait time of 75 seconds (25 × 3s). This seems excessive for a live streaming scenario. Consider either:
The original issue describes a 20-second EOF wait corrupting the ratio, but the fix allows up to 75 seconds of total wait time, which could still cause significant delays in live streaming scenarios.