Skip to content

Commit c41e5e1

Browse files
fix(network): advertise 127.0.0.1 instead of localhost in playlist URL
Build 122 overlay showed AVPlayer in `timeControlStatus=waitingToPlay reason=AVPlayerWaitingWhileEvaluatingBufferingRateReason` but zero `[HLSLocalServer] conn state=…` lines, even though that handler now fires the moment any TCP connection arrives at the listener (`.preparing` / `.ready` / `.failed` / `.cancelled`). The only way that's consistent: AVPlayer never actually opens a socket to localhost:port. It's hanging upstream of TCP, on hostname resolution. The original comment claimed `localhost` was needed for tvOS ATS to treat the connection as exempt without a per-domain plist entry. That's moot on the consumer side: Sodalite's Info.plist already has both `NSAllowsArbitraryLoads` and `NSAllowsLocalNetworking`, so any HTTP loopback is allowed regardless of host form. The IP literal `127.0.0.1` sidesteps the DNS / nsswitch / /etc/hosts resolution path AVKit appears to hang in. If this lands the connection, the next overlay screenshot will show the burst of `[HLSLocalServer] conn state=ready` plus a `GET /master.m3u8` line within a frame of `play()`. If AVPlayer still hangs after this we know DNS wasn't the cause and can chase the next suspect (codec-string strictness, asset pre-flight) without DNS muddying the signal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5f22c59 commit c41e5e1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

Sources/AetherEngine/Network/HLSLocalServer.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,23 @@ final class HLSLocalServer: @unchecked Sendable {
113113
/// URL the host hands to AVPlayer to start playback. Points at
114114
/// the master playlist if the provider has one, else the media
115115
/// playlist directly.
116+
///
117+
/// Uses the IP literal `127.0.0.1` rather than the hostname
118+
/// `localhost`. The hostname form needs DNS / nsswitch /
119+
/// /etc/hosts to resolve, and AVPlayer on tvOS appears to hang
120+
/// in its pre-flight before opening any TCP socket when
121+
/// resolution doesn't return immediately (build 122
122+
/// `timeControlStatus=waitingToPlay` with zero NWListener
123+
/// state-update events). The IP literal sidesteps the resolver
124+
/// entirely. ATS is covered either way: Sodalite's Info.plist
125+
/// already has `NSAllowsArbitraryLoads` plus
126+
/// `NSAllowsLocalNetworking`, so the original argument for
127+
/// keeping the hostname (per-domain ATS exception avoidance)
128+
/// no longer applies.
116129
var playlistURL: URL? {
117130
guard port > 0 else { return nil }
118131
let path = (provider?.masterCodecs != nil) ? "master.m3u8" : "media.m3u8"
119-
return URL(string: "http://localhost:\(port)/\(path)")
132+
return URL(string: "http://127.0.0.1:\(port)/\(path)")
120133
}
121134

122135
// MARK: - Init

0 commit comments

Comments
 (0)