Skip to content

AirPlay to a receiver that refuses the HDR master takes 8 s or more to start, or never starts #1150

Backlog

Description

@ijuniorfu

What happened?

Summary

AirPlaying a 4K HDR10 video from an iPhone to a Mac mini receiver shows nothing for several seconds. In the session below the viewer closed the receiver window after about 3 s, before the engine's media fallback came, so nothing ever played. Three things add up, and each has a small fix, given in full below.

Setup

  • Sender: iPhone, iOS 27.2.1, native route (HEVC, stream-copied AAC, served as HLS fMP4 from the loopback server).
  • Receiver: Mac mini (Mac16,10), macOS 27.2.1, AirPlay Receiver on, on a 1080p SDR display.
  • Source: 3840x2160 HEVC Main 10 PQ (HDR10), MKV on a cloud drive, peak segment bitrate about 48 Mbps.
  • Master as served: CODECS="hvc1.2.6.L150.90,mp4a.40.2",RESOLUTION=3840x2160,VIDEO-RANGE=PQ,BANDWIDTH=52651984, with a SUBTITLES group.

What happens

From the sender's engine log and the receiver's own unified log (times are the receiver's clock):

Time What
50.15 The receiver is handed the loopback URL first and gets -1004 (connection refused); the sender tears that stream down.
50.18 to 52.45 The engine logs external playback active (wireless) -> LAN reload and rebuilds the session. The rebuild reopens the source (connect 792ms, open_input 650ms, find_stream_info 522ms), about 2.3 s before the receiver sees the LAN address.
52.54 The receiver fetches master.m3u8 (200).
52.55 The receiver refuses it: CoreMediaErrorDomain -17223, AVFoundationErrorDomain -11868. It reports a 1920x1080 display that does not prefer HDR10. It then fetches media.m3u8 and never asks for init.mp4 or a segment.
(sender) Nothing fails on the sender. timeControlStatus=playing for one tick at t+0.04 s, then rate=0.0 reason=nil, paused at t+0.14 s, with play intent still true.
55.62 The viewer closes the receiver window (UserStop). The five-second progress watchdog had not fired yet.

Causes

  1. The rebuild costs about 2.3 s for nothing. The server already listens on every interface and keeps its segments, and the refusal fallback already moves a session onto the LAN by swapping the item. Only the address has to change.
  2. The watchdog waits a flat five seconds, even though the sender's player falls back to paused within 0.14 s of a refusal.
  3. The watchdog counts any segment fetch as the receiver starting. HLSLocalServer.servedMediaBytes is set for every client, and the sender's own player fetches from the same server over the LAN address (in the same log the iPhone pulls init.mp4 and seg52.mp4 from its own LAN IP). A refusing receiver can then read as one that started, and the fallback never comes.

Fix

  • Swap instead of rebuild. AirPlayPlaylistDecision.routeChangeHop takes toWirelessReceiver. An on-demand session going onto a wireless receiver gets .swapItem. The way back to the device keeps the rebuild, since it picks the playlist and display criteria for the local panel again, and so do live URL sessions, so they rejoin at the edge.
  • A hold on the swap, as on the rebuild (Native subtitles cannot reach a wireless AirPlay receiver: renditions live in the master playlist, but the AirPlay path forces the media playlist #227). A swap replaces the item the external-playback KVO watches, which reads as a passing false. handleExternalPlaybackChange holds edges while airPlayItemSwapSettling is set, for airPlayItemSwapSettleSeconds (2 s). Then reconcileExternalPlaybackAfterReload() reads the audio route, which survives the swap. Without this the passing false would swap back to loopback, and the next true would swap forward again. That is the loop Native subtitles cannot reach a wireless AirPlay receiver: renditions live in the master playlist, but the AirPlay path forces the media playlist #227 fixed for the rebuild. The existing sequential-origin and forward-only swaps get the same hold.
  • A polled watchdog. armAirPlayProgressWatchdog checks four times a second through AirPlayPlaylistDecision.receiverStart:
    • started: the receiver fetched a segment, or the clock moved 0.5 s.
    • refused: the player has sat .paused against the viewer's play intent for refusalGraceSeconds (2.5 s) with the receiver fetching nothing, or airPlayProgressWatchdogSeconds (5 s) has passed.
    • keepWatching: neither yet.
  • Receiver-only fetches. HLSLocalServer sets servedMediaToReceiver only for a peer that is neither loopback nor one of the device's own addresses, read through getifaddrs at the moment of the check. HLSVideoEngine.hasServedMediaSegmentToReceiver exposes it internally, and handleRefusedAirPlayMaster and the watchdog use it. No public API changes.

With the fix, this receiver should get the LAN media playlist about 3 s after AirPlay is picked instead of about 8, and play it.

Open points

  • The 2.5 s grace rests on the existing note that a receiver which takes the master fetches its init segment within about a second (device log 2026-07-27, Apple TV 4K). A slower receiver that accepts but takes longer than 2.5 s would wrongly get the media playlist and lose its subtitle renditions. A measured healthy start on more receivers would settle it.
  • The swap now covers every on-demand session, not only sequential origins. Its edge hold is reasoned from the Native subtitles cannot reach a wireless AirPlay receiver: renditions live in the master playlist, but the AirPlay path forces the media playlist #227 rebuild hold but not yet seen against a real receiver. Repeated [AirPlay] external playback lines after a swap would mean the loop is back.
  • The first attempt on the loopback URL (the -1004 above) is unchanged. It is short now that the rebuild is gone.
  • The issue number in the fix (AE#1145 in comments, docs, CHANGELOG and test names) is a placeholder. Please replace it with this issue's number.

Steps to reproduce

none

AetherEngine version or commit SHA

cf3c6ea

Host app

Custom / my own integration

Platform

iOS

OS version

iOS

Device / chip

iPhone

Playback path

Native AVPlayer

Source media (for playback bugs)

No response

Error codes / log lines


Anything else

No response

Activity

  1. added
    bug
    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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions