Skip to content

test(mediaplayer): align bridge timing slack with the re-sync threshold - #991

Merged
srperens merged 1 commit into
mainfrom
test/mediaplayer-bridge-timing-slack
Oct 5, 2026
Merged

srperens merged 1 commit into
mainfrom
test/mediaplayer-bridge-timing-slack

Conversation

@srperens

@srperens srperens commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Refs #957

Problem

a_live_timeline_with_a_stall_plays_on_time_in_the_main_pipeline and playback_carries_on_in_time_after_a_file_switch fail on nearly every macOS CI run. I scanned ~30 failed runs on main and PRs: every Build (macOS) failure was one or both of them, always with "arrived N ms after its time", where N was 150–240 ms (once 395 ms). Every green run I checked had skipped the macOS job.

There are two causes, both in the tests:

  • The tests allowed 150 ms of lateness, but the bridge only re-syncs a buffer once it is more than LATE_RESYNC_NS (250 ms) late. Lateness between 150 and 250 ms is allowed by design, and the tests treated it as a failure.
  • The stall test paced its pushes with relative sleep(20ms) calls, so sleep overruns on a loaded runner added up. The failing buffer was often from before the stall (e.g. buffer 6).

Change

Test-only change:

  • SLACK_NS = timing::LATE_RESYNC_NS + 50 ms in both tests: what the bridge allows, plus a margin for the hop through the main pipeline.
  • The stall is now 800 ms instead of 400 ms. Without the re-sync, the buffers after it are ~700 ms late, well clear of the 300 ms slack.
  • Each push now waits for its own deadline from the first push, so an overrun does not delay every later buffer.

Rejected:

  • #[serial]: it only serializes against other #[serial] tests, and the rest of the suite still runs in parallel.
  • Skipping the tests on macOS: they would then guard nothing there.

Evidence

  • The stall test still guards the re-sync. I forced Timing::place to never re-sync and the test failed with buffer 15 arrived 705 ms after its time in the main pipeline.
  • The flake is load, not macOS behaviour: on an otherwise idle Mac, the old test passed 10/10 runs alone.
  • Whether CI passes reliably now is unverified until the ci:macos run on this PR finishes.

Tests

Ran (macOS, local): cargo test --lib mediaplayer::bridge::tests, 13 passed. cargo fmt --check and cargo clippy --all-targets are clean.
Not run: the full suite locally. The macOS and Windows CI jobs run through the ci:macos label.

Out of scope

The tests are still wall-clock based. If the runner stalls the test's own measurement for more than ~300 ms, they can still fail.

🤖 Generated with Claude Code

The stall and file-switch tests allowed 150 ms of lateness, while the
bridge itself lets a buffer run up to LATE_RESYNC_NS (250 ms) late before
it re-syncs. On the loaded macOS CI runner buffers land 150-240 ms late,
so both tests failed on nearly every macOS run.

Take the slack from LATE_RESYNC_NS plus 50 ms for the hop, lengthen the
stall to 800 ms so a removed re-sync still fails by a wide margin, and
pace the pushes on absolute deadlines so sleep overruns do not add up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srperens srperens added the ci:macos Run Build (macOS) on this pull request label Oct 5, 2026
@srperens
srperens merged commit 2ba2b86 into main Oct 5, 2026
17 of 18 checks passed
@srperens
srperens deleted the test/mediaplayer-bridge-timing-slack branch October 5, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:macos Run Build (macOS) on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant