diff --git a/quest/m1/README.md b/quest/m1/README.md index 1f21f64ea8b..4ff0eb71cba 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -147,7 +147,6 @@ removed). - [moq-quic's API improves on quinn's](/quest/m1/quic-api/README.md) - moq-quic and both QUIC drivers ship one mirrored API: `send::`/`recv::` namespaces, one error per direction, consuming terminal operations, plain configs, no quinn baggage - [On-demand JavaScript FETCH](/quest/m1/js-fetch-on-demand.md) - browser publishers answer IETF FETCH for evicted or uncached groups through the JS ranges request surface - [Rust cancels an unclaimed fill head when a subscription ends](/quest/m1/ietf-fill-end-cancel.md) - SUBSCRIPTION_ENDED cancels, not finishes, a fill no group was sent for, as in JS -- [A resumed untimed copy keeps DYNAMIC_GROUPS](/quest/m1/ietf-dynamic-groups-resume.md) - opting out of properties on a draft-22 resume no longer forgets DYNAMIC_GROUPS - [Rust marks a lost listed group unknown](/quest/m1/ietf-publisher-unknown-range.md) - the Rust IETF publisher sends End of Unknown Range for a listed group it can't serve, after the publisher's open quests land - [Native rung disable](/quest/m1/simulcast-rung-disable.md) - OBS stops sending the top renditions its grant cannot fund, as the Rust/FFI publishers do, and a shaped uplink through moq-ffi proves the resume - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the playout target is default in both languages; a manual browser proof and a native trace replay remain diff --git a/quest/m1/ietf-dynamic-groups-resume.md b/quest/m1/ietf-dynamic-groups-resume.md deleted file mode 100644 index e534c2a5ccb..00000000000 --- a/quest/m1/ietf-dynamic-groups-resume.md +++ /dev/null @@ -1,14 +0,0 @@ -# [XS] A resumed untimed copy keeps DYNAMIC_GROUPS - -## Goal - -On moq-transport draft 22, a resumed copy of an untimed track that opts out of -Track Properties still knows the track's DYNAMIC_GROUPS, as its first -subscription did. - -## Plan - -Found in [moq-dev/moq#7085](https://github.com/moq-dev/moq/pull/7085): opting -out of properties on resume drops DYNAMIC_GROUPS along with TIMESCALE. Carry -it from the first subscription, or keep asking for it when the track has it. -Add a resume test on draft 22. diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index ee458ded782..cf96ba117e0 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -757,7 +757,9 @@ struct Idle { /// Serves its cache misses with a group FETCH, subscribed or not. dynamic: track::Requests, demand: track::Demand, - timescale: Option, + /// The Track Properties the publisher declared for the copy. A resumed SUBSCRIBE that + /// opts out of them is answered without them, so the copy keeps these. + properties: ietf::Properties, /// The publisher ended the track, so a returning subscriber reads the copy as it is. finished: bool, } @@ -3144,6 +3146,11 @@ impl Subscriber { let order = aggregate.map(|s| s.order).unwrap_or_default(); // Without an Established subscription, a relay includes the request it holds. let new_group = target.new_group(); + // A timed copy asks for the units that opt its objects into timestamps. + let properties_wanted = match &target { + Target::Request(_) => true, + Target::Resume(idle) => idle.properties.timescale.is_some(), + }; // Buffered only: the wait for the answer flushes it, so the local terminals still end a // request the peer's send window holds back. let written = match &held { @@ -3174,13 +3181,7 @@ impl Subscriber { group_order: order.into(), filter: join.filter, fill: join.fill, - // A resumed copy already knows the track, from the answer that accepted - // it, but only a TIMESCALE in this answer opts its objects into the - // timestamps a timed copy reads. - properties_wanted: match &target { - Target::Request(_) => true, - Target::Resume(idle) => idle.timescale.is_some(), - }, + properties_wanted, forward: true, rendezvous: false, range_filters: false, @@ -3406,8 +3407,15 @@ impl Subscriber { properties, largest, } = accepted; - // The objects are stamped in the units the answer declares. A timed copy asked for - // them; an untimed one that opted out has none to keep. + // A resumed SUBSCRIBE opts out of the properties from draft-22, so its answer carries + // none and the copy keeps the ones it learned. Before that the answer declares them + // again. A pause holds these too, so a later resume still knows DYNAMIC_GROUPS. + let properties = match &resumed { + Some(idle) if held.is_none() && !properties_wanted && ietf::Filter::is_draft20(self.version) => { + idle.properties.clone() + } + _ => properties, + }; let timescale = properties.timescale; let info = accepted_info(&properties, self.version); // The copy already holds the track: it is current again up to the answer's Largest @@ -3941,8 +3949,7 @@ impl Subscriber { messages, request_id, alias, - // What a pause holds again: the properties the track was listed with. - properties, + properties: properties.clone(), owed: unanswered.load(Ordering::Relaxed), copy: Some(track.clone()), }; @@ -3951,7 +3958,7 @@ impl Subscriber { demand: track.demand(), track, dynamic, - timescale, + properties, finished: false, }); } @@ -3974,7 +3981,7 @@ impl Subscriber { demand: track.demand(), track, dynamic, - timescale, + properties, finished: true, }); } @@ -4002,7 +4009,7 @@ impl Subscriber { demand: track.demand(), track, dynamic, - timescale, + properties, finished: false, }) } @@ -4081,7 +4088,7 @@ impl Subscriber { broadcast_path.clone(), track_name.to_owned(), fill, - Later::Known(idle.timescale), + Later::Known(idle.properties.timescale), ); group_fetches.push(fetch); } @@ -4388,7 +4395,7 @@ impl Subscriber { .await; match learned { Ok(idle) => { - timescale.resolve(Ok(idle.timescale)); + timescale.resolve(Ok(idle.properties.timescale)); Some(idle) } Err(err) => { @@ -4548,7 +4555,7 @@ impl Subscriber { demand: track.demand(), track, dynamic, - timescale: ok.properties.timescale, + properties: ok.properties, finished: false, }) } diff --git a/rs/moq-net/src/ietf/subscriber/tracks.rs b/rs/moq-net/src/ietf/subscriber/tracks.rs index e6affb5d75b..86b295e8695 100644 --- a/rs/moq-net/src/ietf/subscriber/tracks.rs +++ b/rs/moq-net/src/ietf/subscriber/tracks.rs @@ -1766,6 +1766,112 @@ mod tests { } } + /// A copy that learned DYNAMIC_GROUPS keeps it through a draft-22 resume that opts out of + /// the properties, so once that subscription pauses as the listing's entry, the + /// REQUEST_UPDATE resuming it still carries the group a join asked for. + #[kio::test] + async fn a_paused_resume_that_opted_out_keeps_dynamic_groups() { + let version = Version::Draft22; + let mut h = harness(version); + let mut listing = h.establish().await; + let accept = |peer: memory::Session| async move { + let mut stream = kio::clock::timeout(TIMEOUT, Stream::accept(&mut Transport::new(peer), version)) + .await + .expect("no SUBSCRIBE") + .unwrap(); + let (id, body) = read(&mut stream).await; + assert_eq!(id, ietf::Subscribe::ID); + let msg: ietf::Subscribe = body.message(version).unwrap(); + (stream, msg.properties_wanted, msg.new_group) + }; + let subscribe_ok = |dynamic_groups| ietf::SubscribeOk { + track_alias: 3, + largest: Some(ietf::Location { group: 5, object: 0 }), + properties: ietf::Properties { + dynamic_groups, + ..Default::default() + }, + }; + let answer = ietf::RequestOk { + active: None, + largest: None, + }; + + // The first answer declares DYNAMIC_GROUPS, and group 5 lands with a delta. + let (track, first, _serving) = h.read_track("video").await; + let (mut stream, wanted, _) = accept(h.peer.clone()).await; + assert!(wanted); + write(&mut stream, ietf::SubscribeOk::ID, &subscribe_ok(true)).await; + let first = kio::clock::timeout(TIMEOUT, first) + .await + .expect("never accepted") + .unwrap(); + let copy = h + .subscriber + .state + .lock() + .subscribes + .values() + .next() + .unwrap() + .producer + .clone() + .unwrap(); + let mut group = copy.create_group(crate::model::group::Info { sequence: 5 }).unwrap(); + group.write_frame(None, b"key".as_slice()).unwrap(); + group.write_frame(None, b"delta".as_slice()).unwrap(); + + // A join past the ratio asks for group 6, which stays outstanding. + let join = track.subscribe(None).await.unwrap(); + settle().await; + let (id, body) = read(&mut stream).await; + assert_eq!(id, ietf::SubscribeUpdate::ID); + assert_eq!( + body.message::(version).unwrap().new_group, + Some(6) + ); + write(&mut stream, ietf::RequestOk::ID, &answer).await; + + // Everyone leaves, and the copy lingers. + drop((first, join)); + settle().await; + + // A returning reader resumes it, opting out of the properties: the answer has none. + let reader = track.subscribe(None); + let (mut stream, wanted, new_group) = accept(h.peer.clone()).await; + assert!(!wanted, "the resume opts out"); + assert_eq!(new_group, Some(6)); + write(&mut stream, ietf::SubscribeOk::ID, &subscribe_ok(false)).await; + let reader = kio::clock::timeout(TIMEOUT, reader) + .await + .expect("never accepted") + .unwrap(); + + // Skipped in the listing, so this subscription becomes the entry and pauses. + let skipped = ietf::PublishSkipped { + suffix: Path::from_static(""), + track_name: "video".into(), + }; + write(&mut listing, ietf::PublishSkipped::ID, &skipped).await; + assert_eq!(event(&mut h.tracks).as_deref(), Some("+video")); + drop(reader); + let (id, body) = read(&mut stream).await; + assert_eq!(id, ietf::SubscribeUpdate::ID, "not paused"); + assert_eq!( + body.message::(version).unwrap().forward, + Some(false) + ); + write(&mut stream, ietf::RequestOk::ID, &answer).await; + + // The resume still asks for group 6, since the track declared DYNAMIC_GROUPS. + let _reader = track.subscribe(None); + let (id, body) = read(&mut stream).await; + assert_eq!(id, ietf::SubscribeUpdate::ID, "not resumed"); + let resume: ietf::SubscribeUpdate = body.message(version).unwrap(); + assert_eq!(resume.forward, Some(true)); + assert_eq!(resume.new_group, Some(6), "the pause forgot DYNAMIC_GROUPS"); + } + /// A listed track that finishes before its resume is answered goes back to lingering, and /// its waiting reader SUBSCRIBEs: the idle copy cannot place the end, which the SUBSCRIBE /// learns, rather than abort a clean finish.