From 2eb58205a9ad5571393e9bb84a74c0282c0d0564 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 09:28:44 -0700 Subject: [PATCH 1/2] chore(quest): claim quest/m1/test-flakes-2/go-reservation-grant.md Quest-Claim: e4e4180a3ab25ac3 From 5edc80c1ae0953bea2d47ba9b51405ef1cee751f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 24 Oct 2026 09:56:55 -0700 Subject: [PATCH 2/2] fix(net): publish the send estimate before the connect A client could observe a connect before the session's send estimate reached the persistent allocator, so reservation grants read None right after connecting. Seed the session's estimate producer with its first sample, and seed the connection's persistent estimate before publishing the connect. Co-Authored-By: Claude Opus 5.5 --- quest/m1/test-flakes-2/README.md | 1 - quest/m1/test-flakes-2/go-reservation-grant.md | 16 ---------------- rs/moq-ffi/src/session/dial.rs | 2 ++ rs/moq-net/src/client.rs | 7 ++++++- rs/moq-net/src/session.rs | 4 ++++ rs/moq-tokio/src/connection.rs | 5 ++++- 6 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 quest/m1/test-flakes-2/go-reservation-grant.md diff --git a/quest/m1/test-flakes-2/README.md b/quest/m1/test-flakes-2/README.md index 1d9391c3868..400ec04cb08 100644 --- a/quest/m1/test-flakes-2/README.md +++ b/quest/m1/test-flakes-2/README.md @@ -44,4 +44,3 @@ Public API: none. Wire: none. - [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 - [Interop timestamp gap](/quest/m1/test-flakes-2/interop-timestamp-gap.md) - `rust -> js-native-node` audio has no gap under load -- [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 1f304165902..1e1a39a98f4 100644 --- a/rs/moq-ffi/src/session/dial.rs +++ b/rs/moq-ffi/src/session/dial.rs @@ -221,6 +221,8 @@ async fn run( return; } }; + // 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(), driver: crate::ffi::Background::default(), diff --git a/rs/moq-net/src/client.rs b/rs/moq-net/src/client.rs index 57041fc606b..3071a7289b3 100644 --- a/rs/moq-net/src/client.rs +++ b/rs/moq-net/src/client.rs @@ -1095,9 +1095,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 45e2b810b7d..47d2f0f4897 100644 --- a/rs/moq-net/src/session.rs +++ b/rs/moq-net/src/session.rs @@ -172,6 +172,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) } @@ -368,8 +369,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 6ceffff789c..5624e07e4da 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -634,6 +634,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() { auth::replay(&state, session, state.connects + 1); // A migration replaces a live session without a disconnect in between, so @@ -1479,7 +1482,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() }