diff --git a/quest/m1/test-flakes-2/README.md b/quest/m1/test-flakes-2/README.md index d1a4566ad24..e481f0aaa02 100644 --- a/quest/m1/test-flakes-2/README.md +++ b/quest/m1/test-flakes-2/README.md @@ -43,4 +43,3 @@ Public API: none. Wire: none. - [Media resource instrumentation](/quest/m1/test-flakes-2/resource-instrumentation.md) - the media test stops seeing a playing player report nothing to release - [Tone check grace](/quest/m1/test-flakes-2/tone-grace.md) - the interop tone check charges its grace only for audible playback, so a refilling ring under CPU starvation is not a failure - [IETF22 fallback](/quest/m1/test-flakes-2/ietf22-fallback.md) - an IETF22 browser viewer follows a fallback within the media lane's bound, keeping its session and its audio -- [Go reservation grant](/quest/m1/test-flakes-2/go-reservation-grant.md) - the Go reservation test waits for its grant diff --git a/quest/m1/test-flakes-2/go-reservation-grant.md b/quest/m1/test-flakes-2/go-reservation-grant.md deleted file mode 100644 index 7771e740351..00000000000 --- a/quest/m1/test-flakes-2/go-reservation-grant.md +++ /dev/null @@ -1,16 +0,0 @@ -# [XS] The Go reservation test waits for a grant - -## Goal - -`TestReservationUpdateReleasesSubscribedTrack` (`go/wrapper/bandwidth_test.go`) -never fails with "grant unavailable". - -## Plan - -`Reservation.Grant()` returns nothing until the QUIC estimate exists, and the -test asserts right after `Dial`. Seen under load in -[moq-dev/moq#6476](https://github.com/moq-dev/moq/pull/6476) and -[moq-dev/moq#6517](https://github.com/moq-dev/moq/pull/6517). Wait on the -grant's own signal rather than a sleep. - -Public API: none. Wire: none. diff --git a/rs/moq-ffi/src/session/dial.rs b/rs/moq-ffi/src/session/dial.rs index 541684b31a4..d2a721041a7 100644 --- a/rs/moq-ffi/src/session/dial.rs +++ b/rs/moq-ffi/src/session/dial.rs @@ -242,6 +242,8 @@ async fn run( return err; } }; + // Before the session publishes, so a watcher that sees it already reads its estimate. + let _ = send.set(session.send_bandwidth().and_then(|bw| bw.peek())); published.session = Some(Accepted { session: session.clone(), }); diff --git a/rs/moq-net/src/client.rs b/rs/moq-net/src/client.rs index 253d7c0aeef..be90008de04 100644 --- a/rs/moq-net/src/client.rs +++ b/rs/moq-net/src/client.rs @@ -1225,9 +1225,14 @@ mod tests { let client = Client::new().with_versions(Version::Lite(lite::Version::Lite04).into()); let (session, driver) = client.connect(moq_clock::now(), fake.clone()).await.unwrap(); + let mut bandwidth = session.send_bandwidth().expect("backend reports an estimate"); + assert_eq!( + bandwidth.peek(), + Some(crate::bandwidth::Rate::from_bps(1_000_000)), + "the estimate is readable before the sampler first runs" + ); moq_clock::sim::spawn(crate::time::run(driver)); - let mut bandwidth = session.send_bandwidth().expect("backend reports an estimate"); assert_eq!( bandwidth.changed().await.unwrap(), Some(crate::bandwidth::Rate::from_bps(1_000_000)) diff --git a/rs/moq-net/src/session.rs b/rs/moq-net/src/session.rs index efa3c0b7cb6..4a0bafec220 100644 --- a/rs/moq-net/src/session.rs +++ b/rs/moq-net/src/session.rs @@ -210,6 +210,7 @@ impl Session { /// Returns a consumer for the estimated send bitrate (from the congestion controller). /// /// Returns `None` if the QUIC backend doesn't support bandwidth estimation. + /// Otherwise it holds an estimate from the start, the session's first sample. pub fn send_bandwidth(&self) -> Option { self.send_bandwidth.as_ref().map(bandwidth::Weak::consume) } @@ -415,8 +416,11 @@ impl Session { } // Send bandwidth is version-agnostic: it depends on QUIC backend support. + // Seeded with the first sample, so a consumer taken before the sampler + // first runs reads the estimate instead of `None`. let (send_bandwidth, send_producer) = if sample.estimated_send_rate.is_some() { let producer = bandwidth::Producer::new(); + let _ = producer.set(sample.estimated_send_rate); (Some(producer.weak()), Some(producer)) } else { (None, None) diff --git a/rs/moq-tokio/src/connection.rs b/rs/moq-tokio/src/connection.rs index d21d9554728..24eb9cf367a 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -625,6 +625,9 @@ impl Shared { session.abort(err.clone()); return; } + // Before the state publishes, so a watcher that sees this connect already + // reads its estimate, and the grants that divide it. + let _ = self.send_bw.set(session.send_bandwidth().and_then(|bw| bw.peek())); if let Ok(mut state) = self.state.write() { // A migration replaces a live session without a disconnect in between, so // its end is counted here, keeping `started - ended` at 1 while connected. @@ -1489,7 +1492,7 @@ impl Connection { /// /// Unlike the session's, this handle is persistent: the reconnect loop forwards each session's /// estimate into it, so it survives reconnects. Its value is `None` while disconnected or when the - /// backend has no estimate. + /// backend has no estimate, and is already set when a watcher sees the connect. pub fn send_bandwidth(&self) -> BandwidthConsumer { self.send_bandwidth.clone() }