Skip to content

fix(publish): a range with an end replays the whole retained audio, as in Rust - #9511

Merged
kixelated merged 14 commits into
mainfrom
quest/m0/interop-green/firefox-replacement
Nov 24, 2026
Merged

kixelated merged 14 commits into
mainfrom
quest/m0/interop-green/firefox-replacement

Conversation

@kixelated

@kixelated kixelated commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/interop-green/firefox-replacement.md: the Nightly's moq-lite-06 fallback on Firefox takes 717 to 1028 ms on ubuntu-24.04-arm against its 1039 ms bound. Nothing drops audio. Each lite-06 join makes the incumbent's audio encoder replay its 2.13 s Max Age of retained PCM before it encodes any live audio.

Following the maintainer's decisions, this PR keeps that replay and pins it with tests in both languages, fixes JS replaying too little for a range with an end, and closes the quest: the replay is what a lite-06 join asks for, and the fallback passed 20 of 20 focused ARM runs.

Problem

A lite-06 SUBSCRIBE can't say how far behind live its player wants to start. The relay forwards it upstream as a live join with no lag limit. On ARM the relay's trace shows the fallback viewer's audio join as Live { min: None, max: Some(2.13s) } (15 of 25 lite-06 audio joins; the rest carry 2.08 s). The player's Max Age reaches 2 s past its delay so its jitter estimator sees every arrival (js/watch/src/audio/decoder.ts #runSubscribeMaxDelay).

By default a JS publisher keeps raw PCM while nobody listens (onDemand: "retain"). It encodes the replay in time order before the first live frame. That is about 300 ms of Opus on ARM, and the player skips that history as it trails the clock (skipping missing groups: track=audio).

Decisions

  • Maintainer, 2026-11-23 (comment): ✅ a join with no lag limit replays retained audio according to its Max Age (rejected: (a) live audio only; (b) replay with live audio encoded first; (c) keep replaying the whole retained window). A Live range with no Min Age starts from the oldest group but drops anything older than its Max Age. So the replay budget is the retained audio within Max Age, and the whole retention only when Max Age is also none. This replaces the option (a) the PR first implemented.
  • Maintainer, 2026-11-23 (comment): ✅ the lite-06 replay is correct, since a lite-06 join asks for its oldest group plus a 2.13 s Max Age and gets exactly that; land this PR and delete the firefox-replacement quest on the 20 of 20 ARM passes (rejected: a follow-up to encode live audio before the replay; a looser lite-06 bound; replaying nothing). The epic README's Plan records the 2.13 s Max Age and the 719–1028 ms ARM fallback.

Approach

  • js/publish/src/audio/encoder.ts replayBudget and rs/moq-audio/src/encode/producer.rs replay_budget give a join with no lag limit its Max Age, and the whole retention when Max Age is none too. Rust's code matches main; only its comment changed.
  • JS now treats a range with an end as history, which wants the whole retention, as Rust already did. Since moq-dev/moq#9409, JS bounded such a range by its max.
  • Tests: a no-lag join with Max Age 130 ms replays from frame 143 of 150 (Rust and JS), and one with no Max Age replays the whole retention (Rust and JS). In JS, a no-lag join with an end also replays the whole retention. These replace the option (a) test that expected live audio only.
  • doc/lib/js/publish.md and doc/lib/rs/moq-audio.md state the rule.
  • Deletes quest/m0/interop-green/firefox-replacement.md. The epic README's Plan records the finding, and firefox-arm-resume.md drops its link and keeps the replay ruled out as the page stop's cause.

Impact

  • Public API: none. Wire: none.
  • Behavior: a JS publisher that retains audio now replays the whole retention to a range with an end, instead of only its max. Joins with no end behave as on main.

Validation

ARM (ubuntu-24.04-arm, the Nightly's class), through a temporary pull_request workflow like moq-dev/moq#9494's, deleted from the branch. Focused just test media --media-engines firefox --media-cases replacement, 5 runs per job:

Code Focused passes lite-06 fallback lite-07 fallback moq-transport fallback Run
base (main + timing logs) 20 / 20 717–1023 ms 45296112340
option (a), replay nothing 10 / 10 217–323 ms 219–321 ms 213–317 ms 45304404751
this PR (Max Age rule) 20 / 20 719–1028 ms 314–438 ms 214–319 ms 45309593159

In the last run, two of the four jobs ran the relay at moq_net=trace. Those trace jobs measured 719–1028 ms and the plain jobs 721–924 ms. The trace shows the Max Age above.

Local (x86):

  • cargo test -p moq-audio --features capture replay: 4 pass.
  • bun test src/audio/encoder.test.ts in js/publish: 61 pass. With option (a)'s replayBudget restored, the new Max Age case fails (demand replays only the retained audio a join with no lag limit's max still wants).
  • just check origin/main passes.
  • At ede9e1e (quest Markdown only on top of 98a8f99), quest check passes, and so does just check origin/main except test rs. That step timed out 4 tests in each of two runs, different ones each time, all while mbx: waiting for machine-wide scheduler capacity before starting this test (host load 37), so they never started. The 1146 that ran passed. CI runs them.

Caused by

  • moq-dev/moq#9409: rewrote JS replayBudget and dropped its range.end check, so a range with an end replayed only its max (found by reviewer).

Notes

  • Coordination: moq-dev/moq#9492 edited this quest's file and landed first. moq-dev/moq#9501's firefox-arm-resume gets only an evidence paragraph here.
  • The lifecycle player's resume also joins over lite-06 and pays the same replay. Option (a)'s run still saw rejoin reaches live fail once in 6 full Firefox runs, so the replay doesn't explain that page stop; firefox-arm-resume.md records this.

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, high effort
Implementer: Claude Code, claude-opus-5-5, high effort (iterate)
Implementer: Claude Code, claude-opus-5-5, high effort (iterate, M)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with high)

Review

Rewritten by quest review after each round.

  • Head: ede9e1e

  • Base: origin/main at d80be44

  • Risk: medium, If it breaks, the audio a late subscriber receives changes: a join with no lag limit now gets only the retained audio within its max instead of the whole retention, and a range with an end now replays the whole retention, in the shipped `@moq/publish` encoder (`js/publish/src/audio/encoder.ts`) and `moq-audio` (`rs/moq-audio/src/encode/producer.rs`), so a viewer could get less or more history than before, and a revert of the code restores the old replay. This is a behavior fix that keeps the API and wire format, so it is medium rather than high; the rest is docs, tests, and quest plans (low).

  • Classified: medium by Claude Code, claude-haiku-5-5, low effort, session 91d02ca7-91da-46d0-9cb4-e69dcaceed76

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a20b3a-dce0-79d2-9f22-b11540afd7fe, round 4

  • Score: 10/10, The incremental changes only update quest notes and remove the completed quest without leaving references to it; no new findings remain.

  • Rounds: 5; first round 0; findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

kixelated and others added 9 commits November 23, 2026 16:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…audio

A join with no lag limit, as every join before moq-lite-07 is, states no
playout target, so encoding its whole max first only held the live edge
back by that encode, for history its player skips.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…urvives the replay fix

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Firefox plays a live replacement and its fallback within the bound fix(publish,moq-audio): a join with no lag limit replays no retained audio Nov 24, 2026
…Rust

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

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (via /quest-run, 2026-11-23): a join with no lag limit replays retained audio according to its Max Age (rejected: (a) live audio only; (b) replay with live audio encoded first; (c) keep replaying the whole retained window). A Live range with no Min Age starts from the oldest group but drops anything older than its Max Age, so the replay budget is the retained audio within Max Age, and all of the retained window only when Max Age is also none.

(Written by Claude Opus 5.5)

kixelated and others added 3 commits November 23, 2026 18:03
…io within its max

Maintainer decision on #9511: a Live range with no Min Age starts from the
oldest group but drops anything older than its Max Age, so its replay budget
is the retained audio within Max Age, and the whole retention only when Max
Age is also none. Keeps JS treating a range with an end as history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ay remains under the Max Age rule

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title fix(publish,moq-audio): a join with no lag limit replays no retained audio fix(publish): a range with an end replays the whole retained audio, as in Rust Nov 24, 2026
@kixelated

Copy link
Copy Markdown
Collaborator Author

Applied the decision at 98a8f99: a join with no lag limit replays the retained audio within its Max Age, and the whole retention when Max Age is also none, in both replayBudget (JS) and replay_budget (Rust). Tests cover both cases. JS keeps treating a range with an end as history.

On ARM (run 45309593159), the lite-06 fallback viewer's audio join carries Live { min: None, max: Some(2.13s) }. So the replay matches main, and the fallback took 719–1028 ms against the 1039 ms bound (main: 717–1023 ms; replaying nothing: 217–323 ms). The PR's ## Waiting asks how to remove that cost under the rule, with a recommendation.

(Written by Claude Opus 5.5 with high)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (via /quest-run, 2026-11-23): the lite-06 replay is correct: a lite-06 join asks for its oldest group plus a 2.13 s Max Age, and gets exactly that. ✅ Land this PR (the Max Age rule and the JS end fix) and delete the firefox-replacement quest, since 20 of 20 ARM runs pass (rejected: a follow-up to encode live audio before the replay; a looser lite-06 bound; replaying nothing). Merge pick: /quest-merge.

(Written by Claude Opus 5.5)

The maintainer decided a lite-06 join gets exactly what it asks for (its
oldest group plus a 2.13 s Max Age), and 20 of 20 ARM runs pass. The epic
README records the measurement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 24, 2026 02:55
@kixelated

Copy link
Copy Markdown
Collaborator Author

Applied the decision in ede9e1e: it deletes quest/m0/interop-green/firefox-replacement.md and its link from firefox-arm-resume.md. The epic README's Plan now records the 2.13 s Max Age a lite-06 join asks for and the 719 to 1028 ms ARM fallback (20 of 20 runs passed). The decision is recorded under ## Decisions. Local review: Codex gpt-6.1-sol, round 4, 10/10, no findings.

(Written by Claude Opus 5.5 with high)

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 32222bd5-a6ae-45f4-9961-6b1b66c2a437
Commits

Reviewing files that changed from the base of the PR and between c262012 and ede9e1e.

Files selected for processing: 8

  • doc/lib/js/publish.md
  • doc/lib/rs/moq-audio.md
  • js/publish/src/audio/encoder.test.ts
  • js/publish/src/audio/encoder.ts
  • quest/m0/interop-green/README.md
  • quest/m0/interop-green/firefox-arm-resume.md
  • quest/m0/interop-green/firefox-replacement.md
  • rs/moq-audio/src/encode/producer.rs
  • 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

@kixelated
kixelated enabled auto-merge November 24, 2026 02:56

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound. Adding a range.end check to JS replayBudget brings it back in line with Rust's replay_budget, which only bounds (Start::Live { .. }, None). The no-lag-limit rule (bound by max, whole retention when max is also none) is now pinned by tests in both languages.

Reviewed changes

I reviewed all 8 files at ede9e1e: the JS and Rust replay-budget logic, their tests, the docs and the quest notes.

  • JS replayBudget end check: a range with an end now returns undefined, so it replays the whole retention. Range.end is typed bigint | undefined in js/net/src/track.ts, so !== undefined covers every case.
  • Rust replay_budget doc: the comment now describes what the code already did: min.into_iter().chain(max).min(), where min: None falls back to max.
  • Tests: these cases are covered in both languages: a no-lag join with a 130 ms max replays from frame 143, and a join bounded by neither lag nor max replays from frame 0 (all 150 frames in JS). JS also tests that a join with an end replays all 150 frames. Rust's replays_from now takes the expected first frame.
  • Docs: doc/lib/js/publish.md and doc/lib/rs/moq-audio.md now state the rule for joins with no lag limit.
  • Quest notes: firefox-replacement.md is deleted. The epic README and firefox-arm-resume.md record the ARM measurements and the decision.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 34e760d Nov 24, 2026
6 checks passed
@kixelated
kixelated deleted the quest/m0/interop-green/firefox-replacement branch November 24, 2026 03:02
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