Skip to content

Loopback-HLS: the final segment of a long 4K DV title never completes at EOM — AVPlayer parks ~0.1s from the end (WaitingToMinimizeStalls) → -12889; resuming into the tail can't start a master #169

Closed

Description

@rrgomes

On the loopback-HLS native path, a long, heavy 4K Dolby Vision P8.1 direct-play title fails to finish: the final segment doesn't serve, so AVPlayer parks a fraction of a second from the end and eventually errors instead of reaching didPlayToEndTime. A resume into the tail region then can't start a master at all.

Asset: 48-min episode, HEVC Main 10 Dolby Vision Profile 8.1 (BL compat id 1), 24p, ~25.4 Mbit/s, EAC3 5.1 + Atmos, direct-play .mkv over the loopback path. engine.duration = 2881.3 s.

Symptom 1 — final segment never completes (initial playthrough). AVPlayer reaches the last segment and parks:

engineClock=2881.202  avpClock=2881.202  tcs=1 rate=1.0
waitReason=AVPlayerWaitingToMinimizeStallsReason
seekable=[0.0-2881.3]  loaded=[2844.8-2881.3]        <- loaded right to the end, but not playing out

It never fires didPlayToEndTime; after ~43 s it dies with CoreMediaErrorDomain -12889 (loaded ranges collapse to []).

Symptom 2 — resume into the tail can't start a master. Resuming at ~2878.5 s (the last ~3 s), the master never produces tracks and degrades all the way to the media playlist:

[HLSLocalServer] seg719: slow serve, sending early chunked header      (repeats)
#35 readiness gate: master did not start (timedOut) after a panel switch; reloading the master (attempt 2/2) at 2878.50s
#35 readiness gate: master never produced tracks; trying the HDR-preserving reduced master (DV dropped) at 2878.50s
#35 readiness gate: master never produced tracks after 2 attempts; falling back to the media playlist (HDR10 base, DV dropped) at 2878.50s

then AVPlayer stalls again (WaitingToMinimizeStalls, loaded=[2862.7-2877.5]).

seg719 is the final segment (~2881 s / ~4 s ≈ 720 segments), so both symptoms point at tail/EOF handling in the loopback segment producer — the last segment slow-serves and never completes, and starting a master anchored in the final few seconds times out. This reads as the #93/#35 loopback-wedge family, but triggered by end-of-file rather than a seek.

Ask: could the producer be stalling at EOF on the final segment (short/partial last segment, or a producer that never signals completion at the tail), and/or the readiness gate timing out when the master is anchored in the last few seconds? A completed final segment (or a clean didPlayToEndTime) would let playback finish normally.

Host-side mitigation (already shipped our side): we now treat a stall/terminal failure within 15 s of duration as end-of-media and complete cleanly, so the user gets a normal finish instead of a Playback Error — but that papers over the tail-production failure rather than fixing it.

Environment: AetherEngine 5.10.0, tvOS (Apple TV 4K 3rd-gen), direct-play .mkv over loopback. Full UDP trace available on request.

Activity

  1. superuser404notfound commented on Jul 21, 2026

    @superuser404notfound
    Owner

    Thanks for the trace, the two symptoms turned out to be separate mechanisms at the same tail. Both are fixed in 5.16.2 (06453a8, 07645b8).

    Symptom 1 (park then -12889). The final segment does produce and serve fine, so this is not a stalled/never-completed tail production as the report first suspected. The mismatch is between what the segment advertises and what its video actually contains: the final #EXTINF is derived from the container duration (sourceDurationSeconds), but the muxer writes the last video sample at EOF with only its own one-frame duration. When the container duration overshoots the last real video frame (audio running a few frames longer, or a rounded-up MKV Duration), the video track underfills the advertised segment by ~0.1s. AVPlayer's video renderer then parks waiting for frames that were never there, while loadedTimeRanges (audio plus the segment map) shows the segment fully loaded, so didPlayToEndTime never fires and eventually the loaded ranges collapse to -12889. The engine now recognises this tail park from its 1 Hz native tick (VOD, playhead within 0.5s of duration, final segment loaded to the end, WaitingToMinimizeStalls, playhead frozen for a 3-tick grace) and synthesizes organic end-of-media, so playback finishes cleanly (.ended, autoplay-next etc.) after ~3s rather than hanging then erroring at ~43s.

    Note this reads the raw loadedTimeRanges end, not the clamped forward buffer, specifically so a resume/seek into the tail (Symptom 2, where the playhead runs ahead of loaded media) does not get misread as an exhausted tail.

    I looked at padding the final video sample to fill the advertised #EXTINF instead, but rejected it: the packet flushed at EOF is the last in decode order, not presentation order, so extending its duration would corrupt a B-frame tail. Completing at the honest video-exhaustion point is robust either way.

    Symptom 2 (tail resume can't start a master, DV dropped). Resuming into the last few seconds anchors the #35 readiness gate's master on the final segment, still being produced over the slow link, so awaitStartupReadiness times out with 0 tracks and no media loaded yet. The gate was written for the cold DV/HDCP decode failure and read that timeout as a dead master, so it reloaded, timed out again, and fell back through the reduced master to the media playlist, dropping DV before it had any segment data to decode. The gate now splits a settle-window timeout on whether any media has loaded: no media means the first segment simply has not been served yet, so it keeps the DV master and re-awaits (bounded at ~24s, well past a slow-link final-segment production); media loaded but still 0 tracks stays the cold-decode park with the reload/fallback chain unchanged. A genuinely wedged producer still falls through once that budget is spent.

    Retest ask (5.16.2): the same tail playthrough and the same tail resume. Expected log lines:

    • Symptom 1: [AetherEngine] #169 tail park: playhead=... duration=... loadedEnd=... at the finish, then a clean end-of-media instead of the -12889 death. The playhead/duration/loadedEnd numbers will confirm the mechanism (video ending short of the container duration the final EXTINF was built from) if you want to post them.
    • Symptom 2: [AetherEngine] #35/#169 readiness gate: master's first segment not served yet ... keeping the DV master and waiting (data-wait N/8), then the DV master starting once the final segment lands, with no fallback-to-media line and no DV drop.

    Your 15s-from-duration host mitigation for Symptom 1 can come out once you are on 5.16.2, since the engine now finishes the tail itself. Leaving the issue open for your device verdict.

  2. rrgomes commented on Jul 22, 2026

    @rrgomes
    ContributorAuthor

    Not fixed in 5.18.4. Reopening with a better trace.

    Source: 4K HEVC Dolby Vision Profile 8.1 in MKV, 2881.3 s, direct-played over LAN from a Plex server on the loopback-HLS native path, Apple TV 4K 3rd gen, AetherEngine 5.18.4.

    Important correction to my earlier report: we were carrying a host-side workaround that treated any stall within 15 s of the end as end-of-media and completed the item cleanly. That masked this entirely, and my previous "fixed" confirmation was the workaround firing rather than the engine finishing. I removed it and retested. The failure is unchanged.

    Single session, resumed at 1756 s then seeked to 2821.1:

    05:39:42  stall    engineClock=2871.568  loaded=[2835.1-2871.6]  tcs=1 rate=1.0
                       waitReason=AVPlayerWaitingToMinimizeStallsReason
    05:39:51  reload   NativeAVPlayerHost #13 startPos=2871.57
    05:40:03  stall    engineClock=2879.210  loaded=[2870.3-2879.3]
    05:40:11  reload   NativeAVPlayerHost #14 startPos=2879.21
    05:40:05+ seg719: cache miss after 30005ms (cache=46 restarted=false)  x11, indefinitely
    05:40:47  failed   CoreMediaErrorDomain -12889  loaded=[]  frozenFor=47.2s
    

    seg719 is the final segment. The producer is provably stopped throughout: across four 30 s memprobes spanning the wedge, avioFetchedMB stays 502, packetsWritten 1265, pktTotal 85264, cacheCount 46, avBufAhead 0.0s. No bytes are being read from the source at all.

    A possible mechanism, from VideoSegmentProvider: every miss logs restarted=false, so needsRestart was false and the fetch took the plain forwardBackpressureWaitSeconds path rather than the reposition/restart path. With a non-empty cache and an index just above the resident max, that is the r.1 < index <= r.1 + forwardWaitWindow branch, where needsRestart = index > activeMarchFront + forwardWaitWindow. The request is judged near enough to the active producer's march front to be worth waiting for, but the producer has stopped, so activeMarchFront never advances, the test stays false, and the same 30 s wait re-arms indefinitely. The escalation to a restart is unreachable because the "will this arrive?" question is answered by index distance alone, never by whether the producer is still making progress.

    The final segment looks especially exposed: there is nothing after it for the producer to march into, so if it exits or starves before writing that segment, the march front sits permanently just below the requested index and the wait cannot resolve itself.

    Earlier in the same session the source reader was already struggling, which may be the trigger:

    05:36:21  slow read 4046ms at offset=4625784340 detour=0(4002ms,1fetch) reconnects=1 gen=3->4
    05:36:25  slow read 4044ms at offset=4559644850 detour=0(4005ms,1fetch) reconnects=1 gen=4->5
    

    We have restored our near-end workaround for now, so our users get a clean finish instead of the error screen. That means we will not hit this organically any more, but I can remove it again to retest whenever you want.

    Lower-confidence secondary note: on the same run the embedded SRT cues ran late after the forward seek and did not recover (subCues=9 at the wedge). That may simply be the side demuxer re-anchoring after the seek and the two reloads rather than anything new in 5.18.x. Flagging in case it is related; not asking you to chase it yet.

  3. superuser404notfound commented on Jul 22, 2026

    @superuser404notfound
    Owner

    Thanks for the correction and for the trace, that is exactly the evidence this needed. The workaround explanation also resolves the earlier confusion: your "fixed" verdict was the mitigation firing, and the 5.16.2 changes fixed a different (real, but separate) tail mechanism. This round is a producer death, not a duration mismatch.

    Your VideoSegmentProvider read is confirmed verbatim. In the r.1 < index <= r.1 + forwardWaitWindow branch, needsRestart = index > activeMarchFront + forwardWaitWindow answers "will this arrive?" by index distance alone; a dead producer freezes the front just below seg719 and the 30 s wait re-arms forever, which is precisely your cache miss after 30005ms (cache=46 restarted=false) x11. Your point about the final segment being maximally exposed is also right: there is nothing beyond it for the march to advance into.

    Two more defects were stacked behind it:

    1. A VOD pump that exits on a mid-session read error (your frozen memprobes say the source reader stopped for good after the reconnect churn at 05:36) had NO recovery arm at all. The engine only surfaced the nothing-ever-produced case as fatal and assumed the scrub/wedge arms covered the rest; the backpressure wedge detector runs inside the pump and died with it, and the provider escalation never fires per your analysis.
    2. Even an escalated restart would have been vetoed: the restart loop's producerCovers guard reads the base of the dead producer, which is still installed and "covers" seg719, so the fire is suppressed as "the march will deliver it".

    Fixed in 5.19.1 (1ba1b8c), defense in depth:

    • A mid-session VOD readError pump exit now gets a bounded event-driven revive (2 attempts), aimed at the pending seek target or AVPlayer's real position, and the demuxer whose read just threw is replaced with a fresh connection instead of being re-seeked. In your trace's shape this restarts production within seconds of the pump death, well before AVPlayer's -12889 window.
    • The forward-wait itself is now liveness-aware: a FINISHED pump skips the wait entirely and restarts immediately, and a pump that never exits (blocked in a read) escalates once a full 30 s wait has burned with zero march-front progress for the same index. An advancing front resets the record, so slow-but-alive sources keep the full patience and the healthy-march protections are unchanged. Both proofs bypass the producerCovers veto.

    Retest ask (5.19.1, workaround removed): the same tail playthrough and tail resume. Expected signatures, depending on which state the producer dies in:

    • [AetherEngine] #169 VOD pump died mid-session (readError N); rebuilding producer on a fresh demuxer at ... followed by seg719 producing and serving, or
    • [AetherEngine] seg719: #169 forward-wait march dead (front=718 frozen across a full wait); escalating to restart

    Either way the item should finish through the 5.16.2 tail-park completion instead of dying at -12889. If you can also grab the pump finished: reason=... line from the wedge run, that would pin which of the two paths your device actually takes.

    On the SRT note: plausibly the same root cause rather than something new. Embedded SRT cues are fed by a packet tap on the producer, so a dead producer taps nothing and subCues freezes exactly like the segments did. I would expect it to recover along with this fix; if it still lags on 5.19.1 after a forward seek, flag it and I will chase it separately.

    Once your device verdict is in, I would suggest retiring the 15 s workaround for good: with the engine recovering the tail itself, the mitigation would otherwise skip up to the last 15 s of real content and mask any future tail regressions from both of us.

  4. rrgomes commented on Jul 22, 2026

    @rrgomes
    ContributorAuthor

    Retested on 5.19.1 with our 15 s workaround removed. The escalation half is fixed; the item still does not finish.

    Fixed: every tail cache miss in this session reads restarted=true, where 5.18.4 gave restarted=false eleven times in a row. The forward-wait escalation is reachable now, exactly as intended.

    Still failing: the restart has nothing to restart into. The final segment is never produced, by any pump, under any anchoring. Three pump lifecycles in one session on a 4K HEVC Dolby Vision Profile 8.1 MKV, 2881.3 s, direct-played over LAN, Apple TV 4K 3rd gen:

    pump finished: reason=eof packetsRead=3775 packetsWritten=1629 lastError=0 cacheCount=29
    
    initial producer anchored at idx=716 (startPosition=2872.29s)
    pump finished: reason=eof packetsRead=819  packetsWritten=216  lastError=0 cacheCount=3
    
    initial producer anchored at idx=718 (startPosition=2880.34s)
    still waiting for video keyframe: dropped=200 lastDts=2880419 isKey=false target=2878501 baseIndex=718
    pump finished: reason=eof packetsRead=497  packetsWritten=0    lastError=0 cacheCount=0
    

    The third is the most diagnostic. Anchored at the tail segment, the producer seeks to that segment's advertised start (target=2878501), drops 200 packets waiting for a keyframe, never sees isKey=true through to lastDts=2880419, and exits at EOF having written nothing. The plan for this file reports keyframe-aligned, 1066 IRAPs -> 720 segments, so a seek to a segment boundary should land on an IRAP, and here it does not. Anchoring roughly six seconds earlier at idx=716 does find keyframes and writes 216 packets into three segments, which places the discontinuity in the last few seconds of the file rather than in the tail generally.

    Earlier in the same session, in that same region:

    video dts non-monotonic at source: orig=2872286 lastValid=2872289 pts=2872411 -> bumped to 2872290
    

    That is a plausible mechanism for plan-time segment boundaries and runtime seek landings to disagree, though I have not proven the link.

    One secondary observation. On the tail resume the readiness gate logs master's first segment not served yet (still producing over a slow link); keeping the DV master and waiting (data-wait N/8) eight times, but nothing is producing: the pump had already reached EOF with packetsWritten=0 three seconds before the first of those lines. The gate's wait is unwinnable in that state and its message describes the opposite of what is happening. Consulting pump liveness there would turn 25 s of false hope into an immediate, accurate failure, and it is the same liveness signal the new forward-wait escalation already computes.

    We have restored our near-end-of-media net for now, so this will not be hit organically again on our side. Happy to remove it and retest whenever you want another pass.

  5. superuser404notfound commented on Jul 23, 2026

    @superuser404notfound
    Owner

    Thanks, the third pump lifecycle was the decisive one. You were right that plan-time boundaries and runtime landings disagree on timestamps; the axis pair turned out to be decode vs presentation time, and the disagreement was inside the restart gate itself.

    Root cause. The scan-forward gate that a restarted producer uses to find its anchor keyframe compared packet dts against the plan boundary, which is a PTS (segmentPlan[baseIndex].startPts, a Cues timestamp). Your file is decode-ordered (your own bump line shows it: orig=2872286 ... pts=2872411, dts sitting ~125 ms below pts, a classic reorder delay), so the anchor IRAP's dts is a reorder delay below its own pts, and therefore below the boundary the gate was waiting for. The gate dropped the exact keyframe the restart seeked for. This is the same defect class the #92 cutter fix removed from segment cutting; the pregate kept the dts comparison.

    Mid-file this is survivable: the next IRAP, a GOP later, satisfies the gate and production opens one GOP late. At the tail it is fatal, and your third pump is the textbook trace: the seek deliberately lands early (that is what the scan-forward is for), the IRAPs at ~2872.4 and in between are correctly below the target and dropped, the seg718 anchor IRAP is dropped on its dts, and past it there is no further IRAP before EOF, so the unbounded VOD gate dropped all 200 remaining video packets to lastDts=2880419 and exited with packetsWritten=0. The 5.19.1 escalation then worked exactly as designed and restarted into the same starve, which is why every miss read restarted=true while nothing changed.

    Your "discontinuity in the last few seconds" localization was also right, with a sharper edge: there is no runtime keyframe at or after seg719's planned boundary at all (a Cues entry whose block is not key-flagged at demux, or tail Cues drift). That makes the advertised final segment structurally unproducible by keyframe-aligned cutting from any anchor, which is why your idx=716 pump wrote three segments and folded the rest of the tail into the last one at EOF adoption instead of ever cutting a seg719.

    Fixed in 5.20.1 (0138d38), three layers:

    1. The gate now judges packets by presentation time (videoGateTargetSatisfied, dts fallback for NOPTS), so the anchor IRAP opens its own segment. For dts==pts sources the behavior is unchanged.
    2. A VOD pump whose gate still starves to EOF is proof that no runtime keyframe exists at or after the targeted boundary. The engine now re-anchors production on the segment of the last keyframe the gate dropped (bounded), so the tail content gets produced and the item finishes through the 5.16.2 tail-park completion instead of dying at -12889 on a segment that cannot exist.
    3. Your secondary observation is implemented as suggested: the readiness gate's data-wait now consults the same pump-liveness signal the forward-wait escalation uses. Production that already exited with nothing served fails over immediately, and logs production already finished with no data served; skipping the data-wait (not a slow link) instead of eight rounds of the opposite.

    Retest ask (5.20.1, workaround removed): the same tail playthrough and the same tail resume. Expected signatures:

    • The tail restart opening cleanly: [HLSSegmentProducer] video gate open: actual=... anchorPts=... at the seg718 anchor, tail content producing, then the tail-park completion (#169 tail park: ... followed by a clean end) instead of -12889.
    • If a pump still starves (a resume landing inside the unproducible final slot): [HLSVideoEngine] #169 VOD gate starved to EOF at segN: no keyframe at/after the plan boundary; re-anchoring on the last real keyframe (pts=...) -> segM, then the same tail-park finish.
    • The pregate log now also prints lastPts= next to lastDts=, so if anything still refuses to open, that line will show us both axes directly.

    On the embedded SRT lag: with the gate opening at the correct tail IRAP and production actually covering the tail, the packet tap now sees those cues, so I would expect it to recover along with this. If it still lags on 5.20.1 after a forward seek, flag it and I will chase it separately.

    And once your device verdict is in, I would again suggest retiring the 15 s net for good; with the tail producible and the engine completing end-of-media itself, the mitigation would only skip real content and mask any future tail regression from both of us.

  6. rrgomes commented on Jul 23, 2026

    @rrgomes
    ContributorAuthor

    Retested on 5.20.1 (8f1be63), our near-end workaround removed, Apple TV 4K 3rd gen, same DV P8.1 title (2881.3 s). The PTS gate fix works where it applies, but the tail still ends in -12889 on a straight playthrough.

    Works: a mid-file seek to ~4 min from the end restarted the producer and the scan-forward gate opened on presentation time exactly as intended:

    producer restarted at idx=661 (seek=2648.27s [absolute source-PTS])
    video gate open: actual=2648271 anchorPts=2648271 target=2648271 desired=2648271 shift=0
    

    Still fails: that same producer then forward-played from 2648 s to EOF, emitting through seg718 but not the final seg719, and exited normally:

    pump finished: reason=eof packetsRead=12956 packetsWritten=5587 cacheCount=70
    

    From there, ~80 s of nothing but the forward-wait escalation spinning, until -12889:

    seg719: #169 forward-wait march dead (front=718 producer finished); escalating to restart
    seg719: #169 forward-wait march dead (front=719 producer finished); escalating to restart
    seg719: cache miss after 24014ms (cache=70 restarted=true)          <- cache frozen at 70, x10
    #65 nudge did not revive the consumer; reloading item at 2877.24s    <- x2, no effect
    ...
    FreezeDiag failed CoreMediaErrorDomain -12889 engineClock=2878.501 loaded=[]
    

    The failure clock, 2878.501, is exactly seg718's plan boundary (planSource=2878.501s): AVPlayer parked at the seg718/719 seam.

    Why the re-anchor never fired. shouldReanchorVODAfterGateStarvation is guarded on !videoGateOpened, which targets a restart pump that seeks into the tail and starves. But on a natural playthrough the pump that reaches the tail is the original forward producer — it opened its gate back at the 2648 s seek and forward-played to EOF, so videoGateOpened == true and it's excluded. Nothing spawned a fresh tail pump to trigger the arm otherwise: across that whole 80 s window there was not one video gate open, still waiting for video keyframe, #169 VOD gate starved … re-anchoring, or pump finished. So handleVODGateStarvationExit is never invoked; the only .eof this session was the forward producer's, which the guard rejects.

    (For contrast, my 5.19.1 capture did spawn tail restart pumps — three lifecycles, one packetsWritten=0. This 5.20.1 run produced none. I don't know whether that's the different entry path (seek-then-play vs play-from-start) or a change in the restart path, but either way the forward-play producer is the one that reaches EOF and it's the one the guard excludes.)

    The shape that needs covering is a forward producer reaching EOF having emitted through segment N while the plan's final segment N+1 was never produced, with segN's end within a frame of the media duration — the common case for any straight playthrough, versus the restart-into-tail (resume) case the 5.20.1 arm handles. Would it make sense to trigger the re-anchor (or accept EOM) when a forward .eof leaves a trailing plan segment unemitted and the last emitted segment ends at ~duration? Our client net does the latter heuristically inside 15 s of the end; glad to keep it off another round for a specific capture.

    I couldn't get the tail-resume shape this round — resuming near the end restarts our client at 0 (a resume-position issue on our side, unrelated) — so I only have the forward-play trace. Full session log available if useful.

  7. superuser404notfound commented on Jul 24, 2026

    @superuser404notfound
    Owner

    Thanks for the new trace. It confirms that the 5.20.1 PTS gate change works for mid-file anchors, and it exposes a separate terminal plan mismatch during straight playthrough.

    The original forward producer opens at seg661 and reaches natural EOF after emitting the media through seg718. The planned seg719 boundary has no runtime keyframe, so seg719 cannot be produced by the forward producer or by any restart anchor. The remaining EOF media is already carried in seg718, but the VOD playlist still advertises seg719. AVPlayer then waits at the impossible 718/719 seam and eventually reports -12889.

    I have opened #206 with the fix. It folds a sub-target final plan slot into its predecessor, preserves the complete advertised duration and terminal PTS, and makes that collapsed plan the single plan used by the provider, initial seek mapping, and producer startup. This removes the structurally unproducible boundary without dropping tail content or synthesizing an early end.

    The regression suite covers the observed 2.799 second tail and the long-GOP case. All 983 tests, strict Swift concurrency, and the tvOS Simulator build pass. I will post the exact release version here once the PR is merged and released.

  8. superuser404notfound commented on Jul 24, 2026

    @superuser404notfound
    Owner

    The fix is now released in AetherEngine 5.20.4: https://github.com/superuser404notfound/AetherEngine/releases/tag/5.20.4

    Both Sodalite and AetherPlayer have been updated to the 5.20.4 release pin. Please retest the original straight-playthrough case with the 15 second host workaround removed. The expected result is that the final 2.799 second plan slot is folded into the preceding segment, so the playlist no longer advertises the impossible seg719 boundary and playback reaches normal end of media without -12889.

    I am leaving this issue open for your device result.

  9. rrgomes commented on Jul 24, 2026

    @rrgomes
    ContributorAuthor

    5.20.4 fixes it. The title plays to the end.

    Retested on 5.20.4 (1abe7fa), Apple TV 4K 3rd gen, same DV P8.1 title (2881.3 s), with our 15 second near-end-of-media workaround removed. Straight playthrough with one mid-file scrub — the exact shape that failed on 5.20.1.

    The collapse is visible in the plan:

    [HLSVideoEngine] segment plan: keyframe-aligned, 1066 IRAPs → 720 segments
    [HLSSegmentProducer] init OK (baseIndex=0, segments=718, targetDur=4.000s)
    [HLSVideoEngine] prepared: codec=hvc1.2.4.L150,ec-3 supplemental=dvh1.08.06/db1p
                     resolution=3840x1606 fps=23.976 range=PQ DV=profile81
                     segments=718 duration=2881.3s
    

    720 raw segments collapse to 718, so the last index is seg717 and the 2.8 s terminal slot is gone. seg718 and seg719 appear nowhere in the session log.

    The forward producer reached EOF exactly as before, one pump, no restart after the scrub:

    pump finished: reason=eof packetsRead=13860 packetsWritten=5976 lastError=0
                   elapsed=193731ms cacheCount=74
    

    but this time playback continued out of cache through the final segment and ended normally:

    GET /seg713.mp4 ... GET /seg717.mp4     <- last segment, 40 s after the pump finished
    [NativeAVPlayerHost] #1 didPlayToEndTime
    [NativeAVPlayerHost] #1 rate=0.0
    [NativeAVPlayerHost] #1 timeControlStatus=paused reason=- t+268.05s
    

    Zero occurrences of -12889, forward-wait march dead, cache miss, or any freeze diagnostic in the whole session.

    The resume-into-tail shape also passes now, which I could not test last round. Resuming 61 s from the end anchors the initial producer inside the tail:

    initial producer anchored at idx=703 (startPosition=2820.00s)
    init OK (baseIndex=703, segments=15, targetDur=4.000s, srcVideoTb=1/1000)
    video gate open: actual=2817231 anchorPts=2817231 target=2817231 desired=2817231 shift=0
    pump finished: reason=eof packetsRead=3559 packetsWritten=1536 lastError=0
                   elapsed=8950ms cacheCount=15
    

    segments=15 is worth pointing out: 703 through 717 inclusive on the collapsed plan. That confirms the initial producer is now built from the same collapsed plan as the playlist, rather than the raw 720-segment one, which is the half of the change a straight playthrough never exercises. The full tail produced in under 9 seconds, cacheCount matched the planned segment count exactly, and it ended on didPlayToEndTime with no diagnostics.

    The 5.20.2 indexed IRAP seek shows up here too, and it is a large win on this remote origin — the mid-file restart landed in 8 ms with the seek costing nothing measurable:

    producer restarted at idx=657 (seek=2632.05s [absolute source-PTS],
                                   restart took 8ms; stopWait=7ms seek=0ms build=0ms)
    video gate open: actual=2632046 anchorPts=2632046 target=2632046 desired=2632046 shift=0
    

    Our workaround is retired permanently now rather than just for the test, so any future tail regression surfaces as the original symptom instead of being masked. Thanks for the fast turnaround — happy to see this closed.

  10. superuser404notfound commented on Jul 24, 2026

    @superuser404notfound
    Owner

    Thank you for the exceptionally thorough device verification, including both the straight-playthrough and resume-into-tail paths. The matching collapsed-plan counts, normal didPlayToEndTime completion, and clean producer/cache behavior confirm the 5.20.4 fix across both startup shapes. Closing as verified.

  11. rrgomes commented on Jul 25, 2026

    @rrgomes
    ContributorAuthor

    Closing — 5.20.4 verified fixed on device.

    For completeness, the full HDR/codec gate matrix is also green on 5.20.4, all on Apple TV 4K 3rd gen via the engine path: DV Profile 7, DV Profile 8.1, HDR10, and plain 4K SDR HEVC. Each run included a near-EOM seek that then played through to end of media, so the final-segment fold is exercised across all four cells. Thanks again for the quick turnaround.

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