Skip to content

Piece-B seek-deadline recovery (#65 4.2.2) re-anchors producer to a stale coalesced seek target, not AVPlayer's rendered position → permanent wedge after a rapid scrub burst #79

Closed

Description

Environment: AetherEngine 4.5.1, macOS, native loopback-HLS VOD path. Source: 4K HEVC Dolby Vision P8.1 + TrueHD → EAC3 bridge, ~1.95 h, remote direct-play. Engine logging on.

Summary

The 4.2.2 fix for #65 gives the seek-deadline path a recovery floor ("reconcile clock to AVPlayer's rendered position and re-anchor the producer there"). Under a sustained bidirectional scrub burst that recovery fires but does not recover: when the seek-deadline reconcile coincides with an in-flight coalesced producer restart to a different target, the producer ends up anchored at the coalesced declareTarget, not at AVPlayer's rendered position. Producer and playhead then diverge permanently and AVPlayer stays starved.

This is distinct from the pause false-positive in #65 (the Piece-A backpressure wedge-breaker never fires here) and likely overlaps #50.

Repro

Long high-bitrate bridged-audio title; rapid alternating forward/back scrubs (~8 seeks over ~40 s: fwd→back→fwd→back across distant points).

Evidence

The seek-burst drives a storm of out-of-range / coalesced producer restarts (seg 618→243→646→217→1048→1393→738→978). The Piece-B reconciler then fires twice, 20 s apart, with AVPlayer's rendered position identical (frozen) while the producer is re-anchored ~1660 s away:

12:35:50  [HLSVideoEngine] declareTarget backward jump 1395 → 738, proactively restarting producer
12:35:55  [HLSVideoEngine] restart at idx=738: old producer didn't exit within 5s, abandoning it
12:35:58  [AetherEngine]   #65 seek did not land within 8.0s and AVPlayer is starved
                           (rendered=5577.60s buffered=2955.33s); reconciled clock ... and re-anchored producer
12:36:15  [HLSVideoEngine] producer restarted at idx=738 (seek=2952.24s ... restart took 25118ms)
12:36:15  [HLSVideoEngine] coalesced restart advancing to settled target idx=978
12:36:15  [HLSVideoEngine] producer restarted at idx=978 (seek=3912.28s ... restart took 0ms)
12:36:18  [AetherEngine]   #65 seek did not land within 8.0s and AVPlayer is starved
                           (rendered=5577.60s buffered=3914.55s); reconciled clock ... and re-anchored producer
  • rendered=5577.60s is identical across both firings 20 s apart → AVPlayer is frozen (live snapshot: position stuck, cache 0B).
  • The final producer is anchored at idx 978 / 3914 s via the coalesced declareTarget chain (738→978), not the rendered position (5577 s) the log claims to reconcile to. The gap is ~1663 s, so AVPlayer can never receive the segment it's stuck on; buffered climbs (2955→3914 s) but always behind the playhead.
  • Ledger is clean throughout (drift=0.000 shift=0.000), so this is the livelock class, not content/shift drift.

Secondary findings (same capture)

  • 25 s producer-restart hang: producer restarted at idx=738 ... restart took 25118ms, preceded by old producer didn't exit within 5s, abandoning it — the abandoned producer's in-flight read shares the demuxer and blocks the new one well past the 5 s guard.
  • Restart-storm memory/refetch blowup: every restart re-opens AVIOReader (gen 7→12) and re-pulls 20–36 MB segments; avioFetchedMB 359→2287, rss peaks ~1150 MB.

Suspected root cause

The seek-deadline reconciler computes a re-anchor target from AVPlayer's rendered position, but a concurrently in-flight coalesced restart (declareTarget / coalesced restart advancing to settled target) wins and overrides the producer's base index with the stale scrub target. The reconcile should either win over (or re-issue after) the coalesced restart so the producer's final base index matches the position the clock was reconciled to.

Relationship

Extends the #65 4.2.2 Piece-B fix (incomplete for the coalesced-restart case); related to #50 (loopback-HLS wedge after rapid seek burst).

Activity

  1. added 2 commits that reference this issue on Jun 26, 2026
  2. superuser404notfound commented on Jun 26, 2026

    @superuser404notfound
    Owner

    Fixed in 4.5.3. Your diagnosis was exactly right on both halves, thank you for the frame-exact trace and the clean ledger.

    The override (primary). The seek-deadline reconcile and the backpressure wedge breaker both re-anchor the producer to AVPlayer's real rendered position, but they routed that through the #35 burst coalescer, where begin(idx) simply overwrote the pending slot. So a stale burst-tail scrub clobbered the reconcile's target and the producer settled at the coalesced scrub position (978 / 3914 s) while the clock sat at the rendered position (5577 s), exactly the ~1663 s gap you measured, with no way for AVPlayer to close it.

    The re-anchor is now authoritative. Because it is computed from AVPlayer's real position (the ground truth the clock was just reconciled to), it wins the coalescer's pending slot over any in-flight scrub target, and a newer authoritative re-anchor still supersedes an older one (AVPlayer moved). A non-authoritative scrub can no longer overwrite it. So the producer ends where the clock was reconciled to. Live segment-loss reopen is deliberately left non-authoritative. Walking your trace: requestRestart(618) runs, scrubs coalesce, the reconcile sets 978→ no, the rendered-position target authoritatively, the stale 1393 scrub is dropped, and next(justRan: 618) drains to the rendered-position target, not the scrub target.

    The 25 s restart (secondary). You were right that the abandoned reader holds the shared demuxer: stop() only sets a flag and wakes the cache waiters, it cannot interrupt a blocking socket read, so the new producer queued behind it for the full ~20 s connStallTimeout. On the single-demuxer VOD path the engine now opens a fresh demuxer, then on success markClosed()s the wedged one (the existing thread-safe unblock) and hands the fresh demuxer to the new producer (installed only inside the session-epoch-validated section; clean fallback to the old abandon behaviour if the reopen fails). That collapses the ~20 s shared-read stall and frees the wedged reader's AVIO buffers promptly instead of after 20 s, which also trims the restart-storm memory peak you saw.

    This went through a 4-lens adversarial review (coalescer correctness, demuxer resource/thread-safety, regression, and a step-by-step replay of your trace) plus synthesis: zero confirmed defects. But the decisive evidence is your device, so if you can retest on 4.5.3 (long bridged-audio title, the same rapid bidirectional burst): the producer's final restart should land at the rendered position rather than the coalesced scrub target, the seek-deadline reconcile should no longer be followed by a producer anchored ~1600 s away, and a wedged restart should log a fresh-demuxer reopen instead of restart took 25118ms. AetherPlayer will pick up 4.5.3 in its next build for an interactive macOS repro.

    Thanks again for separating the override from the wedged-read stall, that split is what made this two clean fixes instead of one guess.

  3. ghost closed this as completedon Jun 27, 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