Repository navigation
Backlog
Labels
bugSomething isn't working
Description
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 aSUBTITLESgroup.
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
- 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.
- The watchdog waits a flat five seconds, even though the sender's player falls back to paused within 0.14 s of a refusal.
- The watchdog counts any segment fetch as the receiver starting.
HLSLocalServer.servedMediaBytesis 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 pullsinit.mp4andseg52.mp4from 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.routeChangeHoptakestoWirelessReceiver. 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.handleExternalPlaybackChangeholds edges whileairPlayItemSwapSettlingis set, forairPlayItemSwapSettleSeconds(2 s). ThenreconcileExternalPlaybackAfterReload()reads the audio route, which survives the swap. Without this the passingfalsewould swap back to loopback, and the nexttruewould 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.
armAirPlayProgressWatchdogchecks four times a second throughAirPlayPlaylistDecision.receiverStart:started: the receiver fetched a segment, or the clock moved 0.5 s.refused: the player has sat.pausedagainst the viewer's play intent forrefusalGraceSeconds(2.5 s) with the receiver fetching nothing, orairPlayProgressWatchdogSeconds(5 s) has passed.keepWatching: neither yet.
- Receiver-only fetches.
HLSLocalServersetsservedMediaToReceiveronly for a peer that is neither loopback nor one of the device's own addresses, read throughgetifaddrsat the moment of the check.HLSVideoEngine.hasServedMediaSegmentToReceiverexposes it internally, andhandleRefusedAirPlayMasterand 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 playbacklines after a swap would mean the loop is back. - The first attempt on the loopback URL (the
-1004above) is unchanged. It is short now that the rebuild is gone. - The issue number in the fix (
AE#1145in 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
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
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity