Skip to content

fix(watch): a buffered audio head waits at most the max delay - #9267

Open
kixelated wants to merge 1 commit into
mainfrom
fix/watch-order-hold-expiry
Open

kixelated wants to merge 1 commit into
mainfrom
fix/watch-order-hold-expiry

Conversation

@kixelated

@kixelated kixelated commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A buffered subscription's audio Order holds the head until it's complete: a newer group arrives, the first group runs past the floor, or the held timestamps span the max delay. All three wait on timestamps advancing. A publisher that repeats one timestamp, or on release keeps sending older groups within that span, never triggers any of them. A viewer's tab keeps every frame it receives.

Approach

Do as Rust's start gate in moq-audio does ("a packet waits at most the hold, which bounds what the gate keeps by arrival time, whatever the timestamps say"): the head is also released once it has waited the max delay since its first frame arrived, read from @moq/clock. What the hold keeps is then bounded by what the network delivers in that time, with no new constant.

The bound is the max delay rather than the floor: a zero floor still holds the head for its older groups, and every existing release path is unchanged.

Impact

  • No public API or wire change.

Validation

  • New Order test: 100 frames repeating one timestamp stay held until the manual clock reaches the max delay, then release together. It fails without the wall-clock release.
  • The existing Order tests now run on a Manual clock, since the hold reads the time.
  • just check passes.
  • Not run in a browser.

Caused by

  • moq-dev/moq#6549 - added the hold, releasing it only as timestamps advance (found by reviewer)

Alternatives

  • Treat a non-advancing frame as a publisher violation and release the hold. Bounds repeats within a group but not 1 µs steps; the arrival-time bound covers both.
  • Cap the held frames or bytes. A constant, and codec-specific.

Follow-ups

  • Backport to release, where Order is the same apart from number timestamps.

Models

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

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 016801d

  • Base: origin/main at f839672

  • Risk: medium, The audio ordering change could release buffered frames earlier and affect playback for watch users, but it preserves the public API and wire format and is fully undone by a revert.

  • Classified: medium by Codex, gpt-6.1-sol, low effort, session 01a1fbaa-04bd-75e3-9b00-7a3a1f1da2da

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

  • Session: 01a1fbaa-1815-7f30-823f-04eff0719c1a, round 1

  • Score: 9/10, No actionable regressions were found in the focused change, which includes a deterministic clock-based regression test, though builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

The hold released only as timestamps advanced, so a publisher repeating
one timestamp grew it without bound. Release it once it has waited the
max delay too, as Rust's gate bounds what it keeps by arrival time.

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

coderabbitai Bot commented Nov 21, 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 2 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: fac9404a-4e80-4dbd-a14d-dadd46b2c9c8
Commits

Reviewing files that changed from the base of the PR and between f839672 and 016801d.

Files selected for processing: 2

  • js/watch/src/audio/order.test.ts
  • js/watch/src/audio/order.ts
  • 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

@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. It bounds the held head by arrival time, the same way Rust's start gate in moq-audio does, and adds no new constant.

Reviewed changes

I reviewed the full diff: js/watch/src/audio/order.ts and its test.

  • Wall-clock release in Order.push: #first now records arrived from @moq/clock's now(). The head also flushes once now().since(arrived) reaches maxDelay. The existing ran and span release paths are unchanged.
  • Tests: the existing Order tests now run on an installed Manual clock. A new test pushes 100 frames with one repeated timestamp. They stay held until the clock has advanced the max delay, then all 102 release together, and later frames pass straight through.

I checked that now, Instant.since, Manual.install and the @moq/clock/test export all exist. The test's boundary arithmetic holds: 999µs still holds, and the extra 1µs releases.

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

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