Skip to content

A replayed media file never repeats a timestamp - #113

Merged
kixelated merged 3 commits into
mainfrom
quest/m0/media-replay-timestamps
Nov 8, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m0/media-replay-timestamps

Conversation

@kixelated

@kixelated kixelated commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

When a media source starts over while it's on program, it now publishes picture timestamps that always increase. publish::tests::a_media_file_is_published_on_one_timeline passes on every run.

Root cause

This is a real bug in rs/moq-scene/src/source.rs. The test doesn't read too early. Media pictures are encoded onto the source's own track one bus latency (50 ms) before they show, and each is stamped with the time it will show. When feed.play() restarts the clip, the cut clears the pictures waiting to be displayed. A picture handed over just before the cut is already on the track, though. The new play starts at now + BUS_LATENCY, which can be that same moment. The failing runs show this: ... 10450ms, 10550ms, 10550ms, 10650ms ....

Caused by

Fix

Own now records when the last picture encoded onto the track shows (stamped). After a cut, the new play starts at whichever is later: now + BUS_LATENCY or stamped + 1 ms. Loops aren't affected, because each loop already starts where the last play ended.

Verification

  • Before: 5 of 6 runs failed on main at 4c4a219 (macOS).
  • After: 10 of 10 runs passed, and just ci passes.
  • After merging main at the new moq pin (moq-dev/studio#104): 8 of 8 runs passed, and just ci passes.

Choices made without asking

  • The new play starts 1 ms after the last stamp. That matches the timer wheel's granularity, which ahead already accounts for.
  • The flake is entirely in studio code, so nothing needs to go to moq.

Decisions

  • A picture cut off by a restart stays on the published track: it was encoded one bus latency ahead, never shows on program, and is at most 50 ms long. Timestamps still always increase. ✅ (a) accept it (rejected: (b) encode each picture when it shows, which would restructure media's display loop and drop encoding ahead). Maintainer, 2026-11-08.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with low)

Review

Rewritten by quest review after each round.

  • Reviewer: Codex, gpt-6.1-sol, medium effort
  • Session: 01a1bc60-8dab-7252-a4f6-84c8ec0132cc, round 1
  • Head: ef33e9d
  • Base: origin/main at 4558d7a
  • Score: 9/10, The change preserves increasing publication timestamps across media restarts without shifting continuous loops, with no actionable defects found by source inspection and runtime validation remaining outside this review.
  • Findings: none

@pullfrog

pullfrog Bot commented Nov 8, 2026

Copy link
Copy Markdown

Pullfrog  | Review this ➔

A cut's play begins after the last picture already encoded onto the
media source's own track. Pictures encode a bus latency ahead of when
they show, so one handed over just before a restart was published at
the same moment the restart's keyframe was stamped with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 8, 2026 18:17
@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown

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 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review 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: 8d3b63a7-548a-4213-b35b-66cbda394a24
Commits

Reviewing files that changed from the base of the PR and between 4558d7a and ef33e9d.

Files selected for processing: 3

  • quest/m0/README.md
  • quest/m0/media-replay-timestamps.md
  • rs/moq-scene/src/source.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 (squash) November 8, 2026 18:20

@kixelated kixelated left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed head: ef33e9d

No new defects found in the interrupted-play fix. I read source.rs in full, followed the publication/encoder timestamp paths, and checked the existing media restart and A/V tests. Own retains the last submitted picture's show time across cuts; a fresh play selects a later begin, shared by both audio and video. Continuous loops keep their existing scheduled begin rather than accumulating the restart adjustment. The strict timestamp assertion remains unchanged. This respects the recorded decision to leave an already-encoded, subsequently cut picture on the published track.

Separate pre-existing follow-up, not a defect introduced by this PR: a video-only file that decodes to one picture gets a zero final-picture duration at rs/moq-scene/src/source.rs:1726. With looping enabled, next = Some(end) at :1552 then reuses the same begin, so successive loops can submit the same timestamp. The importer does not exclude this input. A separate fix should establish the lone frame's duration and cover that input; the same behavior is present on the base branch.

Direction: no revisions requested for this cut/restart change. Keep the single-frame loop-duration issue separate.

Verification limits: GitHub-only static review. I did not run quest context, builds, tests, or reproduce either scenario. The repeated-run and just ci results are reported by the author, not independently verified here. The Check workflow for this head was in progress when inspected.

@kixelated kixelated mentioned this pull request Nov 8, 2026
@kixelated
kixelated merged commit 0cc4c65 into main Nov 8, 2026
4 checks passed
@kixelated
kixelated deleted the quest/m0/media-replay-timestamps branch November 8, 2026 18:38
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