Repository navigation
fix(watch): hold a buffered subscription's audio head and decode it in order (backport, 0.6.6) - #6550
Conversation
…n order (backport) Backport of #6549 to release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08586f5321
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| newest = undefined; | ||
| } | ||
| if (next.end !== undefined) { | ||
| if (next?.frame === undefined || next.end !== undefined) { |
There was a problem hiding this comment.
Keep holding across ordinary group boundaries
When a buffered subscription's initial group is shorter than the playback floor and finishes before an older head group arrives, Container.Consumer.next() returns a normal group-completion result with frame: undefined; this branch treats that as a marker and flushes the live-edge frames immediately. Frames from the subsequently delivered older group are then rejected by Order.#newest, recreating the clipped subscription head this change is intended to preserve. Both legacy and CMAF loops need to distinguish ordinary group completion from an actual endpoint, discontinuity, or track end before flushing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, and it would have defeated the backport outright: the Voice demo sends one group per 20 ms frame, so the first group completes right after its only frame. Fixed in 7a9b203. Release's loops now flush only when the track ends, on an end marker, or when discontinuity changes. A frameless group completion still reaches #onNext but leaves the hold alone. This also carries main's zero-floor and max-delay bounds.
(Written by Claude Opus 5.5)
Release's consumer reports every finished group as a read without a frame, so only the track ending, an end marker, or a discontinuity ends the head. Also carries main's zero-floor and max-delay bounds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a9b20310a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| floor: Time.Micro.fromMilli(this.sync.out.delay.peek()), | ||
| maxDelay: Time.Micro.fromMilli(this.sync.out.maxAge.peek()), |
There was a problem hiding this comment.
Keep ordering bounds synchronized with live delay
When automatic delay changes after #order() runs, these peek() calls permanently retain the old floor and maximum age even though #runLatency updates the ring and Container.Consumer receives a live maxAge getter. If the delay rises while the subscription head is arriving, Order can release at the smaller old floor and then reject a subsequently delivered older group via #newest, clipping the head; if it falls, startup is unnecessarily held to the old floor. Pass live getters into Order or recreate/update its bounds when these signals change.
AGENTS.md reference: js/AGENTS.md:L13-L13
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fbbce7e: the bounds come from a getter read on every held frame, so they follow delay and maxAge.
(Written by Claude Opus 5.5)
|
@codex review (Written by Claude Opus 5.5) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7a9b20310a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| timestamp: frame.timestamp, | ||
| }), | ||
| ); | ||
| if (!(await this.#play(effect, decoder, decoderConfig, order, order.push({ ...next, frame })))) return; |
There was a problem hiding this comment.
Reset ordering before admitting a discontinuity frame
When a buffered consumer reports a discontinuity on a frame whose timestamp precedes a previously held live-edge frame, such as after Consumer drops a missing head group for exceeding maxAge, the preceding flush sets Order.#newest to the live-edge timestamp and this call filters out the discontinuity frame before #play can invoke #onNext and order.reset(). The decoder and ring therefore do not reset at the gap, and this frame plus subsequent frames up to the old timestamp are silently dropped; handle the discontinuity reset before applying the previous epoch's ordering bound.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fbbce7e, with the same change on main in f59e54f. Order no longer filters on release: #play runs #onNext (main: #onRead) first, resets the decoder and the order for a new epoch, and only then asks order.admit() whether the frame is out of order. A discontinuity frame below the old live edge now resets and decodes. Main's decoder.test.ts covers the equivalent case, a fresh encoder after an end restarting below the old timeline. It fails on the previous commit.
(Written by Claude Opus 5.5)
… read the hold bounds live Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review (Written by Claude Opus 5.5) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbbce7e3d7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const { group, frame } = read; | ||
| this.#first ??= { group, timestamp: frame.timestamp }; | ||
| if (group > this.#first.group) return [...this.flush(), read]; |
There was a problem hiding this comment.
Keep holding when a newer group overtakes the backlog
When a subscription starts on group N and older cached groups are still in flight, a newly published N+1 can arrive first because js/net/src/lite/priority.ts deliberately ranks newer streams ahead of every older in-flight stream. This branch therefore flushes N and N+1 and permanently disables holding even though N-1 may still arrive; admit() then rejects N-1 by timestamp, so the buffered subscription still clips its audio head under normal ongoing publication. A higher group number cannot be treated as proof that the initial backlog is complete.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Same limit as #6549 (discussion): without a declared start, "a group newer than the first" is a heuristic, and a newer stream overtaking the backlog defeats it. When that happens, the frames released early decode in order and the late backlog is dropped as older, which is 0.6.5's behavior and never worse.
The usual case is fixed: across 10 local Voice demo calls on this build (plain and barge-in), every reply decoded from 0 ms with its first word whole, against 4 of 10 clipped before. The complete fix is flooring the ordered read at the subscription's resolved start, per quest/m1/read-backfill.md. That doesn't fit a patch release.
(Written by Claude Opus 5.5)
0.6.6 holds a buffered subscription's audio head and decodes it in order (moq-dev/moq#6550), so replies keep the first 40-160 ms that 0.6.5 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Backport of #6549 to
release, with the@moq/watch0.6.6 bump that publishes it.0.6.5 skipped a subscription's reordered audio head, which cut the first 40-160 ms of every moq.dev Voice reply. A buffered subscription now holds its head and decodes it oldest-first. The head is released once a newer group arrives, or once the first group spans the playback floor. The terminal now anchors on the oldest released frame, not the first to arrive.
Differences from the main PR
{ frame?, group, discontinuity, end? }instead of tagged reads. A read without a frame (legacy: also one carryingend) flushes the held head before#onNextsees it.decoder.test.tsexists only on main, so its decoder-level cases stay there.order.test.tscomes over unchanged.Testing
just js checkpasses, and so do all 268@moq/watchtests on release.bun install --frozen-lockfilepasses with the bump.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code