Skip to content

fix(routing): reroute remote HLS classified by the loopback session's own open (#246) - #247

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/issue246-second-open-hls-reroute
Jul 29, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/issue246-second-open-hls-reroute

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Problem

The AE#154 reroute onto the native remote-HLS bypass keys on AVIOReaderError.hlsPlaylistOnVODPath. That typed classification only reaches the check when the load-time probe is the open that reads the playlist body.

When the first probe.open fails for an unrelated (transient) reason, probeFailure is inconclusive, shouldReroute returns false, and the load falls through to the loopback path with preopenedDemuxer: nil. HLSVideoEngine.start() then reopens the same URL, and that open is the first to see the body, so it is the one that produces hlsPlaylistOnVODPath. The fallback open interpolated it into HLSVideoEngineError.openFailed(reason: "\(error)"), erasing the domain, and the load died terminally with HLS playlist supplied to the VOD loopback path for a source AVPlayer plays fine (the reporter's manual retry, whose first probe happened to see the body, routed native and reached readyToPlay).

Fix

  • HLSVideoEngine.openFailure(from:) rethrows both HLS classifications verbatim and keeps the wrapped openFailed(reason:) shape for everything else. hlsPlaylistOnRawLivePath rides along so AE#140 stays typed at every open too.
  • load()'s dispatch catch answers the classification from either open with the same AE#154 reroute. It is taken as a full load() restart, the shape the HDR10 4K HEVC 50fps live HLS via nativeRemoteHLS: AVPlayer exposes no video track (audio-only, black); no HDR display-criteria negotiation. VLC + Android decode it fine #168 reroute already uses, because the half-built loopback session has to be cleared; the bypass runs no probe, so it cannot bounce back here a second time.
  • RemoteHLSMediaSelection.shouldReroute is renamed probeFailure: -> failure: since it now answers both origins. No isLive guard is needed: the reader only classifies as hlsPlaylistOnVODPath on the non-live path.

Also fixed, because the reroute would otherwise drop the resume anchor: the nativeRemoteHLS branch never forwarded startPosition, so a VOD playlist restarted at zero whether the host requested the bypass directly or arrived on it through a reroute. Live keeps its no-initial-seek contract even when a host passes an anchor.

Tests

Issue246SecondOpenRerouteTests covers the open-failure mapping and the reroute decision on the error it preserves, including the regression direction (a wrapped classification must not reroute, which is why it must not be wrapped). Full suite 1262/1262 green, -strict-concurrency=complete clean, tvOS Simulator build succeeds.

Reported by qoli (#246).

🤖 Generated with Claude Code

https://claude.ai/code/session_01At1agC2qU2Y2MX2BKLdT4N

… own open (#246)

The AE#154 reroute keys on AVIOReaderError.hlsPlaylistOnVODPath, which only
reaches it when the load-time probe is the open that reads the playlist body.
A probe that failed transiently first left probeFailure inconclusive, so the
load fell through to the loopback path with no preopened demuxer, and
HLSVideoEngine.start()'s fallback open produced the classification instead.
That open interpolated the typed error into openFailed(reason:), erasing the
domain, so a playable source failed terminally while a manual retry played.

The fallback open now rethrows both HLS classifications verbatim, and load()
answers one from either open with the same reroute, taken as a full load()
restart (the #168 shape) so the half-built loopback session is cleared. The
bypass runs no probe, so it cannot bounce back a second time.

The bypass also never forwarded startPosition, which would have dropped the
resume anchor on every reroute; VOD now honors it, live keeps its
no-initial-seek contract.

Reported by qoli.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01At1agC2qU2Y2MX2BKLdT4N
@superuser404notfound
superuser404notfound merged commit 9180efb into main Jul 29, 2026
3 checks passed
@superuser404notfound
superuser404notfound deleted the fix/issue246-second-open-hls-reroute branch July 30, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant