Skip to content

feat(dovi): compose Profile 7 FEL on AVPlayer's own frames behind a load option - #967

Merged
superuser404notfound merged 4 commits into
superuser404notfound:mainfrom
pkajaba:feat/fel-avplayer-output
Nov 3, 2026
Merged

superuser404notfound merged 4 commits into
superuser404notfound:mainfrom
pkajaba:feat/fel-avplayer-output

Conversation

@pkajaba

@pkajaba pkajaba commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Base origin/main c991c8b, tip 8f281dd.

What this does

LoadOptions.dualLayerRoute (default .softwareHost, unchanged) takes .avPlayerOutput with the
DualLayerDolbyVision trait and preferDualLayerDolbyVision on. AVPlayer then plays the base layer and the audio
from the engine's loopback stream and owns the clock; the engine takes its decoded frames from an
AVPlayerItemVideoOutput, pairs each with its enhancement layer, composes them with the composer the software
host uses and presents the result in a display layer on the item's timebase. It is opt-in; every other session loads
as before.

  • The enhancement layer comes from an in-process tap on the segment producer's single read (no second
    connection, no full-file scan); a bounded on-disk ring (1 GiB, unlinked at once) keeps the packets for seeks back.
    The session's forward-buffer window is capped at 10 segments on this route, so the producer's lead stays inside the ring.
  • DualLayerVideoDecoder gets an external-base-layer mode; pairing, RPU, display metadata and kernels are the existing
    code. The compose target is the output pool. Composing in place on the player's buffers is an environment opt-in
    (AETHER_FEL_OUTPUT_INPLACE=1), not shown safe off the Mac.
  • A position with no enhancement layer shows AVPlayer's own base-layer frame (never a frozen picture); every seek, of any
    length and either direction, resets the feed from the clock.
  • When an AirPlay video receiver or an external display holds the picture, the route stops and AVPlayer shows the Profile 8.1
    base layer (logged); Picture in Picture is not offered on this route (nativePlayerLayer is nil), never a blank window.
  • Platforms: macOS build and tests passed on this branch; the tvOS and iOS builds succeed with and without the trait. The Simulators have no hardware video decoders and cannot play a Profile 7 title; 42 route and related tests passed on a tvOS Simulator. tvOS ran on one Apple TV (below); iOS compiles and is selectable but was not run
    on a device.
  • Public API: LoadOptions.dualLayerRoute, DualLayerRoute. Nothing private. Documented in docs/api.md,
    docs/dolby-vision-fel.md, docs/cli.md, CHANGELOG.

Threads and stop: there is no compose queue. A composition runs on the thread that hands the decoder the frame: the route's pull thread, or VideoToolbox's callback thread when the enhancement layer arrives last. The in-flight limit (3) and the pool reserve (3) are upstream's, and there is no stall report. A pull tick can wait for a free GPU slot, a wait that ends when the GPU completes one. stop() waits at most 2 s for a pull or feed tick. Closing the decoder itself still waits for the enhancement-layer session, as on the software host, so a GPU that never completes can still hold it.

Dither differs from the software host (by design)

The compose kernels dither on the parity of a frame index. The software host counts compositions; this route uses the
frame's position in the stream, because with the player delivering frames a count would depend on arrival timing. On a
91 s 4K P7 FEL clip: with the software host given the same index rule, 0 of 2181 compared frames differ (every plane and
every RPU attachment). Against the software host as committed, 1265 of 2181 frames differ, and in 23 sampled raw frames the
differing samples (75.8 million of 286 million) all differ by exactly one 10-bit code; the picture and the RPU differ in nothing else (the route's frames also carry a few extra player attachments). The two routes
share the maths and the pairing; they are not bit-identical.

Tested on Mac

At 8f281dd, with measurement hooks kept out of the commit, Mac only. The plain route run, frame comparisons and tests are on this tree; the seek, ring and --surface runs and the memory figures are from before the last merge of origin/main and the decoder lock change:

  • Default route, compared with origin/main c991c8b: delivered software-host frames on a 91 s 4K P7 FEL clip, 0 of 2182 differ (all planes, colour tags, RPU digest), and 0 samples differ in 23 raw frames.
  • aetherctl play --fel --fel-output, whole clip: fed 2182, pulled and composed 2181, presented 2180 at the last report, 0 base-layer-only, 0 resyncs, 0 dropped, 0 corrupted. The run compared above did not present frame 3 (onlyA [3]).
  • 10 short seeks (0.3 to 2 s, both ways), four runs: landings 68 to 183 ms (one landing at 579 ms in one run), median 130 to 145 ms, 12 resyncs, base-layer-only frames 0, 0, 6 and 9 in ten seeks (at most 5 after one seek), 1318 to 1404 presented, 0 dropped, 0 corrupted.
  • Ring and --surface: with the ring held at 1536 frames by a local hook, seeks past it landed in 81, 161 and 219 ms, 415 base-layer-only frames until the playhead reached held packets, 2254 presented. --surface completed with the overlay shown.
  • Memory: see the Memory section below. CPU and GPU were not re-measured on this branch; the figures from the earlier revision (CPU per frame about equal to the software host, plain AVPlayer 3.7 ms) are not claimed here.
  • Dither numbers above (0 of 2181, 1265 of 2181, 75.8 M of 286 M samples, 1 code) are for this commit.
  • Tests: swift test passes without the trait (5577 Swift Testing tests in 754 suites, XCTest 0 failures). The strict pool run with all traits passes (5993 tests in 794 suites). tvOS and iOS build-for-testing succeed with and without the trait. swift test --enable-all-traits reported 36 issues in 11 local-origin network suites at load 16 to 45; each of the 11 passes alone. I did not run that family on origin/main in this round, and they are not on a known-flake list. 12 runs of the dual-layer suites had 0 hangs.
  • A test race in DualLayerVideoDecoderTests, also on origin/main (2 of 120 runs of the suite): a frame loses its ticket to OrderedDelivery's stall guard and the test waits on it with no limit, so the run stops at the 300 s test limit. This branch takes no decoder lock between pairing a frame and delivering it, because an earlier revision that did so made the race common (14 of 23 runs at the same load). The upstream race is not fixed here.

Measured on an earlier revision, not repeated on this branch:

  • A second 388-frame clip was compared by position on that revision.
  • Rate 1.5 held across a pause and resume.
  • On screen: a --surface capture shows the overlay filling the window with the right aspect and colour (a Mac compositor capture, not a Dolby Vision signal).
  • In-place composition (opt-in): 1384 MB, the plain sum of player and decoder service, against 1583 MB for the route on the same measure.
  • CPU and GPU per frame.

Frame 3 (125 ms in): earlier runs never presented it. The plain run on this branch pulled 2181 frames and the route run above did not present frame 3; another run pulled all 2182. The frame itself was not checked.

Memory

Measured on a Mac with a 91 s 4K Profile 7 FEL clip, one run at a time, 100 s each, median of samples from 40 to 95 s, nothing else running. "Player" is the app process, "decoder service" the system video decoder service its playback uses. Totals count each shared picture buffer once (one footprint call over both processes); the plain sum of the two processes is 250 to 290 MB higher for the two AVPlayer rows because shared buffers show in both.

Software host Plain AVPlayer (enhancement layer discarded) This route
Player + decoder service, shared buffers once about 710 MB about 700 MB about 1250 MB
Player + decoder service, plain sum 713-723 MB 899-962 MB 1514-1556 MB
Decoder service 301 MB 515 MB 930 MB
CoreMedia memory pool 4 MB 330 MB 331 MB
Picture buffers in the player process 315 MB 0 MB 196-208 MB

(The software host's player and service figures trade places between runs, because a shared buffer is attributed to one process or the other; its total stays at about 710 MB.)

What the route adds to plain AVPlayer, in the decoder service (+406 MB of picture buffers): +262 MB from attaching the AVPlayerItemVideoOutput with the route's pixel buffer attributes (measured with the output attached and no frame pulled, no enhancement layer, nothing shown), +95 MB from pulling frames 0.15 s ahead of the clock (four 4K pictures, 24 MB each; 0.10 s gives one picture less), +49 MB for the enhancement-layer decoder session. In the player: a 196 MB output pool for the composed pictures (opt-in in-place composition avoids most of it but is not shown safe). The CoreMedia pool is AVPlayer's own: 330 MB with or without the output, the enhancement layer or the route; only preferredForwardBufferDuration moved it (1 s instead of 4 s: -30 MB, stall risk not measured).

Measured and not a cause or not a lever: suppressesPlayerRendering (changes the service by 2 MB), the HLS segment window (no change), the output's IOSurface and Metal keys (no change), an 8-bit output (-36 MB, loses the 10-bit picture), the pull lead beyond the 95 MB (at zero lead the service still holds 286 MB more than plain AVPlayer). Requesting no pixel format at all removes the 262 MB, but AVPlayer then delivers a packed lossless 10-bit format the composer does not read correctly (every frame differs), so the route requests x420; a conversion step would be needed to use it. Inferred, not measured: that the 262 MB is look-ahead storage AVFoundation keeps for a requested format (the attach-only run proves the cost is the attach, not why it is that size).

The route therefore costs about 540 MB more than the software host and about 550 MB more than plain AVPlayer on this clip. Other clips and bit rates were not measured.

Tested on Apple TV

One run of 11 minutes on an Apple TV 4K, through AetherPlayerView, no seeks, a 4K Profile 7 FEL title with TrueHD Atmos, on the commit before the merge of current origin/main, with failure logging added locally:

  • Fed 15,854, composed 15,837, base-layer-only 1, resyncs 3, failed writes 0. No item failure or recovery.
  • The display layer reported 2133 of 15836 frames dropped (13.5%) in this run, and I have not explained that. The count was read once, at stop, so when they happened is unknown, and nobody watched this run. The route cannot be called smooth on a TV yet.
  • App footprint 612 to 655 MB in the engine's probe, 720 MB peak, no growth. The decoder service on the TV was not measured.
  • Audio is bridged: TrueHD Atmos is decoded and re-encoded as Dolby Digital Plus 5.1, with objects mixed into the floor channels. There are no Atmos objects on this route.
  • A second 11-minute run, on this PR's tree with logging added, same title, no seeks, sampled the count every 5 s: total=15739 dropped=0 corrupted=0, and 0 in all 154 samples. Composed 15,510, no bypasses, no failed writes, peak footprint 743 MB, available memory never below 1358 MB, mean compose GPU time about 18 to 24 ms per frame (highest 74 ms). So the 13.5% did not recur, and when those drops happen is still unknown. This run had one item failure, -11868 at a playhead of 21.42 s (underlying -17223). The reload on the master was refused, which set the media-direct latch, and the media playlist played the rest, about 10.5 of the 11 minutes, after about 3.5 s of frozen picture, resuming at the position it failed at. The first run stayed on the master, so the two runs are not like for like, and with one run each a link between the drops and the master is only a guess. Nobody watched this run either.
  • A separate 23-minute run, in a local test host using AVPlayerViewController with the display layer in its overlay, had AVPlayer's item fail once with -11868 'Cannot open' at a playhead of 22.74 s. Recovery on the same master was refused, and the media playlist then played to the end. That refusal latches the process to media-direct HDR loads. It did not recur in the 11-minute run or in 3 minutes of a later launch of that host. It is intermittent and its cause is not known, so the route is not ruled out.
  • -11868 is not specific to this route. Ten fresh 60-second starts of the same title on this PR's tree with logging added, alternating: plain AVPlayer with the enhancement layer discarded failed in 5 of 5, this route in 5 of 5, every time at a playhead of 21.4 to 21.8 s, 1.4 to 1.8 s after seg6.mp4 was served in full. All ten then played on from the media playlist. The cause is not known, and the logs show no failed request. The panel had accepted the same master 22 s earlier, so the engine's reading of the refusal as a panel HDR refusal looks wrong here, and the first route run above, on the earlier commit, did not fail, though the two commits serve identical bytes for the master, playlists, init and the first eight segments, so the commit does not explain that. The Mac does not fail. A plain start about 10 minutes after restarting the TV failed the same way, and so did three route starts on the earlier commit that had passed that morning, so the commit is ruled out: 15 of 15 starts on the master have failed since then, against 2 earlier passes. Something that changed on the TV, the title or the origin during that day explains the passes. The only logged difference is free space on the TV (about 6.9 GiB against 3.9 GiB), with no mechanism shown; a start with the session cache budget set to the morning value failed too. On this title the master therefore cannot be held past that point, and the 13.5% has only been seen on that first run.
  • A 5-minute route run on the same tree also fell to the media playlist, at 21.68 s, and the layer reported total=7098 dropped=0 corrupted=0. Each of the five 60-second route starts reported 1345 to 1355 frames and 0 dropped. So every drop figure above 0 so far comes from the one run that stayed on the master, and all the 0 figures are nearly all media playlist. An attempt to measure the TV decoder's memory with Instruments in that 5-minute run failed, because the capture disconnected about 1 s after attaching during playback, so that number is still missing.

Still needs Apple TV

  • Slot wait on the pull thread at TV GPU times (no queue or stall report on this base).
  • Frame drops, including the figure above; the 0.15 s pull lead (0.30 s to 0.15 s
    saved about 90 MB on the Mac; 0 bypassed frames at 0.15 s and 0.10 s and 38 at 0.05 s); memory on a TV decoder; seeks on a device.
  • Whether AVPlayerItemVideoOutput buffers can be composed in place on tvOS hardware decoders (opt-in only).
  • An AirPlay receiver run (the hand-back is covered by the decision test, not by a run), Picture in Picture for a host that
    wants it, subtitles on this route, audio-to-video offset on a real display chain.
  • A host with its own AVPlayerViewController gets no picture from the route (the player's rendering is suppressed); the
    option is for hosts using the engine's AetherPlayerView.
  • Also on a device: frame 3 at the start of play, recovery of the display layer after a return from background or a decoder loss (the route sets no flush-to-resume recovery), ring reads and writes on TV flash.
  • iOS has been built only, never run.

…oad option

LoadOptions.dualLayerRoute (default .softwareHost, unchanged) takes
.avPlayerOutput with the DualLayerDolbyVision trait and
preferDualLayerDolbyVision on. AVPlayer then plays the base layer and the
audio from the engine's loopback stream and owns the clock; the engine takes
its decoded frames from an AVPlayerItemVideoOutput, pairs each with its
enhancement layer, composes them with the composer the software host uses and
presents the result in a display layer on the item's timebase.

The enhancement layer comes from an in-process tap on the segment producer's
single read, with a bounded on-disk ring (1 GiB, unlinked at once) that keeps
the packets for seeks back. The forward-buffer window is capped at 10 segments
on this route so the producer's lead stays inside the ring. DualLayerVideoDecoder
gets an external-base-layer mode; pairing, RPU, display metadata and kernels
are the existing code. The route composes into the output pool, not into
AVPlayer's buffers, unless AETHER_FEL_OUTPUT_INPLACE=1 asks for it. A position
with no enhancement layer shows AVPlayer's own base-layer frame, and every seek
of any length resets the feed from the clock. When an AirPlay video receiver or
an external display holds the picture, the route stops and AVPlayer shows the
Profile 8.1 base layer. Picture in Picture is not offered on this route.

A composition runs on the thread that hands the decoder the frame: the pull
thread, or VideoToolbox's callback thread when the enhancement layer arrives
last. stop() waits at most 2 s for a pull or feed tick. Closing the decoder
itself still waits for the enhancement-layer session, as on the software host,
so a GPU that never completes can still hold it.

The two routes share the compose maths and the pairing but are not
bit-identical: the dither parity follows the frame's position in the stream
here, and the software host's count of compositions there. Opt-in; every
other session loads as before. Built on macOS, tvOS and iOS; run on the Mac,
on a tvOS Simulator and once on an Apple TV. CHANGELOG, docs/api.md, docs/cli.md and
docs/dolby-vision-fel.md updated.
@superuser404notfound

Copy link
Copy Markdown
Owner

Thanks for this, Pavel, and for the unusually honest test write-up (the open 13.5% and the -11868 are exactly what I want to know about).

I read it against main and ran it locally merged onto current origin/main (merges clean): swift test --enable-all-traits passes (5993 tests in 794 suites, XCTest 0 failures), and so does the one-thread cooperative pool run. With the option at .softwareHost I see no behaviour change: the software host keeps the counting frame index and in-place composition, and without the trait every new site is empty. So nothing here blocks; two points I'd like to see before it leaves draft:

  1. outputRouteFrameRate is not reset with the other per-source state. loadSession and stop(resetDisplayCriteria:finalTeardown:) clear sourceElType and its neighbours, but not outputRouteFrameRate. Today both loadNative callers either run after the assignment in the route decision or reload the same source, so it is not reachable. But if a future load path reaches loadNative without passing the decision, the stale value would build the route for an unrelated source and suppress AVPlayer's picture. Resetting it next to sourceElType in both places closes that.

  2. DualLayerOutputRoute.stop() blocks the main thread. It is @MainActor, waits up to stopWaitSeconds (2 s) for the feed and pull ticks, and before that decoder.close() waits for the enhancement-layer session without a bound. That runs on every teardown and on the AirPlay / external-display hand-back in handleExternalPlaybackChange. You already call it out in the description; I'd still prefer the waiting part off main (close and drain on a background queue, keeping only the layer/output detach on main), or at least a device log showing how long stop() takes there. We had a main-thread hang on teardown before (dumpPlayerItemTracks freezes the main thread ~4 s on first playback #735), so I'd like to rule it out on the TV before this goes to ready.

Minor, no action needed: the four new suites carry .timeLimit(.minutes(2...3)) and no .offCooperativePoolOneLane. They only use doubles and the strict run is green, so fine as is; just keep it in mind if one of them grows a real composer or clip.

Otherwise I'll wait for your Apple TV list (drops, seeks, memory on the TV decoder, AirPlay, flash behaviour of the 1 GiB ring). Mark it ready when you are happy with it and I'll merge.

CHANGELOG.md: both sides' Added entries kept, the route's last.
@pkajaba
pkajaba marked this pull request as ready for review November 3, 2026 11:13

@quint-aether quint-aether Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review

Status: 🟠 Needs changes. Real issues to fix before merge.

This adds an opt-in second Profile 7 FEL route (LoadOptions.dualLayerRoute = .avPlayerOutput). AVPlayer plays the 8.1 base layer and owns the clock, and the engine composes the enhancement layer onto AVPlayer's frames, using the existing pairing and composer. The direction is right. The fix lives in the engine, it reuses DualLayerVideoDecoder instead of copying it, it stays behind the DualLayerDolbyVision trait, and the default route is unchanged. The PR is now marked ready, but neither of the two points the maintainer asked to see before that is addressed at this head.

Findings

  • Should fix: outputRouteFrameRate is still not reset with the other per-source state in loadSession and in the stop path (maintainer's point 1). (Sources/AetherEngine/AetherEngine.swift:2530)
  • Should fix: DualLayerOutputRoute.stop() still blocks the main actor. It waits without a bound in decoder.close(), then up to 2 s in waitForTicksToEnd(), on every teardown and on the AirPlay hand-back. There is no move off main and no TV log of how long it takes (maintainer's point 2, #735). (Sources/AetherEngine/Native/DualLayerOutputRoute.swift:282)
  • Nit: a loadNative that fails or is superseded after prepareDualLayerOutputRoute leaves the prepared route in dualLayerOutputRoute until the next teardown. (Sources/AetherEngine/AetherEngine+Loading.swift:953)
  • Nit: the new doc section quotes 10 segments, 0.15 s, 1 GiB and 2 s, and DocumentedConstantsTests does not pin any of them. (docs/dolby-vision-fel.md:380)

Checklist: CHANGELOG yes, docs yes, tests yes, traits both ways yes (every new site is behind #if DualLayerDolbyVision or reached only through it)

Needs a device run: On the TV, these are still open:

  • how long stop() takes there
  • the 13.5% display-layer drops seen once, and whether they relate to the master playlist or the -11868 reload
  • seeks on a device
  • memory of the TV decoder service
  • the 1 GiB ring written with pwrite on the segment producer's pump thread, against TV flash and a purgeable temporary directory
  • an AirPlay hand-back run
  • recovery after a return from background
  • iOS, which has never been run

Thanks for the careful measurements and for writing down plainly what is still unexplained.

Automated review by Quint (Claude) of 8f281dd. It reads the code, it does not build or run it; a maintainer reviews and merges.

/// Set by the load's route decision when a Profile 7 FEL source takes `DualLayerRoute.avPlayerOutput`:
/// the stream's frame rate (known and positive; the decision refuses the route otherwise). `loadNative`
/// starts the route for the session it builds.
var outputRouteFrameRate: Double?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open from the maintainer's review: outputRouteFrameRate is set only by the route decision (line 5670). Neither loadSession (next to sourceElType = nil, line 4691) nor the stop path (line 7245) clears it. prepareDualLayerOutputRoute and forwardBufferSegmentsForSession both read it, so a loadNative reached without the decision (a future rebuild path, or one that skips the probe) would build the route for an unrelated source. That route would suppress AVPlayer's picture and cap the forward window. Fix: set outputRouteFrameRate = nil next to sourceElType = nil in both places.

// wait that ends when the GPU completes one and that closing the decoder does not cut short. Only
// the wait for the ticks below is bounded; closing the decoder itself still waits for the
// enhancement-layer session, as on the software host, so a GPU that never completes can still hold it.
decoder.close()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open from the maintainer's review. stop() is @MainActor. decoder.close() waits for the enhancement-layer session without a bound, and waitForTicksToEnd() then parks main for up to stopWaitSeconds (2 s) on a pull tick waiting for a GPU slot. This runs on every stopInternal teardown, on every prepareDualLayerOutputRoute, and in handleExternalPlaybackChange during the AirPlay hand-back. The engine had a main-thread hang on teardown before (#735). Suggested fix: keep the timer cancel, item.remove(output), the overlay detach and the controlTimebase reset on main, and do decoder.close(), the tick drain and the final flush on a background queue. The stopped flag and the decoder's epoch already stop a late tick from handing anything on. If you keep it on main, a device log of how long stop() takes on the TV is the minimum the maintainer asked for.

}
// #260: an observer installed before load has to reach this session's producers too.
session.setNativeVideoFrameTimeObserver(nativeVideoFrameTimeObserver)
prepareDualLayerOutputRoute(session: session)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the route is prepared here, but self.nativeVideoSession = session happens only at line 1342. Between them are the session.start() / prepare() / serve() awaits and the supersede check, and each of those paths stops only the session. A failed or superseded load leaves the route in dualLayerOutputRoute, holding its 1 GiB ring fd and its decoder. In that state nativePlayerLayer returns nil until the next teardown or prepare clears it. Stopping the route (stopDualLayerOutputRoute()) on those failure exits would close the gap.

Comment thread docs/dolby-vision-fel.md

| Part | What it does | Code it reuses |
|---|---|---|
| Base layer and audio | `AVPlayer` plays the engine's loopback HLS stream: the base layer with the RPU converted to Profile 8.1 and the enhancement layer dropped, as on the native route, plus the audio. The item owns the clock. The forward-buffer window of the session is capped at 10 segments (the default) on this route, see the ring below. | the native route, unchanged |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this section quotes several constants: the forward-buffer cap of 10 segments (DualLayerRouteDecision.maxForwardBufferSegments), the 0.15 s pull lead (DualLayerOutputRoute.pullAheadSeconds), the 1 GiB ring (VideoPacketHistory.defaultCapacityBytes) and the 2 s stop bound (stopWaitSeconds). The house rule is that numbers quoted in docs are pinned by DocumentedConstantsTests, and none of these is. Since the route is trait-gated, the pin needs the same #if DualLayerDolbyVision guard.

@quint-aether quint-aether Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review

Status: 🟠 Needs changes. Real issues to fix before merge.

I checked new head 8e2407a and nothing my last review covered has changed. It looks like a rebase onto current main. The two should-fix findings are still open: outputRouteFrameRate is not reset in loadSession and the stop path, and DualLayerOutputRoute.stop() still blocks main. The two nits are open too, and the inline comments from the last review still apply.

Automated review by Quint (Claude) of 8e2407a. It reads the code, it does not build or run it; a maintainer reviews and merges.

DualLayerVideoDecoder.swift: the in-place test keeps composesIntoBase and the measure skip keeps the stall check. Both sides declared streamFrameRate; main's stays, and the route's frame index still only reads it on the external base layer.

@quint-aether quint-aether Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review

Status: 🟠 Needs changes. Real issues to fix before merge.

I checked new head 27f0cd2 and nothing my last review covered has changed. Two should-fix findings are still open. outputRouteFrameRate is not reset in loadSession or in the stop path, and DualLayerOutputRoute.stop() still blocks main. The two nits (the prepared route left in place after a failed or superseded load, and the doc constants not pinned) are also open. The earlier inline comments still apply.

Automated review by Quint (Claude) of 27f0cd2. It reads the code, it does not build or run it; a maintainer reviews and merges.

AetherEngine.swift: the video gravity setter keeps the route's layer update and main's PiP frame refresh.
AetherPlayerView.swift: the hosted layer takes main's PiP frame and the overlay stays at the view's bounds; detach clears both the overlay and the PiP layout.

@quint-aether quint-aether Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review

Status: 🟠 Needs changes. Real issues to fix before merge.

I checked new head 80de16b. Nothing my last review covered has changed; it looks like another rebase onto main. Two should-fix findings are still open: outputRouteFrameRate is not reset in loadSession or in the stop path, and DualLayerOutputRoute.stop() still blocks main. The two nits are also still open: a prepared route is left in place after a failed or superseded load, and the doc constants are not pinned. The earlier inline comments still apply.

Automated review by Quint (Claude) of 80de16b. It reads the code, it does not build or run it; a maintainer reviews and merges.

superuser404notfound pushed a commit that referenced this pull request Nov 3, 2026
…ate, stop it on failed loads

Follow-up to #967, the open review points:

- DualLayerOutputRoute.stop() detaches on main and returns; closing the
  decoder and the bounded wait for the feed and pull ticks run on a
  teardown queue, and the display-layer flush hops back to main after it.
  A pull tick waiting for a GPU slot can no longer park main for up to
  2 s on every teardown or AirPlay hand-back (#735 was a teardown hang).
- outputRouteFrameRate is cleared with sourceElType in loadSession and
  stop(), so a load path that skips the route decision cannot build the
  route for an unrelated source.
- A load that fails or is superseded between preparing the route and
  handing the session over stops that route, and only that one, so its
  1 GiB ring and decoder do not linger.
- DocumentedConstantsTests pins the route's documented numbers (10
  segments, 0.15 s, 1 GiB, 2 s).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SeT6NgupsgTSme7g6RFnE5
@superuser404notfound
superuser404notfound merged commit 566ba87 into superuser404notfound:main Nov 3, 2026
6 checks passed
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged into main as 566ba876, thanks, Pavel. A second FEL route that leaves AVPlayer the clock and the audio is a real addition, and the write-up of what you did and did not see on the TV made it easy to judge.

I pushed one follow-up on top, aa66114e, for the four open review points:

  • DualLayerOutputRoute.stop() now detaches on main (timers, item.remove(output), observer, tap) and returns. decoder.close(), the bounded tick wait and the summary line run on a teardown queue, and the display-layer flush and controlTimebase reset hop back to main after that. The overlay is already detached when stop() runs, so the late flush never touches what is on screen. stop(completion:) reports when it is done; the three teardown tests await it, and the blocked-tick test now also checks that stop() returns to main at once.
  • outputRouteFrameRate is cleared next to sourceElType in loadSession and stop(resetDisplayCriteria:finalTeardown:). The reload path goes through stopInternal, which clears neither, so a rebuild keeps the route as before.
  • A load that throws or is superseded between prepareDualLayerOutputRoute and the session handover now stops its route. It stops only its own route: a newer load may already have prepared the next one, so the check is by identity.
  • DocumentedConstantsTests pins 10 segments, 0.15 s, 1 GiB and the 2 s stop bound against §5.2.4. That section also says now where the wait runs.

Local run of the merge plus the follow-up: all traits (XCTest 833, Swift Testing 6136), the one-lane strict pool and trait off (828 / 5661) are all green, and so are the standalone scripts. The trickle-watchdog test failed once under load in the all-traits run and passed three times on its own.

Still open on the Apple TV, from your list: the 13.5% drops on the master run, -11868 at about 21.5 s (it is not specific to this route), memory of the TV decoder, seeks, and AirPlay. If you get to it, a device log of how long the teardown queue takes would be useful too, since that wait is now off main but still unbounded in decoder.close(). Unreleased for now; this goes out with the next engine release.

@pkajaba
pkajaba deleted the feat/fel-avplayer-output branch November 3, 2026 15:39
@superuser404notfound

Copy link
Copy Markdown
Owner

One more follow-up on main, b34475dc: the route now composes in place by default, as the software host does, and falls back to the pool for a frame canComposeInPlace refuses. AETHER_FEL_OUTPUT_INPLACE=0 turns it off.

Measured on an M2 Pro: 4K 23.976 fps P7 FEL, release aetherctl, footprint at 50 s, process plus VTDecoderXPCService:

Run Process Decoder service Total
plain native, no EL 167 MB 308 MB 475 MB
software host (in place) 44 MB 468 MB 512 MB
route, pool 338 MB 704 MB 1042 MB
route, in place 225 MB 703 MB 928 MB

Most of what remains is AVPlayer's own. On the Mac it decodes into the lossless-compressed &xv0 and converts every frame into the x420 the video output asks for, holding both copies. That conversion is about 235 MB in the decoder service. With no format requested the output vends &xv0 and the service drops to 432 MB, but the composer reads the base layer as 16-bit planes, so that is not usable as is. It may look different on the A12, which is one more reason for a footprint on the TV.

A correction to my earlier comment: the route's summary line is logged in stop() again, not on the teardown queue. aetherctl exits right after stop() and was losing it.

If you do another TV round, the two things that matter most now are picture identity with in place on against AETHER_FEL_OUTPUT_INPLACE=0 over a long GOP (the same question as the copy opt-out in #970), and the footprint of the app plus the decoder service with in place on.

@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.56.0 (76ad51a7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants