Skip to content

Software path after an in-place switch: on a title with no audio the clock starts about 0.93 s before the first frame, and 5 to 7 frames drop #800

Open

Description

@cmcpherson274

On an Apple TV, when a running session is switched from the native path to the software path in place (preferredDecodePath = .software), a title with no audio track starts its clock about 0.93 s before the first frame is enqueued, and the renderer drops 5 to 7 frames within about a second of that frame. Three runs on each of 7.35.1 and 7.36.0 read the same.

Setup. Apple TV 4K (3rd generation, AppleTV14,1), tvOS 26.6, Debug builds of our app, both engines in one sitting on 15 October, each run in a fresh process. The title is a 110 s Dolby Vision profile 8.1 test clip (HEVC 3840x2014, 10-bit, 23.976 fps, 11 keyframes, no audio track, so the engine logs audio delivery = noAudioInSource), played direct from Jellyfin and resumed at 30 s on the native path through our loopback route. Our app switches a session to the software path when the native path has shown no picture for 60 s. In these runs we forced that switch with a test hook of ours that hides the first frame from the app's check, so the title was playing natively when the switch came. The engine logs #460: reload applying preferredDecodePath and #461: host asked for the software path, overriding the native route, and the software session opens at the current position, about 86.4 to 86.6 s.

What we see. Positions are seconds of media; the gap is wall time between the two lines' timestamps.

engine run clock start, [AudioOutput] seekClock to= first frame, [SWHost] first video frame enqueued: … pts= clock start to first frame layerDrop at the [SWDiag] tick about 1 s after the first frame dropped in the run, stats final
7.35.1 1 86.400 86.420 s 0.899 s 5 5
7.35.1 2 86.600 86.628 s 0.940 s 7 7
7.35.1 3 86.600 86.628 s 0.949 s 6 6
7.36.0 1 86.600 86.628 s 0.935 s 5 5
7.36.0 2 86.601 86.628 s 0.929 s 5 5
7.36.0 3 86.400 86.420 s 0.905 s 5 5

The drops appear on the tick 0.99 to 1.08 s after the first frame; on five runs an earlier tick, 0.03 to 0.08 s after it, still reads layerDrop=0(+0), as in the lines below. No later tick adds one, and every run reports 0 stalls. No clock re-anchored line follows the switch on any run. 7.36.0, run 1, the lines from the clock start (date and level prefix cut, nothing else changed):

20:40:58.587 [AudioOutput] seekClock to=86.600 rate=1.0
20:40:58.768 [SWReadAhead] producer qos -> utility (now=utility reservoir=20.1s relax=20.0s boost=10.0s waiting=0)
20:40:59.512 [SWDecoder] output 10-bit P010, video range (frame yuv420p10le, color_range=1)
20:40:59.522 [SWHost] first video frame enqueued: pixfmt=0x78343230 size=3840x2014 pts=86.628s
20:40:59.527 [SWHost] picture settles at 3840x2014 after 1 frames
20:40:59.531 [Renderer] enqueue #1: status=rendering ready=true error=nil
20:40:59.531 [SWHost] layer.isReadyForDisplay=true after 2 frames
20:40:59.532 [AetherEngine] #361 startup 8/8 presenting (gen 2)
20:40:59.564 [SWDiag] clk=87.57 dclk=- rate=1.00 aLead=- aRend=unknown/n/- vLead=-0.78 parkedPkts=0 rebuf=n enq=+5 disp=+4 lost=0(+0) dpts=41.7/41.7 layerDrop=0(+0) delay=0.00(+0.00) corrupt=0 status=rendering surf=1920x1080 r4d=y
20:40:59.858 [Renderer] enqueue #30: status=rendering ready=true error=nil
20:41:00.564 [SWDiag] clk=88.57 dclk=1.00 rate=1.00 aLead=- aRend=unknown/n/- vLead=-0.15 parkedPkts=0 rebuf=n enq=+51 disp=+51 lost=0(+0) dpts=41.7/41.7 layerDrop=5(+5) delay=0.00(+0.00) corrupt=0 status=rendering surf=1920x1080 r4d=y
20:41:01.564 [SWDiag] clk=89.57 dclk=1.00 rate=1.00 aLead=- aRend=unknown/n/- vLead=0.35 parkedPkts=0 rebuf=n enq=+24 disp=+24 lost=0(+0) dpts=41.7/41.7 layerDrop=5(+0) delay=0.00(+0.00) corrupt=0 status=rendering surf=1920x1080 r4d=y

Earlier runs of the same steps, for context. At 7.1.3 and 7.7.1 they read 0 frames dropped (our comment on #461, 21 September). Single runs on 13 October, in the table's columns:

engine clock start, seekClock to= first frame pts= clock start to first frame layerDrop about 1 s after the first frame dropped in the run
7.28.3 83.417, then [SWHost] clock re-anchored to first sample: anchor=83.417s (load anchor 86.700s, sessionZero=0.000s) 86.712 s 0.979 s 0 0
7.35.1 86.601 86.628 s 0.927 s 5 5

At 7.28.3, before 7.32.2's anchor change for #724, the gap was about the same, but the clock started 3.3 s behind the first frame: the tick right after that frame read clk=84.39 and vLead=2.32. On the six later runs whose tick came within 0.08 s of the first frame (7.35.1 on 13 October and five of the six above), it read vLead -0.66 to -0.82. One run of a 1080p H.264 title with an audio track through the same switch at 7.35.1 read 0.298 s and 3 frames dropped; we have not repeated that one.

7.37.0 came out after these runs, and we have not run it. Its video preroll (#774) holds the clock until frames are queued; the comment on it names "five dropped frames at every start and every seek on an Apple TV 4K (A12)" on the Profile 7 FEL route (AudioOutput.swift:414-416), and the software host applies it to that route only: "every other route answers nil and starts at once" (SoftwarePlaybackHost.swift:1222-1224; both files at 7.37.0). This title is profile 8.1, a single layer. 7.37.0 also keeps the tvOS software packet cache in memory (#776).

What we expected. The first frames after the switch shown at their times, without drops.

We have no screen recording of these runs, so we cannot say how the drops look on the TV.

7.35.1 is our app's engine pin as of today (2026-10-16); 7.36.0 is the candidate, measured beside it.

Activity

  1. superuser404notfound commented on Oct 16, 2026

    @superuser404notfound
    Owner

    Thanks for the careful measurements, the 7.28.3 comparison was what pinned it down.

    Cause. The software host started its clock when the first packet went into the decoder (a title with no audio) or when the first audio buffer decoded (a title with audio). At that moment the video decoder was still working from the keyframe before the target up to the target. On a 10 s GOP that is about 3 s of 4K HEVC to decode, which matches the ~0.93 s you measured. The first frames then reached the layer late and were dropped. Before 7.32.2 the #724 re-anchor started the clock a whole GOP behind, on the keyframe, and that hid the gap. Once the anchor stayed on the target, the gap became visible. Your 1080p H.264 run with audio (0.298 s, 3 dropped) is the same thing, armed by audio instead.

    Fix. 713c62a on main, not released yet. The video preroll that #774 added for the FEL route now covers every software VOD route. The clock waits at rate 0 until frames from its position on (0.125 s worth) are in the layer, then starts 250 ms from that moment. The same applies to starts, seeks and the in-place switch. Live streams off the FEL route still start at once, so the live join is unchanged.

    On the Mac, with a 4K HEVC 10-bit fixture with no audio and 10 s GOPs, through the same in-place native to software switch:

    before: [AudioOutput] seekClock to=37.925 rate=1.0
            [SWHost] first video frame enqueued: ... pts=38.038s
    after:  [AudioOutput] seekClock to=38.025 rate=1.0
            [SWHost] first video frame enqueued: ... pts=38.038s
            [AudioOutput] preroll ready after 1069 ms; starting at t=38.025 rate=1.0
    

    That shows the clock now waits for the picture. It does not show the drop count: the CLI has no render surface, so layerDrop climbs in every run there and means nothing. Whether the 5 to 7 drops are gone on the Apple TV still needs a device run. The [AudioOutput] preroll ready after N ms line is the one to look for. A timed out in its place would mean the gate never opened, and that run is worth sending.

    I'll leave this open until it has been measured on the device.

  2. superuser404notfound commented on Oct 16, 2026

    @superuser404notfound
    Owner

    Released in 7.38.0 (713c62a). Sodalite and AetherPlayer already pin it.

  3. cmcpherson274 commented on Oct 22, 2026

    @cmcpherson274
    Author

    A correction to the issue text: 7.37.0 was published at 21:37 UTC on 15 October, about 2 h 49 min before the first of these runs (00:26 UTC on 16 October); we ran 7.35.1 and 7.36.0 only.

    Here is the device reading you asked for. We ran 7.44.0, which carries 7.38.0's preroll gate unchanged (AudioOutput.swift and SampleBufferRenderer.swift are the same files at 7.38.0 and 7.44.0), beside 7.36.0. In short: the start drops this issue reported are gone on both of its titles, the clock now waits 0.05 to 1.1 s for the first frames, and on one 4K AV1 title the gate timed out at the start and after every seek.

    Setup. Apple TV 4K (3rd generation, AppleTV14,1), now on tvOS 27.0 (24J361); the issue's runs were on tvOS 26.6. Debug builds of our app, in one sitting on the evening of 20 October (US Eastern): 7.36.0, then 7.44.0, then 7.36.0 again, each run in a fresh process; 7.44.0 with none of its optional traits enabled. FFmpegBuild also differs between the two (3.7.1 and 3.9.0). Full-screen VOD played direct from Jellyfin through our loopback route. The issue's two titles were resumed at 30 s and switched in place to the software path by our app's 60 s no-picture check, with our test hook hiding the first frame from that check, as in the issue; The First 9½ Weeks was switched the same way without the hook. The VC-1 and AV1 titles start on the software path (our app's check reads hardware AV1 decode: false on this Apple TV).

    What we see. Seconds after the session's first [AudioOutput] seekClock line, median [range] over n runs per version, 7.36.0 → 7.44.0. Dropped frames are the layerDrop increments in the [SWDiag] ticks: at a start, from the first frame to 2 s (and to 15 s) after it; after a seek or the unpause, to 15 s after it or the next seek, whichever comes first. "Moving" is the later of the first [SWHost] layer.isReadyForDisplay=true and the clock starting: on 7.36.0 the clock runs at once (back-dated from the first running tick); on 7.44.0 it starts prerollStartLead (0.25 s) after the preroll line, as the next tick confirms.

    title, route n dropped at the start, 2 s (15 s) dropped after seeks preroll on 7.44.0 first frame ready moving
    the issue's DV P8.1 clip, 4K HEVC, no audio, switched at about 85.7 s 3 7, 5, 5 → 0, 0, 0 (same) — ready 800 ms [783–807] 0.712 [0.705–0.712] → 0.735 [0.733–0.773] 0.712 [0.705–0.712] → 1.050 [1.034–1.057]
    …First Do No Harm, 1080p H.264 + AAC, switched at about 87.2 s 3 2, 2, 2 → 0, 0, 0 (same) — ready 298 ms [297–300] 0.317 [0.303–0.317] → 0.290 [0.288–0.292] 0.317 [0.303–0.317] → 0.549 [0.547–0.550]
    The First 9½ Weeks, 1080p H.264 + E-AC-3, switched at about 57 s 1 0 → 0 — ready 51 ms 0.069 → 0.046 0.174 → 0.302
    The Lowdown, 1080p VC-1, resumed at 600 s, seeks to 900 s and 700 s, a pause 3 5, 5, 5 → 2, 2, 2 (same) 35 → 0 over 6 seeks; 0 → 0 after the unpause ready 67 ms [66–72]; seeks 95–248 ms 0.054 [0.052–0.055] → 0.044 [0.041–0.045] 0.198 [0.198–0.200] → 0.317 [0.317–0.323]
    Four Christmases, 1080p VC-1 + TrueHD, from 600 s, seeks to 610 s and 605 s 1 3 → 0 (same) 9 → 0 over 2 seeks ready 301 ms; seeks 125, 124 ms 0.287 → 0.260 0.287 → 0.552
    The Act of Killing, 1080p AV1, from 600 s, seeks to 900 s and 700 s 1 5 → 1 (same) 15 → 0 over 2 seeks ready 1,114 ms; seeks 487, 467 ms 1.213 → 1.090 1.213 → 1.365
    Currahee, 3840x2160 AV1, from 600 s for 150 s, 5 seeks 1 16 → 8 (19 → 8) 162 → 70 over 5 seeks timed out after 2,003 ms; seeks 2,002, 2,003, 2,000, 2,000, 2,001 ms 3.268 → 3.248 3.268 → 3.248
    • An unpause on the Apple TV (The Lowdown, paused 20 s): our press → the clock running 0.24 → 0.42 s (preroll ready after 123 ms).
    • Over the 13 device starts in the table the picture starts moving 0.23 s later on 7.44.0 (median; −0.02 to +0.35 s).
    • Left out of the table: one 7.44.0 run of The First 9½ Weeks, in which our bench's HDMI output dropped (audioRoute changed reason=2, no ports) before the switch (its 7.36.0 pair dropped 0), and the in-place reload after the same kind of drop in one 7.44.0 run of The Lowdown and in the 7.36.0 run of The Act of Killing (17 and 14 drops in about 3 s after each reload).

    On the DV clip the first [SWDiag] tick after the first frame read the clock 0.953 s past the frame's pts on all three 7.36.0 runs, and 0.011 to 0.036 s behind it on 7.44.0. On 7.36.0 the clock still started 0.693 to 0.700 s before the first frame was enqueued on this tvOS (0.90 to 0.95 s on tvOS 26.6 in the issue). 7.44.0, run 1 (date, level and our log's own prefix cut, nothing else changed):

    22:28:44.123 [AudioOutput] seekClock to=85.700 rate=1.0
    22:28:44.839 [SWHost] first video frame enqueued: pixfmt=0x78343230 size=3840x2014 pts=85.711s
    22:28:44.858 [SWHost] layer.isReadyForDisplay=true after 2 frames
    22:28:44.923 [AudioOutput] preroll ready after 800 ms; starting at t=85.700 rate=1.0
    22:28:45.104 [SWDiag] clk=85.70 dclk=- rate=1.00 aLead=- aRend=unknown/n/- vLead=0.01 parkedPkts=0 rebuf=n enq=+7 disp=+6 lost=0(+0) dpts=41.7/41.7 layerDrop=0(+0) delay=0.00(+0.00) corrupt=0 status=rendering surf=1920x1080 r4d=y
    22:28:46.104 [SWDiag] clk=86.63 dclk=0.93 rate=1.00 aLead=- aRend=unknown/n/- vLead=0.29 parkedPkts=0 rebuf=n enq=+24 disp=+24 lost=0(+0) dpts=41.7/41.7 layerDrop=0(+0) delay=0.00(+0.00) corrupt=0 status=rendering surf=1920x1080 r4d=y
    

    From the logs (we have no recording): on the issue's two titles the picture now moves from its first frame instead of skipping 2 to 7 frames, and it starts moving 0.23 to 0.35 s later than the first picture appeared on 7.36.0. We cannot say how the held first frame looks on the TV.

    The 4K AV1 title (Currahee, libdav1d with five threads, audio decoded) timed out at the start and after all five seeks; a second run of that title alone on 21 October timed out six times again (2,002 ms at the start, 2,001 ms after each seek). Its first picture was no later than on 7.36.0, counted from each seekClock line: 3.248 against 3.268 s at the start; 2.86, 2.91, 2.86 and 3.82 s against 2.91, 3.13, 3.15 and 3.90 s after four of the five seeks (after the seek to 300 s neither version showed a picture before the next seek). So once the cap released, the clock still started 1.0 s before the first picture at the start and 0.6 to 1.6 s before it after the seeks, and the drops fell without reaching zero (187 → 84 over the 150 s). FFmpegBuild 3.9.0 against 3.7.1 (libdav1d unchanged) is a second possible cause of this title's drop change. The start, 7.44.0:

    22:42:30.952 [AudioOutput] seekClock to=600.000 rate=1.0
    22:42:32.955 [AudioOutput] preroll timed out after 2003 ms; starting at t=600.000 rate=1.0
    22:42:33.937 [SWDiag] clk=600.73 dclk=0.73 rate=1.00 aLead=-1.43 aRend=rendering/n/- vLead=- parkedPkts=0 rebuf=n enq=+0 disp=+0 lost=0(+0) dpts=- layerDrop=-1(+0) delay=-(+0.00) corrupt=-1 status=unknown surf=1920x1080 r4d=n
    22:42:34.177 [SWHost] first video frame enqueued: pixfmt=0x78343230 size=3840x2160 pts=600.016s
    22:42:34.200 [SWHost] layer.isReadyForDisplay=true after 2 frames
    

    One request. Our app ends a software session after five clock stalls of 1.5 s or more within 60 s, judged from the session's clock. On the first Currahee run it counted three of the held clocks as stalls (no session ended). We now treat the clock as held from a seekClock line, while our clock still reads that position, until the next preroll line plus 0.25 s, and the second run counted none. Two things the log text cannot tell us: which engine printed an [AudioOutput] line (they carry no engine identifier, and we run several engines at once for multiview), and that a hold has begun (seekClock to= reads the same whether the gate then holds or not, so we only learn that the gate exists after a first preroll line). Would you consider exposing the hold as engine state or as a per-engine callback (when it starts, when it is released, ready or timed out, and for which engine), so that a host does not have to read log lines?

    7.44.0 is our app's engine pin as of today (2026-10-21).

  4. superuser404notfound commented on Oct 24, 2026

    @superuser404notfound
    Owner

    Thanks for the device round, and for the 7.37.0 correction. The per-title table is exactly what was needed: on the two titles this issue was about, the start drops are gone, and the gate opened every time.

    4K AV1 timing out. The gate gave up after a flat 2 s from the seekClock line. On Currahee libdav1d needs 2.9 to 3.9 s to decode from the keyframe up to the target, so the timeout started the clock before the first frame at the target existed, and the frames due in between dropped. Since 97e32c5 on main (merged in 88a459e, not released yet) a hold no longer gives up on a decoder that is still working. It waits as long as the decoder keeps producing frames, including the ones it discards on the way to the target, up to 6 s. A decoder that produces nothing for 2 s still times out as before. On that title the six timed out lines should become preroll ready after ~3000 ms, with the clock starting on the first frame instead of 0.6 to 1.6 s ahead of it. The picture will not arrive any sooner, it just will not be chased. The steady-state drops (84 over 150 s) are a separate question. If libdav1d at five threads is that close to real time on the A15, they come from decoder throughput, not from the start, and this change will not touch them.

    The hold as engine state. Done in the same commit. Each AetherEngine instance now has:

    • isClockHeld (@Published): true while the clock stands at rate 0 waiting for frames.
    • clockHoldEvents (AnyPublisher<ClockHoldEvent, Never>): .began, then exactly one .released(ClockHoldRelease). The release is .ready(waitedSeconds:), .timedOut(waitedSeconds:) or .cancelled. A newer seek, a pause, a rate change or the end of the session releases a waiting hold as .cancelled first, so holds never nest.

    Both are per instance, so each engine in a multiview reports its own holds. The clock starts 0.25 s after .ready or .timedOut. A start whose frames are already queued does not hold and emits nothing. The AVPlayer paths, the audio-only host and live streams off the FEL route never hold. It is documented in docs/api.md next to seekEvents.

    I'll leave this open until the AV1 title has been measured on a release that carries it.

  5. superuser404notfound commented on Oct 26, 2026

    @superuser404notfound
    Owner

    Released in 7.48.0 (263dc11). Leaving this open for the retest.

  6. added a commit that references this issue on Nov 3, 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