Repository navigation
fix(frame-times): draw the producer epoch and flush generation process-wide (#314) - #327
Merged
superuser404notfound merged 1 commit intoAug 7, 2026
Conversation
…s-wide (#314) Both discriminators carry the same documented rule, that a higher value retires every entry recorded under a lower one, and both were counted per session. A load() builds a new HLSVideoEngine and a new SampleBufferRenderer, so the counter restarted at the one seam the rule exists for: a report still arriving from the outgoing session outranked everything the incoming one would ever emit, and a host that ordered by it dropped the new item's frames for as long as it played. Both now draw from one process-wide FrameTimeSequence, which restores the ordering end to end without a public struct change: the superseded producer's last report always ranks below the next session's first. The values stay strictly increasing but are no longer consecutive, which ordering never relied on. stopInternal also detaches the outgoing session and host from the observer before stopping them, so the straggler window is closed in the ordinary case rather than only sorted correctly. The witness fails on the old code with equal epochs (1 vs 1) across two sessions, which is the value ordering cannot separate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
superuser404notfound
deleted the
fix/314-process-wide-frame-time-sequence
branch
August 10, 2026 12:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #314.
The defect
NativeVideoFrameTime.epochandSoftwareVideoFrameTime.generationboth document the same rule: a higher value retires every entry a consumer recorded under a lower one. Both were counted per session, and aload()builds a newHLSVideoEngine(AetherEngine+Loading.swift) and a newSampleBufferRenderer(SoftwarePlaybackHost), so the counter restarted at exactly the seam the rule exists for.The observer is engine-scoped and documented to outlive a load, so the outgoing producer keeps reporting until
loadstops it. A host that retired its table at the start of the load could be handed a frame from the outgoing producer at epoch N, adopt N as newest, and then reject every frame of the new session (epochs 1, 2, ...) as stale for the rest of the item.epochis the only discriminator that could separate them:source,itemandsegmentIndexall restart near zero on a new item.The fix
One
FrameTimeSequence, a process-wide monotonic allocator with its own lock, behind both counters:HLSVideoEngine.producerEpochs(static) feedsnextProducerEpoch().SampleBufferRenderer.flushGenerations(static) feeds both the initial generation and every flush. The initial draw matters as much as the flush draw: a renderer that came up at zero would tie with, or rank below, the one it replaces.That restores the documented rule end to end without a public struct change, and hosts that only compare epochs relatively need no changes. Values stay strictly increasing but are no longer consecutive; the doc comments now say so.
The software path was not in the issue's scope but carries the identical defect against the identical contract, so it is fixed in the same pass rather than left to be reported separately.
stopInternaladditionally detaches the outgoing session and the outgoing software host from the observer before stopping them. That does not replace the ordering guarantee (a pump can have snapshotted the observer already), it just means the ordinary case is silence rather than a correctly-sorted straggler.Verification
New suite
Issue314FrameTimeSequenceTests:SampleBufferRendererreports above the one it replaces, and a straggler from the outgoing renderer ranks below the new one's first report (fixture-free, runs on CI);HLSVideoEngineinstances over the witness clip, standing in for the two sides of a load: the incoming session's first epoch outranks the outgoing session's last, and a restart inside the new session still opens above its own first epoch, so Report per-frame presentation times on both the source and item axes (native path) #260's within-session behaviour is untouched (fixture-gated).Negative control: with the per-instance counters restored, the native witness fails with
(incomingEpoch -> 1) > (outgoingEpoch -> 1), plus both software assertions. Full suite green afterwards, 1552 tests in 232 suites.Issue311SoftwareFrameTimesTestsmoves from== before + 1to> before, since a process-wide sequence is legitimately advanced by a renderer in a parallel test. Ordering was always the contract.🤖 Generated with Claude Code
https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE