Skip to content

Loopback-HLS playback wedges under rapid repeated seeks; recovered clock diverges from the decoded frame #35

Closed

Description

@rrgomes

Summary

On the loopback-HLS backend (HEVC served over the internal 127.0.0.1 HLS to AVPlayer), a burst of rapid or repeated seeks can wedge the pipeline: currentTime stops advancing for roughly 10 seconds while state remains .playing. The engine recovers on its own, but after recovery the reported currentTime no longer matches the frame on screen (off by 5 to 10 seconds), and broken/pixelated frames are visible during recovery.

Environment

  • AetherEngine 3.4.0 (4a442c6), FFmpegBuild (07ffa41)
  • tvOS 26.x, Apple TV 4K (2nd gen AppleTV11,1 and 3rd gen AppleTV14,1)
  • HEVC content on the native loopback-HLS to AVPlayer backend (not the software AVSampleBuffer path)
  • LoadOptions: suppressDisplayCriteria: false, matchContentEnabled: true, audioBridgeMode: .lossless

Steps to reproduce

  1. Play an HEVC item on the loopback-HLS backend.
  2. Perform a burst of rapid seeks (repeated short skips, or fast scrubbing back and forth) over several seconds.
  3. Observe the player after the seek burst settles.

Observed

  • The clock freezes: currentTime stops advancing while state stays .playing and the display holds a single frame.
  • No buffering signal during the stall: the engine does not report .buffering/.loading. It sometimes reports .paused for what is actually a buffering stall, which is indistinguishable from a real pause.
  • After roughly 10 seconds the engine recovers on its own, but:
    • the recovered currentTime advances non-monotonically (in one capture a seek to 146.7s was followed by the clock reading 271.9s seconds later),
    • the reported currentTime diverges from the frame actually displayed (clock vs frame off by 5 to 10 seconds), and
    • broken/pixelated frames appear briefly during recovery (consistent with resuming mid-GOP without a clean decoder reset).
  • A same-position seek issued during the wedge is a no-op, so it cannot be used to re-prime the pipeline.

Expected

A burst of seeks should leave the pipeline either playing from the final target, or briefly buffering (reported as buffering) and then resuming, with currentTime monotonic and matching the displayed frame.

Impact

The clock-versus-frame divergence is the most damaging part: any consumer that trusts currentTime (scrubber UI, A/V sync, or an app coordinating multiple players) is misled, since the reported position looks correct while the picture is seconds away. It cannot be detected from outside the engine, because the only position signal available is the diverged clock.

Notes

Found while embedding AetherEngine as the default VOD engine in a tvOS app. Reproducible only under heavy scrubbing; ordinary playback with occasional seeks is unaffected. Happy to provide UDP logs from a capture or a minimal standalone repro app if useful.

Activity

  1. superuser404notfound commented on Jun 15, 2026

    @superuser404notfound
    Owner

    Thanks for the unusually precise report, the clock-versus-frame note in particular pointed straight at the root cause.

    Root cause

    All of the symptoms trace to an uncoordinated producer-restart cascade. On the loopback-HLS path, every out-of-range segment request triggers a full producer restart: tear down the old producer (waiting up to 5s for its pump to exit), seek the demuxer (network-bound on a remote source), and rebuild. These serialize on a single gate with no coalescing. A burst of rapid seeks fires many of them back to back, and on a slow/remote source each one is slow enough that they pile up, which is the ~10s wedge you saw.

    Worse, when the 5s wait times out the old producer is abandoned but keeps reading the shared demuxer, so it can steal the first post-seek packet. The surviving producer then starts a GOP late (the broken/pixelated frames) and computes a wrong timeline shift, which the clock fold publishes as the large non-monotonic jump (your 146.7s reading 271.9s). So the wedge, the broken frames, and the clock-versus-frame divergence are one root, not three.

    This only reproduces under heavy scrubbing against a network-bound source, which is why it is hard to trigger with ordinary seeks: restart latency has to exceed the seek spacing for the cascade to overlap.

    Fix

    Producer restarts now coalesce: a burst collapses to the in-flight restart plus a single final restart at the settled target, instead of serializing one full teardown per intermediate scrub position. The surviving restart runs cleanly without the abandoned-producer demuxer contention, so it lands on a keyframe with the correct shift. Off-device, with an injected restart delay to force the overlap, this takes the longest "playing but clock frozen" interval from 6.35s to 0.21s and the coalescer absorbs the burst as expected.

    Separately, there is now a published isBuffering signal that is true during a mid-playback rebuffer stall, so a stall is distinguishable from real playback and from an explicit pause (your point about it being indistinguishable from a real pause). It is kept separate from state, which still reports .playing across a rebuffer so the transport icon does not flicker.

    Could you re-test?

    The fix is on main now (not yet in a tagged release). Could you build against latest main and run your scrub-burst repro again? The wedge is verified off-device, but the clock-versus-frame divergence is the hardest part to confirm without a real frame on screen, so your test against the actual source would be the decisive check before I cut a release. If it still repros, the UDP capture you offered would be very welcome.

  2. rrgomes commented on Jun 15, 2026

    @rrgomes
    ContributorAuthor

    Confirmed fixed in 3.5.0. 🎉

    Bumped our pin 3.4.0 → 3.5.0 and re-ran the original repro on an Apple TV 4K (tvOS 26.5): a long H.264/AVC asset on the loopback-HLS path, scrubbed hard back and forth — sustained click-skip bursts plus continuous swipe-scrub — for several minutes, in plain single-player playback. No wedge, no clock↔frame divergence, no stuck spinner; every scrub settles cleanly and resumes at the target. The RestartCoalescer is doing exactly what it describes.

    For context, we'd been masking this with a watchdog that pins a clean frozen frame; on 3.5.0 that path no longer triggers under heavy scrub. Thanks for the quick turnaround — happy to see this closed.

  3. added a commit that references this issue on Jun 26, 2026
  4. 2 remaining items

  5. added a commit that references this issue on Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions