Skip to content

fix(publish): replayed audio groups at the declared interval, not the live join - #9552

Draft
kixelated wants to merge 2 commits into
mainfrom
fix/lite06-incumbent-fallback
Draft

kixelated wants to merge 2 commits into
mainfrom
fix/lite06-incumbent-fallback

Conversation

@kixelated

@kixelated kixelated commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Scheduled Interop run 45253796046 (Chromium x64) failed live incumbent fallback plays on moq-lite-06. The player's audio never started within the 1039 ms bound (audioStalled, audioTimestamp: 0), and the incumbent logged reset a lower stream to make room. Per the 2026-11-23 decision (moq-dev/moq#9511), a lite-06 join correctly replays 2.13 s of retained audio. At the 20 ms audio join that replay is 106 one-frame groups, so 106 streams at every hop. That's more than the 100 a peer grants by default, so the live edge queued for stream credit behind history that the player then skipped as stale.

Approach

@moq/publish groups replayed history as coarsely as the catalog's sync.interval promises (Broadcast.join, the longest group of any rendition, so the HLS/DASH grid holds). Live audio keeps its join. The fixture's 500 ms GOP turns the 2.13 s replay into 5 streams instead of 106. An audio-only broadcast declares its own join as the interval, so nothing changes there. The replay mark (#history) is now set before each submit, so a codec that emits within encode() still sees its frame as history.

This stays within the recorded decision: the join still gets all 2.13 s, live audio is not encoded first, and the bound is unchanged.

Impact

  • No public API or wire change. Behavior: replayed retained audio arrives in groups up to the catalog interval long; live groups are unchanged.

Validation

Focused case: just test media --media-engines chromium --media-cases replacement, pinned with taskset. Logged timestamps (removed before commit) on the incumbent's encoder and the viewer's groups, ring, and stall state.

setup lite-06 fallback before after
4 cores 315, 321, 419, 421, 429 ms 220, 236, 314 ms
4 cores, relay grants 40 streams 746 ms 223 ms
2 cores 568 ms 339, 375, 434 ms (one-group prototype)

lite-07 and moq-transport stay at about 210 to 330 ms in both. Where the time went before (4 cores, from withdraw): routing 50 to 75 ms, then the incumbent's 105 history outputs over ~90 ms. A standalone AudioEncoder does 106 Opus frames in ~8 ms, so that cost is page contention, not the codec. The live edge then reached the viewer ~60 to 110 ms later behind the history streams, with holes the viewer skipped. Under the 40-stream relay, live groups arrived in bursts at 471 ms and 629 ms. With the fix, the viewer un-stalls ~30 ms after the live frame is encoded. Some pinned runs failed audio tone or lifecycle player returns on other versions, before and after the change alike: CPU starvation from the pinning.

Unit: replayed audio groups at the declared interval and live audio at its join fails without the fix (one frame per group) and passes with it. just ci passes.

Caused by

  • As old as the retained-audio replay: history always grouped at the live join. It crossed the default stream credit once lite-06 joins replayed their full Max Age, which moq-dev/moq#9511 kept as correct (found by check: scheduled Interop).

Alternatives

  • Loosen the lite-06 bound, encode live first, replay nothing: rejected by the 2026-11-23 decision.
  • One group for the whole replay: measured equally fast, but breaks the catalog's sync.interval promise that HLS/DASH export cuts segments on.
  • Raise the stream credit: only moves the cliff; a longer Max Age crosses it again.

Decisions

  • Decided 2026-11-24 (maintainer, /quest-plan): ✅ replayed history groups at the catalog's declared sync.interval (rejected: one group for the whole replay, which breaks the interval HLS/DASH export cuts on).
  • Decided 2026-11-24 (maintainer, /quest-plan): ✅ keep quest/m3/audio-replay-groups.md as its own m3 quest (rejected: fold into this PR, drop).

Follow-ups

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

… live join

A lite-06 join replays 2.13 s of retained audio, which at the 20 ms join
took 106 one-frame groups: a stream each at every hop, over the 100 a peer
grants by default, so the live edge queued for credit behind history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as draft November 24, 2026 18:15
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The encoder groups retained audio according to the broadcast join interval and continues to group live audio according to the encoder join. Replay history is recorded before retained frames are submitted. A regression test checks replay and live grouping. Documentation describes the behavior and reports an interop failure and a proposed Rust counterpart.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 53fb7

Retained audio replay is now grouped at the catalog's declared interval, while live audio groups keep their existing join. The change is small and covered by a regression test, and no concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: replayed (retained) audio is now grouped at the catalog's declared sync interval instead of the live audio join. This matches the raw summary of encoder.ts and the enc…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description explains the problem (a failed lite-06 Interop test where replayed audio created 106 one-frame groups that exceeded the default stream credit), the approach (grouping replayed audio at…
Full details: Title check

Explanation

The title names the main change: replayed (retained) audio is now grouped at the catalog's declared sync interval instead of the live audio join. This matches the raw summary of encoder.ts and the encoder test, and the PR objectives. It is specific and scoped to the publish package.

Full details: Description check

Explanation

The description explains the problem (a failed lite-06 Interop test where replayed audio created 106 one-frame groups that exceeded the default stream credit), the approach (grouping replayed audio at the catalog's sync.interval while live audio keeps its join), the validation, and the alternatives considered. This matches the changeset, which changes encoder.ts replay grouping, adds a regression test, and updates the docs and quest notes.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ac92b5ab-28f7-4803-ac4d-016c2dc2685f
Commits

Reviewing files that changed from the base of the PR and between 5d86f05 and 53fb75b.

Files selected for processing: 5

  • doc/lib/js/publish.md
  • js/publish/src/audio/encoder.test.ts
  • js/publish/src/audio/encoder.ts
  • quest/m0/interop-green/README.md
  • quest/m3/audio-replay-groups.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant