From 384e41274e0ce5c9d8b8ff898d70847655cde42b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 18:59:59 -0800 Subject: [PATCH 1/7] chore(quest): claim quest/m1/push-to-talk/README.md Quest-Claim: d29a67dfc58635d8 From bd4f5eaacea85ba7b7594626b1a4401e642e8aa6 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 19:04:30 -0800 Subject: [PATCH 2/7] fix(hang): a declared end's pause proves no hole is too old After a push-to-talk release, the next utterance's second group can reach the listener before its head. The hole proof measured the new group against where presentation stopped, so the mute itself read as lateness and the head was skipped. Once delivery stopped at a declared end, the hole waits out its budget instead, as Rust's measure already does. Co-Authored-By: Claude Opus 5.5 --- js/hang/src/container/consumer.holes.test.ts | 56 ++++++++++++++++++++ js/hang/src/container/consumer.ts | 8 ++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/js/hang/src/container/consumer.holes.test.ts b/js/hang/src/container/consumer.holes.test.ts index 724c43aafa5..d26d7f1e0fe 100644 --- a/js/hang/src/container/consumer.holes.test.ts +++ b/js/hang/src/container/consumer.holes.test.ts @@ -238,3 +238,59 @@ test("a hole in a drained backlog is late from the earliest arrival past it, not installed.close(); } }); + +// A pause's timestamp jump is not lateness: the group that resumes it can arrive behind the one after +// it, and is waited for like any hole rather than skipped as too old. +test.each([true, false])("the head after a declared end is waited for (arrives: %p)", async (arrives) => { + const clock = new Manual(); + const installed = clock.install(); + const track = new Track.Producer("audio"); + const consumer = new Consumer(track.subscribe({ delay: { max: Milli(30_000) } }), { + format: new Format("audio"), + delay: { max: Milli(300) }, + }); + const results: Read[] = []; + const reading = (async () => { + for (;;) { + const read = await consumer.next(); + if (!read) return; + results.push(read); + } + })(); + const write = (sequence: bigint, timestamp: number, payload = new Uint8Array([1])) => { + const group = track.createGroup(sequence); + group.writeFrame({ + payload: encodeFrame(payload, Micro(timestamp)), + timestamp: Time.Timestamp.fromMicros(Micro(timestamp)), + }); + group.finish(); + }; + const frame = (group: bigint, timestamp: number) => ({ kind: "frame", group, frame: expect.objectContaining({ timestamp }) }); + try { + write(0n, 0); + write(1n, 60_000, new Uint8Array()); + await flush(); + expect(results).toEqual([frame(0n, 0), { kind: "end", group: 1n, end: Micro(60_000) }]); + write(3n, 60_060_000); + await flush(); + await clock.advance(Nano.fromMilli(Milli(299))); + expect(results).toHaveLength(2); + if (arrives) { + write(2n, 60_000_000); + await flush(); + expect(results.slice(2)).toEqual([frame(2n, 60_000_000), frame(3n, 60_060_000)]); + } else { + await clock.advance(Nano.fromMilli(Milli(1))); + expect(results.slice(2)).toEqual([ + { kind: "gap", timestamp: Micro(60_000), duration: Micro(60_000_000) }, + frame(3n, 60_060_000), + ]); + } + } finally { + consumer.close(); + track.finish(); + track.close(); + await reading; + installed.close(); + } +}); diff --git a/js/hang/src/container/consumer.ts b/js/hang/src/container/consumer.ts index 9ee90a2fef3..3b09ca8673b 100644 --- a/js/hang/src/container/consumer.ts +++ b/js/hang/src/container/consumer.ts @@ -191,6 +191,8 @@ export class Consumer { // Group of the last media frame next() returned, so an endpoint after it reads as that frame's // duration rather than a declared stop. #mediaGroup?: bigint; + // The last item read was a declared end, so the timeline is paused until a frame resumes it. + #paused = false; // Media went missing since the last item read, so the next one is preceded by a gap. #lost = false; // The furthest presentation point read so far: max(timestamp + duration), endpoints included. @@ -805,6 +807,8 @@ export class Consumer { // is proven: the head already reaches past where presentation left off by more than the // max delay, so anything still missing in between would arrive too old to play. Proving it // here matters: #checkMaxDelay would instead drop the head, the very group to play next. + // A declared end proves nothing: the jump past it is the pause, and the media that resumes + // it may still be in flight behind the group after it. // After track termination no missing group can arrive, so drain across any remaining gap. // A missing sequence also expires on elapsed monotonic time, so timestamp-free markers // behind a hole can end a paused track without more arrivals. It is late since a group @@ -821,7 +825,8 @@ export class Consumer { const skipHole = head.frames.length > 0 && (maxDelay === 0 || - (this.#presentedEnd !== undefined && + (!this.#paused && + this.#presentedEnd !== undefined && head.latest !== undefined && head.latest - this.#presentedEnd > maxDelay)); const elapsed = Instant.durationSince(now(), this.#hole) >= maxDelay * 1000; @@ -1038,6 +1043,7 @@ export class Consumer { const edge = this.#edge; const lost = this.#lost; this.#lost = false; + this.#paused = read.kind === "end"; this.#advance(read.kind === "frame" ? Micro(resume + (read.frame.duration ?? Micro.zero)) : resume); if (!lost || edge === undefined) return read; From dcf409c6b8881dd82b734b88c95e3021654c63e9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 19:55:17 -0800 Subject: [PATCH 3/7] test(mux): the head after a declared end is waited for Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/consumer.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index bd8292ded66..3f30a6573d5 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -2699,6 +2699,30 @@ mod tests { assert_eq!(items(&mut consumer).await, ["0", "end 0", "1000000"]); } + /// A pause's timestamp jump is not lateness: the group that resumes it can arrive behind the + /// one after it, and is waited for like any hole rather than skipped as too old. + #[tokio::test(start_paused = true)] + async fn the_head_after_a_declared_end_is_waited_for() { + let mut track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.audio)); + let mut consumer = Consumer::new( + track.subscribe( + moq_net::track::Subscription::default().with_delay(Delay::default().with_max(Duration::from_secs(30))), + ), + Container::Legacy(crate::container::Kind::Audio), + ); + consumer.max_delay = Duration::from_millis(300); + write_group(&mut track, 0, &[ts(0)]); + write_marker_group(&mut track, 1, ts(60_000)); + assert_eq!(consumer.read_frame().await.unwrap().unwrap().timestamp, ts(0)); + assert!(matches!(consumer.read().await.unwrap(), Some(Read::End { group: 1, .. }))); + write_group(&mut track, 3, &[ts(60_060_000)]); + tokio::time::advance(Duration::from_millis(299)).await; + assert!(consumer.poll_read(&kio::Waiter::noop()).is_pending()); + write_group(&mut track, 2, &[ts(60_000_000)]); + track.finish().unwrap(); + assert_eq!(items(&mut consumer).await, ["60000000", "60060000"]); + } + #[tokio::test] async fn a_zero_budget_idle_resume_reports_the_shed_marker_as_a_gap() { let mut track = track_producer("test", hang::container::track_info(hang::catalog::PRIORITY.audio)); From f8aa5ee3889469b6f02557f0080be70df8306de3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 20:14:59 -0800 Subject: [PATCH 4/7] quest: push-to-talk loses no speech Five 60 ms runs of the acceptance proof kept all 110 heads in the browser and native listeners, with no underrun or stall, and two 20 ms runs kept all 44, one of them a head that arrived behind its successor after a 60 s mute. The latency quest now owns the playout budget, and the m5 bandwidth-grant quest no longer leans on the retired disabled-rendition hold. Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 1 - quest/m1/push-to-talk-latency.md | 11 +- quest/m1/push-to-talk/README.md | 100 ------------------ ...bandwidth-grant-in-moq-audio-instead-of.md | 11 +- 4 files changed, 12 insertions(+), 111 deletions(-) delete mode 100644 quest/m1/push-to-talk/README.md diff --git a/quest/m1/README.md b/quest/m1/README.md index c772a56bdbb..9f0d86981b3 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -44,7 +44,6 @@ moves what remains of them once their claims merge. - [Audio jitter target](/quest/m1/audio-jitter-target/README.md) - the playout target is default in both languages; time-stretched browser playback without steady-state underruns and a native trace replay remain - [Container reads drop backfill](/quest/m1/read-backfill.md) - the JS container consumer drops groups below its read cursor like Rust - [Buffered playback subscribes in ascending order](/quest/m1/buffered-ascending.md) - a buffered `` asks for the oldest group first, so a voice reply's opening arrives first, and audio's head hold shrinks to the floor -- [Push-to-talk loses no speech](/quest/m1/push-to-talk/README.md) - an unmute is heard from its first frame with no catalog round trip: mute moves from holding a disabled rendition to suppressed silence with comfort noise, after a route spike; capture delivers frames on a steady cadence - [Push-to-talk's press-to-audible latency fits a budget on the defaults](/quest/m1/push-to-talk-latency.md) - press to audible on the browser defaults, excluding device output, stays under a kixtop-measured budget that `just test push-to-talk` enforces - [Socket endpoints split into servers and clients](/quest/m1/socket-roles.md) - servers announce `.server/` and clients `.client/`, so plain grants keep a client from posing as a server or reading another client - [CARLA's driver ids stay private](/quest/m1/carla-driver-ids.md) - 128-bit driver ids, and `status` shows a handle that isn't the endpoint id diff --git a/quest/m1/push-to-talk-latency.md b/quest/m1/push-to-talk-latency.md index a25d6e5208c..31c5f915ba1 100644 --- a/quest/m1/push-to-talk-latency.md +++ b/quest/m1/push-to-talk-latency.md @@ -44,9 +44,10 @@ ring held when that PCM landed. The run also keeps 60 ms / 128 kbit/s Opus, the setup the nightly passes on. On the loaded agent host, 2026-11-06 runs at the fixed 300 ms delay had no underrun or stall but lost heads ("utterance head was not decoded"): 2 of 22 on the default 20 ms Opus and 1 on 60 ms. -Whether 20 ms frames hit that ordering defect, which -[Push-to-talk](/quest/m1/push-to-talk/README.md) owns, more often is not -settled. What remains is to switch the page to the defaults, measure on `kixtop` again, +The group after a head could overtake it, and the read took the mute's +timestamp jump as proof the head was too late to wait for; +[moq-dev/moq#8123](https://github.com/moq-dev/moq/pull/8123) fixed it, and two +20 ms runs after the fix kept all 44 heads. What remains is to switch the page to the defaults, measure on `kixtop` again, and set and enforce the budget. Measured 2026-11-05 on the defaults, before Watch, one run of 22 presses @@ -81,8 +82,8 @@ Measurement limits: the harness's headless Chromium mutes its output and reads a fake microphone, so `device` is Chromium's projected output for the default device and `capture` excludes the microphone's own input latency. Linux's render callbacks are 43 ms, so its `render` can be negative by up to one -callback. The lost heads are the ordering defect -[Push-to-talk](/quest/m1/push-to-talk/README.md) owns. +callback. The lost heads were the ordering defect +[moq-dev/moq#8123](https://github.com/moq-dev/moq/pull/8123) fixed. Knobs: the target's frame term (`frameDuration`, 20 ms by default) and its measured term (`js/watch/src/audio/latency.ts`); device and render follow the diff --git a/quest/m1/push-to-talk/README.md b/quest/m1/push-to-talk/README.md deleted file mode 100644 index 05f2c8554fb..00000000000 --- a/quest/m1/push-to-talk/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# [M] Push-to-talk loses no speech - -## Goal - -A listener subscribed while a publisher is muted hears the next utterance from -its first frame. Unmuting costs no catalog round trip, no resubscribe and no -microphone reopen. A muted rendition still costs no media bytes. - -## Plan - -From [#7101](https://github.com/moq-dev/moq/issues/7101), traced 2026-10-28. With -`Audio.Encoder` `enabled: false`, watch deselects the rendition and -unsubscribes. On unmute the listener waits for the catalog flip, then its -SUBSCRIBE reaches the publisher. The demand gate discards everything encoded -before that (`js/publish/src/audio/encoder.ts:686`). At 100 ms RTT that is -three one-way trips plus the probe and a frame (~515 ms to the first fresh -frame). The emptied buffer then refills the 300 ms delay, so the result is -~820-950 ms to audible, with 250-400 ms of speech never encoded. - -Decided 2026-10-28 (maintainer): - -- **Hold, not DTX.** DTX is for silence the app can't predict. Push-to-talk - knows when it is silent, and a held subscription costs no media bytes and no - encoder CPU. DTX is off on main anyway ([#4919](https://github.com/moq-dev/moq/pull/4919)). - **Reversed 2026-11-04 (maintainer):** a catalog toggle makes every listener - wait out the `enabled` flip, so the jitter buffer must hold at least a round - trip. Done by [moq-dev/moq#7942](https://github.com/moq-dev/moq/pull/7942): - the mute sends nothing and keeps the rendition enabled, the publisher gates - capture before the encoder and stamps chunks from the inputs it fed, and - each muted span ends with a discontinuity marker that listeners play as - comfort noise, with no underrun or stall, which the jitter estimator ignores. -- **Players hold a disabled rendition**, retired by - [moq-dev/moq#7942](https://github.com/moq-dev/moq/pull/7942) with the mute - that needed it. Every first-party player deselects a disabled rendition - again, and the hang spec is back to "must not select". -- **The publisher keeps its probe result across a disable**, and the - element's `muted` and `invisible` leave capture open. -- **Encoding no longer waits for demand**, in every first-party publisher - (finished by [moq-dev/moq#7554](https://github.com/moq-dev/moq/pull/7554)). - A listener who - subscribes after the unmute still gets the start within its `delay.max`. This - replaces a publisher head buffer, which was considered and dropped as the - same idea special-cased. - -The epic's own work: the acceptance proof `just test push-to-talk` (22 -presses, 60 ms Opus, 300 ms delay), with a native `moq play` listener held to -the same no-lost-head, comfort-noise, and no-underrun checks. A listener's unmute pays no catalog -round trip and no resubscribe, and every frame of each utterance is encoded, -sent, received, and decoded from its first frame, with no catalog flip and no -underrun or stall across the presses. - -Decided with the maintainer on -[moq-dev/moq#7760](https://github.com/moq-dev/moq/pull/7760): - -- ✅ **Ideal conditions only** (2026-11-04): "don't use random packet loss - either, assume ideal conditions." Both elements reach a local relay - directly, on separate sessions so the media crosses it, with no shaping, - loss, or queueing. The bufferbloat and 2% loss profiles were removed. -- ✅ **Latency: at most 300 ms of playout on top of one-way delivery** - (2026-11-03): "We can't ever expect 300ms latency if it takes more than - 300ms to deliver a packet." No clocked live start or other startup - machinery. Five ideal runs on 2026-11-04 held it on all 75 separated presses - (median 261 ms, max 294 ms) at a fixed 300 ms delay, broken down on - [moq-dev/moq#7760](https://github.com/moq-dev/moq/pull/7760). The defaults' - breakdown is in [Push-to-talk latency](/quest/m1/push-to-talk-latency.md). -- ✅ **No encoder recovery on re-enable** (2026-11-03). Asked first why a - fatal encoder error is expected at all: it is not. No push-to-talk run - reported one, and no issue reports a publisher encoder failure; the latch - came from a review finding - ([moq-dev/moq#5441](https://github.com/moq-dev/moq/pull/5441)). WebCodecs - fails an encoder only for a config the platform rejects, an internal codec - error, or reclamation, which Chromium applies only to inactive, backgrounded - hardware codecs; Opus is software. A failure stays latched until a device, - settings or `source` change. - -The publisher's tail drop is fixed: a release's discontinuity marker waits -until the codec has emitted every chunk submitted before it. A frame submitted -under 1 ms before release used to be lost in 3 of 7 runs. - -What remains is a lost head at the listener. In one of 110 presses over the -2026-11-04 relay runs (run 3, press 20, after a 60 s mute), the -head's group 918 and the next frame's group 919, written at +72 and +73 ms, -reached the listener reordered: 919 at +187 ms and 918 at +192 ms, about 115 -ms in transit against the usual 3 ms. The listener decoded 919 at +191.7 ms. -Group 918 arrived 0.4 ms later and never reached the decoder, so the utterance -played from its second frame, 60 ms late. The JS ordered read still delivers a -group below its cursor as a late backfill -(`js/hang/src/container/consumer.ts`), so the head was most likely dropped as -late between the read and the decoder (`js/watch/src/audio/decoder.ts`); pin -that down first. After a declared end, the next group is known to be the end's -group plus one. Holding for it within the delay budget would keep the head -without adding startup latency, but weigh that against the no-window decision -in [Container reads drop backfill](/quest/m1/read-backfill.md). - -The runner fails on a head that is received but never decoded, so the proof -catches this. A complete set of runs finishes this epic. - -## Related - -- [Container reads drop backfill](/quest/m1/read-backfill.md) - changes how the ordered read treats a group below its cursor, where this head was lost diff --git a/quest/m5/2848-follow-the-bandwidth-grant-in-moq-audio-instead-of.md b/quest/m5/2848-follow-the-bandwidth-grant-in-moq-audio-instead-of.md index 6a1bd011c31..22b54b127d1 100644 --- a/quest/m5/2848-follow-the-bandwidth-grant-in-moq-audio-instead-of.md +++ b/quest/m5/2848-follow-the-bandwidth-grant-in-moq-audio-instead-of.md @@ -43,11 +43,12 @@ grant; `Options::bandwidth` documents that the ceiling (`rs/moq-mux/src/rate.rs`); for Opus it is the codec floor. A grant below it disables the rendition until bandwidth recovers (decided 2026-10-04 with the enabled flag), through the rung disable and re-enable - rule in `moq_mux::rate::Control` rather than a second one; the encoder never errors. Viewers with - no enabled alternative hold it ([push-to-talk](/quest/m1/push-to-talk/README.md)), - so its demand can stay while its grant is below the floor; recovery evaluates a - hypothetical share against the current estimate, as the ladder controller - does. The reservation's ceiling is + rule in `moq_mux::rate::Control` rather than a second one; the encoder never errors. This + assumed viewers with no enabled alternative hold it, so its demand stays while its grant is + below the floor, but [moq-dev/moq#7942](https://github.com/moq-dev/moq/pull/7942) retired that + hold: players deselect a disabled rendition again. Settle how demand survives the disable + before building this. Recovery evaluates a hypothetical share against the current estimate, + as the ladder controller does. The reservation's ceiling is the configured bitrate; only the policy target moves. - PCM: `pcm::bitrate(sample_rate, channels)` is `pub(crate)` (`rs/moq-audio/src/pcm.rs`), `Settings::bitrate` is refused for it From 9a0006a91619ea329bfc26e8c37b512b156ab5f2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 20:18:37 -0800 Subject: [PATCH 5/7] style: format the declared-end hole tests Co-Authored-By: Claude Opus 5.5 --- js/hang/src/container/consumer.holes.test.ts | 6 +++++- rs/moq-mux/src/container/consumer.rs | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/hang/src/container/consumer.holes.test.ts b/js/hang/src/container/consumer.holes.test.ts index d26d7f1e0fe..362fcd480a3 100644 --- a/js/hang/src/container/consumer.holes.test.ts +++ b/js/hang/src/container/consumer.holes.test.ts @@ -265,7 +265,11 @@ test.each([true, false])("the head after a declared end is waited for (arrives: }); group.finish(); }; - const frame = (group: bigint, timestamp: number) => ({ kind: "frame", group, frame: expect.objectContaining({ timestamp }) }); + const frame = (group: bigint, timestamp: number) => ({ + kind: "frame" as const, + group, + frame: expect.objectContaining({ timestamp }), + }); try { write(0n, 0); write(1n, 60_000, new Uint8Array()); diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index 3f30a6573d5..9264bc0c44c 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -2714,7 +2714,10 @@ mod tests { write_group(&mut track, 0, &[ts(0)]); write_marker_group(&mut track, 1, ts(60_000)); assert_eq!(consumer.read_frame().await.unwrap().unwrap().timestamp, ts(0)); - assert!(matches!(consumer.read().await.unwrap(), Some(Read::End { group: 1, .. }))); + assert!(matches!( + consumer.read().await.unwrap(), + Some(Read::End { group: 1, .. }) + )); write_group(&mut track, 3, &[ts(60_060_000)]); tokio::time::advance(Duration::from_millis(299)).await; assert!(consumer.poll_read(&kio::Waiter::noop()).is_pending()); From e4946839da28b7b976793d666a25e1eeca1fbfda Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 20:27:06 -0800 Subject: [PATCH 6/7] fix(hang): keep the pause through the end's drain packets A native publisher writes the stopped encoder's final packets after the end marker, in its group. Clearing the pause on any frame let the timestamp shortcut skip the next utterance's head again, so only a frame from a later group resumes it. Co-Authored-By: Claude Opus 5.5 --- js/hang/src/container/consumer.holes.test.ts | 29 +++++++++++--------- js/hang/src/container/consumer.ts | 10 ++++--- rs/moq-mux/src/container/consumer.rs | 20 +++++++++++++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/js/hang/src/container/consumer.holes.test.ts b/js/hang/src/container/consumer.holes.test.ts index 362fcd480a3..e7ee973e4c3 100644 --- a/js/hang/src/container/consumer.holes.test.ts +++ b/js/hang/src/container/consumer.holes.test.ts @@ -257,12 +257,14 @@ test.each([true, false])("the head after a declared end is waited for (arrives: results.push(read); } })(); - const write = (sequence: bigint, timestamp: number, payload = new Uint8Array([1])) => { + const write = (sequence: bigint, ...frames: [number, Uint8Array?][]) => { const group = track.createGroup(sequence); - group.writeFrame({ - payload: encodeFrame(payload, Micro(timestamp)), - timestamp: Time.Timestamp.fromMicros(Micro(timestamp)), - }); + for (const [timestamp, payload = new Uint8Array([1])] of frames) { + group.writeFrame({ + payload: encodeFrame(payload, Micro(timestamp)), + timestamp: Time.Timestamp.fromMicros(Micro(timestamp)), + }); + } group.finish(); }; const frame = (group: bigint, timestamp: number) => ({ @@ -271,21 +273,22 @@ test.each([true, false])("the head after a declared end is waited for (arrives: frame: expect.objectContaining({ timestamp }), }); try { - write(0n, 0); - write(1n, 60_000, new Uint8Array()); + write(0n, [0]); + // The end, then the stopped encoder's final packet, as a native publisher writes them. + write(1n, [60_000, new Uint8Array()], [40_000]); await flush(); - expect(results).toEqual([frame(0n, 0), { kind: "end", group: 1n, end: Micro(60_000) }]); - write(3n, 60_060_000); + expect(results).toEqual([frame(0n, 0), { kind: "end", group: 1n, end: Micro(60_000) }, frame(1n, 40_000)]); + write(3n, [60_060_000]); await flush(); await clock.advance(Nano.fromMilli(Milli(299))); - expect(results).toHaveLength(2); + expect(results).toHaveLength(3); if (arrives) { - write(2n, 60_000_000); + write(2n, [60_000_000]); await flush(); - expect(results.slice(2)).toEqual([frame(2n, 60_000_000), frame(3n, 60_060_000)]); + expect(results.slice(3)).toEqual([frame(2n, 60_000_000), frame(3n, 60_060_000)]); } else { await clock.advance(Nano.fromMilli(Milli(1))); - expect(results.slice(2)).toEqual([ + expect(results.slice(3)).toEqual([ { kind: "gap", timestamp: Micro(60_000), duration: Micro(60_000_000) }, frame(3n, 60_060_000), ]); diff --git a/js/hang/src/container/consumer.ts b/js/hang/src/container/consumer.ts index 3b09ca8673b..71519104ebf 100644 --- a/js/hang/src/container/consumer.ts +++ b/js/hang/src/container/consumer.ts @@ -191,8 +191,9 @@ export class Consumer { // Group of the last media frame next() returned, so an endpoint after it reads as that frame's // duration rather than a declared stop. #mediaGroup?: bigint; - // The last item read was a declared end, so the timeline is paused until a frame resumes it. - #paused = false; + // The group of the last declared end read, until a frame from a later group resumes the timeline. + // Not at the next frame: the stopped encoder's final packets may follow the end in its group. + #paused?: bigint; // Media went missing since the last item read, so the next one is preceded by a gap. #lost = false; // The furthest presentation point read so far: max(timestamp + duration), endpoints included. @@ -825,7 +826,7 @@ export class Consumer { const skipHole = head.frames.length > 0 && (maxDelay === 0 || - (!this.#paused && + (this.#paused === undefined && this.#presentedEnd !== undefined && head.latest !== undefined && head.latest - this.#presentedEnd > maxDelay)); @@ -1043,7 +1044,8 @@ export class Consumer { const edge = this.#edge; const lost = this.#lost; this.#lost = false; - this.#paused = read.kind === "end"; + if (read.kind === "end") this.#paused = read.group; + else if (this.#paused !== undefined && read.group > this.#paused) this.#paused = undefined; this.#advance(read.kind === "frame" ? Micro(resume + (read.frame.duration ?? Micro.zero)) : resume); if (!lost || edge === undefined) return read; diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index 9264bc0c44c..04868863fd1 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -2712,12 +2712,30 @@ mod tests { ); consumer.max_delay = Duration::from_millis(300); write_group(&mut track, 0, &[ts(0)]); - write_marker_group(&mut track, 1, ts(60_000)); + // The end, then the stopped encoder's final packet, as `moq_audio`'s producer writes them. + let mut group = track.create_group(moq_net::group::Info { sequence: 1 }).unwrap(); + let frame = |timestamp, payload| Frame { + timestamp, + payload, + keyframe: true, + duration: None, + }; + Container::Legacy(crate::container::Kind::Audio) + .write( + &mut group, + &[ + frame(ts(60_000), Bytes::new()), + frame(ts(40_000), Bytes::from_static(b"x")), + ], + ) + .unwrap(); + group.finish().unwrap(); assert_eq!(consumer.read_frame().await.unwrap().unwrap().timestamp, ts(0)); assert!(matches!( consumer.read().await.unwrap(), Some(Read::End { group: 1, .. }) )); + assert_eq!(consumer.read_frame().await.unwrap().unwrap().timestamp, ts(40_000)); write_group(&mut track, 3, &[ts(60_060_000)]); tokio::time::advance(Duration::from_millis(299)).await; assert!(consumer.poll_read(&kio::Waiter::noop()).is_pending()); From c6f402e9454539d2924599c3a5e412ef439ff9e5 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 6 Nov 2026 21:29:33 -0800 Subject: [PATCH 7/7] test(hang): a resumed read proves a later hole without a wait Co-Authored-By: Claude Opus 5.5 --- js/hang/src/container/consumer.holes.test.ts | 7 +++++++ quest/m1/push-to-talk-latency.md | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/hang/src/container/consumer.holes.test.ts b/js/hang/src/container/consumer.holes.test.ts index e7ee973e4c3..1562e8080da 100644 --- a/js/hang/src/container/consumer.holes.test.ts +++ b/js/hang/src/container/consumer.holes.test.ts @@ -286,6 +286,13 @@ test.each([true, false])("the head after a declared end is waited for (arrives: write(2n, [60_000_000]); await flush(); expect(results.slice(3)).toEqual([frame(2n, 60_000_000), frame(3n, 60_060_000)]); + // Resumed, a later hole past the budget is proven again without a wait. + write(5n, [61_000_000]); + await flush(); + expect(results.slice(5)).toEqual([ + { kind: "gap", timestamp: Micro(60_060_000), duration: Micro(940_000) }, + frame(5n, 61_000_000), + ]); } else { await clock.advance(Nano.fromMilli(Milli(1))); expect(results.slice(3)).toEqual([ diff --git a/quest/m1/push-to-talk-latency.md b/quest/m1/push-to-talk-latency.md index 31c5f915ba1..da675e8ed15 100644 --- a/quest/m1/push-to-talk-latency.md +++ b/quest/m1/push-to-talk-latency.md @@ -47,8 +47,9 @@ head was not decoded"): 2 of 22 on the default 20 ms Opus and 1 on 60 ms. The group after a head could overtake it, and the read took the mute's timestamp jump as proof the head was too late to wait for; [moq-dev/moq#8123](https://github.com/moq-dev/moq/pull/8123) fixed it, and two -20 ms runs after the fix kept all 44 heads. What remains is to switch the page to the defaults, measure on `kixtop` again, -and set and enforce the budget. +20 ms runs after the fix kept all 44 heads. What remains is to switch the +page to the defaults, measure on `kixtop` again, and set and enforce the +budget. Measured 2026-11-05 on the defaults, before Watch, one run of 22 presses each, Chromium 156 headless through a local relay. `kixtop` is a MacBook Air