Skip to content

Native host: no signal that the engine absorbed an item failure, so a host's own item observers rebuild sessions the engine already recovered #1151

Backlog

Description

@hp561

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, #597 releases 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 #4 was 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.swift 1293–1302 in 7.77.0 (1314–1323 on main). pendingDisplayRejection is @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:

  1. A failed-to-end before the first frame on the loopback route is only counted for the revive escalation (NativeAVPlayerHost.swift around 1000 in 7.77.0, 1019 on main). The item can stay .readyToPlay, so no status change follows.
  2. The readiness gate's final media fallback discards its readiness result (_ = await host.awaitStartupReadiness(…), AetherEngine.swift 3795 in 7.77.0, 3872 on main). 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:

  1. 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)?. Or currentItemFailureOwnedByEngine: Bool, cleared when the next item mounts.
  2. An event stream such as itemFailureEvents with .absorbed(item, reason) and .surfaced(PlaybackErrorInfo). There's precedent: the software-path escalation already hands hosts a SoftwarePathEscalation with absorbedFailure.
  3. 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

Activity

  1. added
    area: api
    area: hdr-dv
    enhancement
    on Nov 29, 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

    area: apiarea: hdr-dvenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions