Skip to content

A seek's decoder flush is undone by the parked video FIFO, and one lookahead frame then wedges video until the next seek #494

Closed

Description

@superuser404notfound

What happens

On the software host, a seek occasionally leaves video standing still while audio and the clock keep running. The session reports playing and never rebuffers, so nothing in the transport says anything is wrong. The 1 Hz diagnostic line shows the whole shape:

[SWDiag] clk=100.70 ... vLead=0.17   parkedPkts=195 rebuf=n enq=+40 disp=+36 dpts=16.5/17.0   <- landing
[SWDiag] clk=101.70 ... vLead=154.24 parkedPkts=224 rebuf=n enq=+0  disp=+0  dpts=-
[SWDiag] clk=102.70 ... vLead=153.24 parkedPkts=256 rebuf=n enq=+0  disp=+0  dpts=-

vLead is the distance of the seek that just landed, the packet FIFO climbs to its 256 cap, nothing is decoded or handed to the layer, and the audio lead decays under it. It clears at the NEXT seek, which is why a scrub hides it: only a seek followed by a stretch of playing shows it.

Mechanism

The parked-video FIFO holds whatever the demux loop read ahead of the renderer, which is the audio lead's worth of video, three to four seconds of it. drainParkedVideoNonblocking read the seek generation ONCE at the top and then emptied that FIFO into the decoder, so a seek landing in the middle of the drain had its own videoDecoder.flush() undone by the packets that kept arriving after it. Instrumented at the feed site, with the seek to 100 s arriving while the loop stood at 252 s:

[PROBE] feed parked pts=252.552 gen=10 live=11 parked=106
[PROBE] feed parked pts=252.519 gen=10 live=11 parked=105
[PROBE] seek flush gen=11 target=100.000              <- videoDecoder.flush() has run
[PROBE] feed parked pts=252.652 gen=10 live=11 parked=104
[PROBE] feed parked pts=252.586 gen=10 live=11 parked=103
   ... the rest of the FIFO, all of it after the flush ...
[PROBE] loop noticed generation 10 -> 11, freeing 0 parked
[PROBE] frame jump 252.136 -> 255.756 gen=11 seekGen=11
[PROBE] first admission after flush pts=255.756 gen=11

The last line is the whole defect. Every frame those late packets produced was refused at the host's decoder callback, which is why this survived both rounds of #491: decodeGeneration was still 10 and the live generation was 11. The damage is done by the one frame that does not come out during its own decode. The deinterlacer holds a frame of lookahead, so the last pre-seek frame emerges on the FIRST post-seek decode call, and by then decodeGeneration has been set to 11 for the post-seek packet that triggered it. Every gate passes it.

That frame is a sample whose presentation time is the whole seek distance in the future. The display layer accepts it, holds it, stops reporting isReadyForMoreMediaData, and the demux loop parks on that signal until its packet FIFO caps out. Note freeParkedVideo reporting nothing to free: by the time the loop reads the new generation, the drain has already fed the entire FIFO to the decoder.

Rate

480i H.264 fixture through the hardware deinterlace chain, macOS on an M1, twenty seeks per run over alternating large forward and backward jumps, ten runs per arm with the arms alternating inside each repeat.

arm seeks episodes per run
6.68.3 200 9 1, 2, 2, 1, 0, 0, 0, 0, 1, 2
with the fix 200 0 all zero

About one seek in twenty-two, then. It is not confined to the deinterlace path: the progressive arm of the same matrix produced it too, just less often, which is what a race whose exposure scales with the number of emitted frames looks like.

How long it lasts is set by the next seek, not by any recovery. With seeks two seconds apart the episodes ran one to two ticks (nine episodes); with seeks four seconds apart, three to four (nine episodes). Nothing in the frozen state lifts itself: the layer will not present a sample whose time is two minutes out, so it never reports isReadyForMoreMediaData again, and the loop that could refill it is parked on exactly that signal. Twelve runs with a thirty-second tail after the last seek did not land an episode ON the last seek (about half of one expected at this rate), so the unbounded case was not reached here and is not claimed.

Fix

The generation check is per packet now, and a feed epoch orders the feed against the flush: a caller captures it while its packets are still current and hands it back with each one, and flush() retires it under the same lock decode(packet:epoch:) takes. A caller re-reading a generation cannot close that gap, because it cannot hold the value across the call it is about to make.

Not this

This is not what #492 describes. A frozen pipeline enqueues nothing, so the layer's drop counter does not move while it lasts; the drop-rate question there is separate and is answered in that thread.

Activity

  1. superuser404notfound commented on Sep 6, 2026

    @superuser404notfound
    OwnerAuthor

    Fix is on fix/ae492-parked-feed-outlives-flush (78100459 + 4fcfd7c1), suite green on both runners (XCTest 606, swift-testing 2662). Not merged or released yet.

  2. superuser404notfound commented on Sep 6, 2026

    @superuser404notfound
    OwnerAuthor

    Released in 6.68.4 (750e0ea). Both consumers bumped.

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