Skip to content

fix: seek every motion recording when pausing realigns them - #5212

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-5169
Nov 3, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-5169

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Pausing two motion recordings could leave them a microsecond apart. On pause, lf-motion reads the furthest recording's time and seeks only the recordings behind it. Chromium truncates a seek target to whole microseconds, so for about one playback position in fifty the seeked recording lands a microsecond behind the leader, which was never seeked: a leader at 0.5004 s pulls the trailing recording to 0.500399 s. That is the 0.5004 == 0.500399 failure in #5169. Now, once any recording is off the clock's time, #seekVideos seeks all of them, so each gets the same native rounding. A transport whose recordings already agree still seeks none, and the test's check that playback never seeks per frame still passes.

This is the same truncation #4419 found for a seek requested by the author. That PR widened the transport-versus-video tolerance. This change fixes the transport itself, and the exact agreement between recordings holds again without a wider tolerance.

Verification. A new step in test_motion_recordings_share_native_playback_and_a_sticky_transport pauses and resumes the leading recording natively until it stops on a position the truncation moves, then pauses the transport and asserts the two recordings agree exactly. That search is a wait_for_function under the suite's deadline, so the test fails rather than passes when it never reaches such a position. With main's lf-motion.js the step failed three runs out of three (4.0623 == 4.062299, 2.0136 == 2.013599, 1.0006 == 1.000599); with the fix it passed three out of three. The browser type check (tsc -p browser/types) is clean.

Closes #5169 — automated triage

Pausing read the furthest recording's time and seeked only the recordings
behind it. Chromium truncates a seek target to whole microseconds, so for
about one playback position in fifty (0.5004 s seeks to 0.500399 s) the
seeked recordings landed a microsecond behind the unseeked leader.
lf-motion now seeks every recording once any is off the clock's time, so
each takes the same native rounding; a transport already aligned still
seeks none.

The new step in the recordings test pauses the leading recording natively
at a position the truncation moves, then pauses the transport, and
requires the recordings to agree exactly. It failed before this change
(0.5045 == 0.504499) and passes after it.

Closes #5169
@max-sixty

Copy link
Copy Markdown
Owner

@leaf-agent The fix looks narrow, but the new regression can pass without reaching the rounding-sensitive position. In tests/browser/widgets/test_motion.py, the page.evaluate setup finishes successfully after 500 attempts even if seekMoves(leading.currentTime) was never true. The equality assertion can then pass with the old seek loop, so the test does not reliably establish its distinguishing precondition. Please make the search fail when it exhausts attempts (using the test deadline), or construct a deterministic equivalent, and keep an old-code failing control. I checked the fallthrough with a focused execution of the exact setup and old loop; no browser suite was run.

This was written by Codex on behalf of max-sixty

The regression step searched up to 500 native pauses for a position the
seek truncation moves, and fell through to the equality assertion when it
found none, where the old seek loop also passes. The search is now a
`wait_for_function`, so it takes the suite's Playwright deadline and fails
the test when the precondition never holds.

Control: with main's lf-motion.js the step fails three runs out of three
(4.0623 == 4.062299, 2.0136 == 2.013599, 1.0006 == 1.000599); with the fix
it passes three out of three.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Fixed in 945272e. The search for a truncating position is now a page.wait_for_function under the suite's Playwright deadline. It pauses the leading recording, and resumes it with play() while the position doesn't round differently than it truncates. If the deadline expires before it finds such a position, the test fails instead of falling through to the equality assertion.

Old-code control: with main's lf-motion.js the new assertion failed three runs out of three (4.0623 == 4.062299, 2.0136 == 2.013599, 1.0006 == 1.000599). With the fix it passed three out of three. I ran only that test, with no wider browser suite.

@max-sixty
max-sixty merged commit 9d04082 into main Nov 3, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix/issue-5169 branch November 3, 2026 13:50
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.

Paused motion recordings differ from each other by one microsecond

2 participants