Repository navigation
Description
What happened?
A host can't tell an AVPlayerItem failure the engine is about to recover in place from one the engine leaves to it. The engine has no public signal for a failure it has absorbed. So a host that watches its own items, which it has to (see below), sees the refused item fail first and rebuilds a session that the engine has already recovered.
Seen on 7.77.0, with the same Apple TV 4K (AppleTV11,1), LG TV and HDR-refusing HDMI chain as #1143.
- Setup: a 4K Dolby Vision Profile 5 MKV, paused. The app goes to the background,
#597releases the pipeline, and the app returns. - Restore:
return from the background clears the panel's HDR-master refusal (#588)is logged, the engine reloads, and the master is served again. - What followed (local times, one process):
47.381 [HLSLocalServer] -> 404 /iframe.m3u8 reason=main variant not playing
47.404 (host) AVPlayerItem.status KVO: item failed -1100
47.405 [NativeAVPlayerHost] #3 item.status=failed err=NSURLErrorDomain/-1100
47.411 (host) failure handled: paused, so parked until Play
47.414 [NativeAVPlayerHost] #3 startup .failed is a master rejection (code=-11848); signalling engine for media fallback instead of surfacing
47.422 [DisplayCriteria] panel refused an HDR master (code=-11848) … (#588)
47.422 [AetherEngine] AVPlayer rejected the master (code=-11848); falling back to media playlist … at 3603.89s
47.423 [NativeAVPlayerHost] #4 load url=…/media.m3u8
47.441 [NativeAVPlayerHost] #4 rate=1.0 (the host reads this as Play and starts its parked rebuild)
48.293 [AetherEngine] load url=… (the host's rebuild: a second full open)
53.437 [NativeAVPlayerHost] #5 item.status=readyToPlay
- Why the host acts first: the host's status observer and
NativeAVPlayerHost's observer see the same KVO change about 1 ms apart. The engine claims the failure (pendingDisplayRejection) only after that. - Cost: the healthy
#4was thrown away, ready came 10.4 s after the return instead of about 5 s, and the warm producer and the AE#1095 parked session were lost. - Where it's cut:
NativeAVPlayerHost.swift1293–1302 in 7.77.0 (1314–1323 onmain).pendingDisplayRejectionis@Published private(set)and internal (line 206), so no host can see it.
Why hosts still watch their own items
Hosts can't simply leave every item failure to the engine and wait for state = .error, because two failures are never published:
- A failed-to-end before the first frame on the loopback route is only counted for the revive escalation (
NativeAVPlayerHost.swiftaround 1000 in 7.77.0, 1019 onmain). The item can stay.readyToPlay, so no status change follows. - The readiness gate's final media fallback discards its readiness result (
_ = await host.awaitStartupReadiness(…),AetherEngine.swift3795 in 7.77.0, 3872 onmain). If that item dies, the comment expects the failure to "surface normally via the host's startup path", but a host that waits for the engine never hears of it.
So a host needs its own observers, and those observers race the engine's in-place recoveries.
What we tried on our side
The app waited up to 3 s after a raw item failure for evidence of an in-place recovery: a different item mounted and .readyToPlay, with no engine error. Only then did it stand down. On the device it worked: the replacement was ready 0.70 s and 1.10 s after the swap, and there was no rebuild.
Three review rounds kept finding new problems in the waiting itself, though. A Play or Pause pressed during the wait has to be held and replayed. A failure reported through both KVO and failed-to-end gets two verdicts. A load that starts during the wait has to own what it mounts. A paused failure can drift into the budgeted recovery path. Each of these is a guess at what the engine already knows, so we've shelved it.
Expected
Some way for a host to know, at the moment an item fails, that the engine has taken it over. Any of these would do:
- A published disposition the host can read synchronously. Published per item, set before the failure leaves the engine's own observer. For example,
AetherEngine.absorbedItemFailure: (item: ObjectIdentifier, reason: .displayRejection | .originRefusal | .stereoRefusal | .softwareEscalation)?. OrcurrentItemFailureOwnedByEngine: Bool, cleared when the next item mounts. - An event stream such as
itemFailureEventswith.absorbed(item, reason)and.surfaced(PlaybackErrorInfo). There's precedent: the software-path escalation already hands hosts aSoftwarePathEscalationwithabsorbedFailure. - The engine publishing the two cases above as
state = .error. Hosts could then rely on the engine alone and drop their raw observers.
With (1) or (2), the host checks one value in its handler and stands down, with no timing involved. (3) removes the need for host observers entirely, and would also make the gate comment at 3795 / 3872 hold for hosts that wait for the engine.
Environment
- Engine: AetherEngine 7.77.0, FFmpegBuild 3.19.3. The line references are checked against
main(cf3c6ea0) too. - Device: Apple TV 4K (2nd gen), tvOS 27.x, LG TV, HDMI chain reporting
dv=false. - Related: Startup readiness gate: a media-playlist fallback never latches panelRefusedHDRMaster, so every HDR load on a refusing panel repeats the ~10 s escalation #1143 (the gate latch, fixed on
main), The master-refusal latch goes stale after an output-format change, and costs more than the master route #588 (the latch lifetime: the foreground clear is what re-runs the refusal), AE#1095 (the parked session lost to the rebuild).
Activity