diff --git a/quest/m1/README.md b/quest/m1/README.md index e2d41051b87..dcecb55fea4 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -144,7 +144,6 @@ per-frame CPU growth since #5926. - [moq-c at parity](/quest/m1/c/README.md) - the hand-written `moq-c` ships at the cut with every m1 binding feature moq-ffi gains - [Bindings see a moq-transport run end as an end](/quest/m1/ffi-ietf-run-end.md) - an IETF publisher ending its run reaches moq-ffi consumers as an end, not `Internal` - [Byte-stream renditions form a ladder](/quest/m1/stream-ladder.md) - moq-ffi stream producers link as `lower` and disable unfundable rungs like frame producers -- [A relay answers a SUBSCRIBE on a copy it kept after a fetch](/quest/m1/relay-fetched-copy-subscribe.md) - the downstream SUBSCRIBE_OK waits for the upstream edge instead of hanging - [A job's exact route continues its claim's readers](/quest/m1/announce-takeover.md) - a job's route inherits its claim's instance, replacing the ANNOUNCE_TAKEOVER predecessor design - [Subscribe ranges](/quest/m1/subscribe-ranges/README.md) - a lite-07 SUBSCRIBE asks for past and live ranges with absolute or relative ends, in either order, and replaces FETCH; merged ranges never starve a subscriber; relays fill misses by range, including over moq-transport - [Drop set](/quest/m1/drop-set.md) - each cursor judges missing groups against its own budget, so a narrow reader drops promptly and a widening re-offers groups already reported dropped on lite-07 diff --git a/quest/m1/relay-fetched-copy-subscribe.md b/quest/m1/relay-fetched-copy-subscribe.md deleted file mode 100644 index 6bdfdb07d52..00000000000 --- a/quest/m1/relay-fetched-copy-subscribe.md +++ /dev/null @@ -1,29 +0,0 @@ -# [S] A relay answers a SUBSCRIBE on a copy it kept after a fetch - -## Goal - -A moq-transport subscriber gets SUBSCRIBE_OK for a history SUBSCRIBE sent -through a relay that holds a copy kept after a FETCH. The OK names the live -edge from the upstream's SUBSCRIBE_OK, never from the relay's cache or an -edge the upstream reported earlier. An integration test covers it. - -## Plan - -Planned 2026-11-01 (maintainer, follow-up of -[moq-dev/moq#7545](https://github.com/moq-dev/moq/pull/7545)). - -Repro, from #7545's review: the relay fetches group 2 of an unfinished track. -A fresh draft-22 session then subscribes `with_range(1..2)` through it, and -gets no SUBSCRIBE_OK within 5 s. It hangs the same way on main -(`3ae67897`), where the relay does subscribe upstream, so this bug predates -#7545. - -- The maintainer decided on 2026-11-01, on #7545, that the OK waits until the - live edge is known, and is never taken from the cache. So the fix is not to - answer from the stale reported edge. -- Find why the upstream's SUBSCRIBE_OK doesn't reach the downstream OK on a - fetched copy, and fix that. -- Test it in `rs/moq-net/tests/integration/fetch_only.rs` on drafts 18 and 22, - direct and through a relay. - -Public API: none. Wire: none. diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index caf9e5b7ec3..2db27696370 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -33,6 +33,9 @@ fn serving_subscription(subscriber_priority: u8) -> Subscription { priority: super::priority::from_wire(subscriber_priority), // No Max Age is the publisher's retention alone, whatever it turns out to be. max_delay: None, + // SUBSCRIBE_OK names the live edge, which a relay learns only from its upstream's + // answer: never from its cache, nor from an edge reported before. + feed: true, ..Default::default() } } diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index 75118c6434a..affa099df95 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -756,15 +756,15 @@ fn largest_group(track: &track::Producer, answer: Option) -> Opt } /// Whether `subscription` needs a live feed for a copy whose publisher reported its Largest -/// Object in group `edge`: one of its ranges is open, counts back from the live edge, or -/// reaches the group the publisher may still be writing. Ranges wholly below it read only -/// history, which fills serve. +/// Object in group `edge`: a reader asked for it ([`track::Subscription::feed`]), or one of +/// its ranges is open, counts back from the live edge, or reaches the group the publisher +/// may still be writing. Ranges wholly below it read only history, which fills serve. fn wants_feed(subscription: &track::Subscription, edge: Option) -> bool { if subscription.ranges.is_empty() { return false; } let history = subscription.start().is_some() && subscription.end().zip(edge).is_some_and(|(end, edge)| end <= edge); - !history + subscription.feed || !history } /// A copy with no subscription upstream, kept for fetches and a returning subscriber. @@ -2966,13 +2966,7 @@ impl Subscriber { } }; let start = subscription.as_ref().and_then(|s| s.start()); - let join = match subscribe_join(start, subscription.as_ref().and_then(|s| s.end()), self.version) { - Ok(join) => join, - Err(err) => { - target.fail(err); - return None; - } - }; + let join = subscribe_join(start, subscription.as_ref().and_then(|s| s.end()), self.version); // A live join delivers nothing below the group SUBSCRIBE_OK names as Largest. Every // draft-18 join is one, since its joining FETCH carries that group alone. let live = start.is_none() || join.fetch; @@ -3590,7 +3584,17 @@ impl Subscriber { && (poll_headed(&fill, waiter).is_ready() || largest.is_some_and(|largest| track.poll_past(largest.group, waiter).is_ready())) { - track.set_live(largest, None); + // An absolute feed starts where it asked, whatever the answer's Largest; a + // live join's starts there. + let from = sent_bounds.0.filter(|_| !live); + match largest { + // A feed ending before the answer's Largest never shows it, so the + // answer alone makes the copy current. A live join's feed is open. + Some(largest) if !live && sent_bounds.1.is_some_and(|end| end <= largest.group) => { + track.set_live_ahead(largest, from) + } + largest => track.set_live(largest, from), + } resuming = None; } // The last subscriber left: the upstream subscription goes with it, as on @@ -3665,10 +3669,7 @@ impl Subscriber { }; let ranges = if bounds != sent_bounds { let mut join = if Filter::is_draft20(self.version) { - match subscribe_join(bounds.0, bounds.1, self.version) { - Ok(join) => join, - Err(err) => return Poll::Ready(End::Invalid(err)), - } + subscribe_join(bounds.0, bounds.1, self.version) } else { Join { filter: match bounds { @@ -12124,24 +12125,22 @@ struct Join { /// Earlier drafts have no fill parameter. Every subscription is a live join: Largest /// Object, followed by a joining FETCH relative at offset 0 for that group's head. An /// earlier start's groups are left to the copy's fills, one FETCH per run of them, and a -/// later start skips the head locally. A bounded end has no -/// joining-FETCH spelling, so it is refused rather than left open. +/// later start skips the head locally. A bounded end has no joining-FETCH spelling +/// either, so the join stays open and readers stop at their own end: refusing it would +/// abort a resumed copy for every reader it serves. /// /// A start group we already know is absolute on draft-22 and needs no fill: the /// subscription's own range covers it, which is what our publisher serves from its cache. -fn subscribe_join(start: Option, end: Option, version: Version) -> Result { +fn subscribe_join(start: Option, end: Option, version: Version) -> Join { if !Filter::is_draft20(version) { - if end.is_some() { - return Err(Error::Unsupported); - } - return Ok(Join { + return Join { filter: Filter::NextObject, fill: None, fetch: true, - }); + }; } - Ok(match start { + match start { // The live join: everything after the live edge, plus the current group's head. None => Join { filter: Filter::NextObject, @@ -12175,7 +12174,7 @@ fn subscribe_join(start: Option, end: Option, version: Version) -> Res fill: None, fetch: false, }, - }) + } } /// Resolve the first absolute ID or a later ID delta without overflowing. Subgroup relay @@ -12223,7 +12222,7 @@ mod filter_tests { #[test] fn live_joins_the_current_group_with_a_fill() { assert_eq!( - subscribe_join(None, None, Version::Draft22).unwrap(), + subscribe_join(None, None, Version::Draft22), Join { filter: Filter::NextObject, fill: Some(ietf::Fill { @@ -12241,7 +12240,7 @@ mod filter_tests { #[test] fn a_past_start_is_absolute() { assert_eq!( - subscribe_join(Some(7), Some(10), Version::Draft22).unwrap(), + subscribe_join(Some(7), Some(10), Version::Draft22), Join { filter: Filter::Absolute { start: ietf::Location { group: 7, object: 0 }, @@ -12257,7 +12256,7 @@ mod filter_tests { #[test] fn the_whole_track_is_unfiltered() { assert_eq!( - subscribe_join(Some(0), None, Version::Draft22).unwrap(), + subscribe_join(Some(0), None, Version::Draft22), Join { filter: Filter::Unfiltered, fill: None, @@ -12268,36 +12267,25 @@ mod filter_tests { const JOINING_DRAFTS: [Version; 1] = [Version::Draft18]; - /// Every draft-18 join is Largest Object plus a joining FETCH, whatever its start, - /// so the current group's head arrives on the fetch stream and the live tail on the + /// Every draft-18 join is Largest Object plus a joining FETCH, whatever its start or + /// end, so the current group's head arrives on the fetch stream and the live tail on the /// subscription. #[test] fn older_drafts_always_join_live() { for version in JOINING_DRAFTS { - for start in [None, Some(7)] { + for (start, end) in [(None, None), (Some(7), None), (Some(7), Some(10))] { assert_eq!( - subscribe_join(start, None, version).unwrap(), + subscribe_join(start, end, version), Join { filter: Filter::NextObject, fill: None, fetch: true, }, - "{version} from {start:?}" + "{version} from {start:?} to {end:?}" ); } } } - - /// A bounded end has no joining-FETCH spelling, so it is refused rather than left open. - #[test] - fn older_drafts_refuse_a_bounded_end() { - for version in JOINING_DRAFTS { - assert!( - matches!(subscribe_join(Some(7), Some(10), version), Err(Error::Unsupported)), - "{version}" - ); - } - } } /// Draft-22's current-group join, where one group arrives on two streams: the fill fetch diff --git a/rs/moq-net/src/model/subscription.rs b/rs/moq-net/src/model/subscription.rs index 08bf5ae5d66..2528465a33d 100644 --- a/rs/moq-net/src/model/subscription.rs +++ b/rs/moq-net/src/model/subscription.rs @@ -94,6 +94,11 @@ pub struct Subscription { /// subscribers fresh. Each subscriber's own publisher (a relay's downstream session) /// still serves it in its own order. pub order: Order, + /// Whether this reader needs the source's live feed, not only its history: a wire + /// publisher owes its peer an answer naming the live edge, which only the upstream's own + /// answer gives. A session holding no upstream subscription for its copy subscribes again + /// for such a reader, whatever its ranges. Aggregated as any: one such reader is enough. + pub(crate) feed: bool, } /// Which of a subscription's pending groups the publisher sends first. @@ -294,6 +299,7 @@ impl Default for Subscription { max_delay: Some(Duration::ZERO), ranges: vec![Range::oldest()], order: Order::Descending, + feed: false, } } } @@ -475,6 +481,7 @@ impl Combined { if let Order::Descending = sub.order { combined.order = Order::Descending; } + combined.feed |= sub.feed; } /// The aggregate, or `None` without a subscriber. diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index f2a02adb0ef..bf808d46d79 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -2846,6 +2846,21 @@ impl TrackState { /// read as the live edge, though the route already holds a newer one. #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] fn set_live(&mut self, largest: Option, start: Option) { + self.answered(largest, start, true); + } + + /// [`Self::set_live`] for a feed that serves no group from `largest`'s on, such as a + /// bounded subscription of history: the cache can never show that group, so the answer + /// alone makes it current, and relative starts count back from that group. + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] + fn set_live_ahead(&mut self, largest: Position, start: Option) { + self.answered(Some(largest), start, false); + } + + /// The route answered with `largest`. With `reaches`, its feed reaches that group, so + /// readers wait until the cache shows it. + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] + fn answered(&mut self, largest: Option, start: Option, reaches: bool) { let Feed::Idle { newest } = self.feed else { return; }; @@ -2868,7 +2883,7 @@ impl TrackState { _ => self.live_floor, }; match largest.map(|largest| largest.group) { - Some(from) if !self.shows(from) => self.feed = Feed::Answered { from }, + Some(from) if reaches && !self.shows(from) => self.feed = Feed::Answered { from }, edge => self.go_live(edge), } } @@ -3686,6 +3701,16 @@ impl Producer { } } + /// [`Self::set_live`] for a feed that serves no group from `largest`'s on, such as a + /// bounded subscription of history: readers resume at once, counting relative starts + /// back from `largest`'s group. A no-op unless idle. + #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] + pub(crate) fn set_live_ahead(&mut self, largest: Position, start: Option) { + if let Ok(mut state) = self.modify() { + state.set_live_ahead(largest, start); + } + } + /// Whether a subscription feeds this copy: its session holds one upstream for it, or /// none, so nothing reaches it but what fills answer. Only the session knows, from its /// own state; the cache never tells. While unfed, a bounded read's holes are misses up diff --git a/rs/moq-net/src/model/track/demand.rs b/rs/moq-net/src/model/track/demand.rs index 53caec2e017..63df3990e0e 100644 --- a/rs/moq-net/src/model/track/demand.rs +++ b/rs/moq-net/src/model/track/demand.rs @@ -22,6 +22,8 @@ pub(super) struct Subscriptions { max_delay: BTreeMap, ranges: Ranges, descending: usize, + /// Subscribers that need the live feed; see [`Subscription::feed`]. + feed: usize, /// The lowest group consumers want while no refresh is pending, never lowered. See /// [`super::Demand::wanted`]. wanted: u64, @@ -35,16 +37,17 @@ pub(super) struct Subscriptions { } /// Everything the aggregate holds besides its ranges. -type Scalars = (i8, Option, Order); +type Scalars = (i8, Option, Order, bool); impl Subscriptions { pub(super) fn combined(&self) -> Option { - let (priority, max_delay, order) = self.scalars()?; + let (priority, max_delay, order, feed) = self.scalars()?; Some(Subscription { priority, max_delay, ranges: self.ranges.union(), order, + feed, }) } @@ -65,6 +68,7 @@ impl Subscriptions { } else { Order::Descending }, + self.feed != 0, ) }) } @@ -140,6 +144,7 @@ impl Subscriptions { } } self.descending += usize::from(new.order == Order::Descending); + self.feed += usize::from(new.feed); self.count += 1; } if let Some(old) = old { @@ -151,6 +156,7 @@ impl Subscriptions { } } self.descending -= usize::from(old.order == Order::Descending); + self.feed -= usize::from(old.feed); self.count -= 1; } if reshaped || self.scalars() != prev { @@ -315,6 +321,7 @@ mod tests { } else { Order::Descending }, + feed: rng.random_bool(0.25), }; match (&mut slots[index], rng.random_range(0..3)) { (slot @ None, _) => *slot = Some((producer.subscribe(next.clone()), next)), diff --git a/rs/moq-net/tests/integration/fetch_only.rs b/rs/moq-net/tests/integration/fetch_only.rs index 89a735d04e3..253515daa44 100644 --- a/rs/moq-net/tests/integration/fetch_only.rs +++ b/rs/moq-net/tests/integration/fetch_only.rs @@ -320,3 +320,244 @@ async fn a_relay_serves_a_bounded_read_of_history_without_subscribing_upstream() } assert!(failures.is_empty(), "failed: {failures:?}"); } + +/// Write group `sequence` of [`frames`] to a live track. +fn write_group(track: &moq_net::track::Producer, sequence: u64) { + let mut group = track.create_group(moq_net::group::Info { sequence }).unwrap(); + for frame in frames(sequence) { + group.write_frame(Timestamp::ZERO, frame).unwrap(); + } + group.finish().unwrap(); +} + +/// Publish a live track of groups `0..groups`, which the publisher keeps writing. +fn publish_live( + origin: &moq_net::origin::Producer, + groups: u64, +) -> (moq_net::origin::Publication, moq_net::track::Producer) { + let broadcast = origin.create_broadcast("bcast").unwrap(); + let track = broadcast.create_track("video", timed()).unwrap(); + broadcast.announce(Default::default()).unwrap(); + for sequence in 0..groups { + write_group(&track, sequence); + } + (broadcast, track) +} + +/// A relay of a live track holding a copy a fetch left unfed, and a fresh session to it. +struct FetchedCopy { + /// The publisher's track, which has since moved past the edge the fetch learned. + track: moq_net::track::Producer, + /// The track through the fresh session, which knows no edge, so its reads SUBSCRIBE. + fresh: moq_net::track::Consumer, + /// The broadcast through the session that fetched, another reader of the relay's copy. + fetched: moq_net::broadcast::Consumer, + _held: Vec>, +} + +/// The relay speaks `upstream_version` to the publisher and `version` downstream. +async fn fetched_copy(upstream_version: Version, version: Version) -> FetchedCopy { + let publisher = produce_origin(1); + let (broadcast, track) = publish_live(&publisher, 3); + + let relay = produce_origin(2); + let mut options = MockConnectOptions::new(upstream_version); + options.server_publish = Some(publisher.consume()); + options.client_subscribe = Some(relay.clone()); + let upstream = connect_mock(options).await; + + // The fetch learns Largest Object (2, 1) from TRACK_STATUS, and subscribes nowhere. + let fetcher = produce_origin(3); + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(relay.consume()); + options.client_subscribe = Some(fetcher.clone()); + let fetching = connect_mock(options).await; + let fetched = resolve(&fetcher).await; + assert_eq!(fetch(&fetched, 2).await.expect("fetch"), frames(2), "{version}"); + assert!(track.subscription().is_none(), "{version}: the fetch subscribed"); + + // The edge moves on, so an answer from the earlier report would be stale. + write_group(&track, 3); + + let client = produce_origin(3); + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(relay.consume()); + options.client_subscribe = Some(client.clone()); + let downstream = connect_mock(options).await; + let fresh = resolve(&client).await.track("video").unwrap(); + + FetchedCopy { + track, + fresh, + fetched, + _held: vec![ + Box::new(downstream), + Box::new(client), + Box::new(fetching), + Box::new(fetcher), + Box::new(upstream), + Box::new(relay), + Box::new(broadcast), + Box::new(publisher), + ], + } +} + +async fn history_through_fetched_copy(upstream: Version, version: Version) { + let copy = fetched_copy(upstream, version).await; + // A front's bounded read parks past its end, so this reads the group and stops there. + let mut sub = subscribe_history(©.fresh).await; + assert!( + copy.track.subscription().is_some(), + "{upstream} to {version}: answered without subscribing upstream" + ); + assert_eq!(next_frames(&mut sub).await, Some(frames(1)), "{upstream} to {version}"); + // The copy still serves its other reader. + assert_eq!( + fetch(©.fetched, 0).await.expect("fetch after the SUBSCRIBE"), + frames(0), + "{upstream} to {version}" + ); +} + +/// A history SUBSCRIBE reaching a relay's copy kept after a fetch is answered from the +/// upstream's SUBSCRIBE_OK, never the edge the fetch learned, and reads its history. A +/// draft-18 upstream has no bounded join, so the relay joins it live and serves the history +/// from fills, keeping the copy for its other readers. +#[kio::test] +async fn a_relay_answers_a_history_subscribe_on_a_fetched_copy() { + for (upstream, version) in [ + ("moq-transport-22", "moq-transport-22"), + ("moq-transport-18", "moq-transport-22"), + ("moq-transport-18", "moq-transport-18"), + ] { + let (upstream, version): (Version, Version) = (upstream.parse().unwrap(), version.parse().unwrap()); + kio::clock::timeout(TIMEOUT, history_through_fetched_copy(upstream, version)) + .await + .unwrap_or_else(|_| panic!("{upstream} to {version}: timed out")); + } +} + +async fn live_through_fetched_copy(version: Version) { + let copy = fetched_copy(version, version).await; + let mut sub = kio::clock::timeout(TIMEOUT, copy.fresh.subscribe(None)) + .await + .expect("subscribe timed out") + .expect("subscribe"); + // The live join starts at the upstream's current group, not the one the fetch reported. + assert_eq!(next_frames(&mut sub).await, Some(frames(3)), "{version}"); + write_group(©.track, 4); + assert_eq!(next_frames(&mut sub).await, Some(frames(4)), "{version}"); +} + +/// A live SUBSCRIBE reaching a relay's copy kept after a fetch joins at the upstream's +/// current edge. +#[kio::test] +async fn a_relay_answers_a_live_subscribe_on_a_fetched_copy() { + for version in VERSIONS { + let version: Version = version.parse().unwrap(); + kio::clock::timeout(TIMEOUT, live_through_fetched_copy(version)) + .await + .unwrap_or_else(|_| panic!("{version}: timed out")); + } +} + +/// A copy kept after a fetch resumes a bounded subscription that ends at or below the +/// upstream's new Largest Object, and reads it, though no group past its end arrives. +/// Draft 22 only: a draft-18 join is live, so these groups come from one fill of the run, +/// and our publisher answers only a one-group FETCH. +#[kio::test] +async fn a_resumed_bounded_subscription_reads_below_the_answered_edge() { + kio::clock::timeout(TIMEOUT, async { + let version: Version = "moq-transport-22".parse().unwrap(); + let publisher = produce_origin(1); + let (broadcast, track) = publish_live(&publisher, 2); + + let client = produce_origin(2); + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(publisher.consume()); + options.client_subscribe = Some(client.clone()); + let pair = connect_mock(options).await; + + // The fetch learns Largest Object (1, 1), and leaves the copy unfed. + let remote = resolve(&client).await; + assert_eq!(fetch(&remote, 0).await.expect("fetch"), frames(0)); + for sequence in 2..4 { + write_group(&track, sequence); + } + + // Past the reported edge, so it subscribes; the answer names group 3, which the + // bounded feed never delivers. + let copy = remote.track("video").unwrap(); + let subscription = moq_net::track::Subscription::default() + .with_order(moq_net::track::Order::Ascending) + .with_max_delay(None) + .with_range(1..3); + let mut sub = kio::clock::timeout(TIMEOUT, copy.subscribe(subscription)) + .await + .expect("subscribe timed out") + .expect("subscribe"); + // Read in arrival order, whichever group lands first. + let mut read = vec![next_frames(&mut sub).await, next_frames(&mut sub).await]; + read.sort(); + assert_eq!(read, [Some(frames(1)), Some(frames(2))]); + assert!(track.subscription().is_some(), "the read never subscribed"); + + drop((sub, copy, remote, pair, track, broadcast, client, publisher)); + }) + .await + .expect("timed out"); +} + +/// A copy that went idle holding a group resumes a bounded subscription of that group after +/// the upstream moved on, and still reads it: the feed starts where it asked, not at the +/// answer's Largest, so the cached group stays below no floor. Draft 22 only: a draft-18 +/// join is live, so it starts at the answer's Largest whatever it asked. +#[kio::test] +async fn a_resumed_bounded_subscription_keeps_its_cached_start() { + kio::clock::timeout(TIMEOUT, async { + let version: Version = "moq-transport-22".parse().unwrap(); + let publisher = produce_origin(1); + let (broadcast, track) = publish_live(&publisher, 1); + + let client = produce_origin(2); + let mut options = MockConnectOptions::new(version); + options.server_publish = Some(publisher.consume()); + options.client_subscribe = Some(client.clone()); + let pair = connect_mock(options).await; + + // A live read caches group 0, then leaves, so the copy goes idle holding it. + let remote = resolve(&client).await; + let copy = remote.track("video").unwrap(); + let mut live = kio::clock::timeout(TIMEOUT, copy.subscribe(None)) + .await + .expect("subscribe timed out") + .expect("subscribe"); + assert_eq!(next_frames(&mut live).await, Some(frames(0))); + drop(live); + let mut watch = track.clone(); + while watch.subscription().is_some() { + kio::clock::timeout(TIMEOUT, watch.subscription_changed()) + .await + .expect("unsubscribe timed out") + .unwrap(); + } + for sequence in 1..4 { + write_group(&track, sequence); + } + + // Past the edge the live read learned, so it subscribes; the answer names group 3. + let subscription = moq_net::track::Subscription::default() + .with_max_delay(None) + .with_range(0..1); + let mut sub = kio::clock::timeout(TIMEOUT, copy.subscribe(subscription)) + .await + .expect("subscribe timed out") + .expect("subscribe"); + assert_eq!(next_frames(&mut sub).await, Some(frames(0))); + + drop((sub, copy, remote, pair, track, broadcast, client, publisher)); + }) + .await + .expect("timed out"); +}