Repository navigation
fix(native): declare the HLS MIME type on the #154 reroute so a mis-typed playlist plays - #1040
Conversation
…reroute so a mis-typed playlist plays The superuser404notfound#154 reroute moves a load onto the AVPlayer bypass because the engine read #EXTM3U in the body, but AVFoundation types a URL by its path extension and Content-Type only. A VOD playlist at /movie.mp4 served as video/mp4 or application/octet-stream therefore failed on the bypass with AVFoundation -11829 / -11828 within a third of a second. The reroute (and the AE#246 second-open reroute) now marks the options with engine-internal body evidence, and the bypass creates the asset with AVURLAssetOverrideMIMETypeKey = application/vnd.apple.mpegurl. The flag rides loadedOptions and the session contract, so rebuilds and in-place swaps of the rerouted session keep it. A host-set nativeRemoteHLS load and the loopback path declare nothing. Co-Authored-By: Paperclip <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
…laration as fork-only until upstream superuser404notfound#1040 Co-Authored-By: Paperclip <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Automated review
Status: 🟡 Minor follow-ups. Only small touch-ups left.
When the engine has read the body and found an HLS playlist (the AE#154 reroute and the AE#246 second-open reroute), the bypass asset now declares application/vnd.apple.mpegurl through AVURLAssetOverrideMIMETypeKey. Without it, a playlist behind an .mp4 or extensionless URL, served as video/mp4 or application/octet-stream, fails on AVFoundation's own typing. The direction is right. The fix is in the engine, it goes only where the engine has evidence, and a host-set nativeRemoteHLS load keeps AVFoundation's typing.
Things I checked that hold up:
- Flag lifetime. The flag cannot be set from the public initializer, so every host
load()starts at false. It ridesloadedOptions, soreloadAtCurrentPosition(which goes straight onto the bypass without a probe) keeps it. A correction closure cannot reach it from outside the module. - Field order.
hlsPlaylistProvenByBodyis the last stored property ofLoadOptionsand the last entry inknownFields. That keeps the orderedfieldInventoryIsCompletecomparison green. - Contract.
declaresHLSPlaylistMIMETypesits onSessionLoadContract, so in-place swaps reuse it the same way they reusehttpHeaders. The loopback route builds its own contract, where the value defaults to false. - Stand-in URL. On the #316 / AE#495 stand-in path the declaration lands on the loopback master instead of the origin URL. That URL is a playlist too, so this does no harm.
- API. No public API change. The new field and the static are internal.
- Availability. The override key's minimum OS versions are below the package's minimums.
Findings
- Nit: The guide's #154 paragraph now covers two unrelated topics: subtitle media selection and MIME typing on the reroute.
CLAUDE.mdasks for one idea per paragraph, with new facts not appended to an existing one. A short paragraph of its own (for example "Mis-typed playlists on the reroute (#154)") would fit the house style better. (docs/guide.md:418)
Checklist: CHANGELOG yes, docs yes, tests yes, traits both ways n.a.
Needs a device run: whether tvOS and iOS honour the override the same way on a real IPTV origin (the measurements are macOS-only). The same goes for a master playlist whose variant playlists are themselves served under .mp4 paths with a video type: the override applies only to the asset's top-level URL.
Thanks for the careful measurement table and for keeping the declaration limited to the cases the engine has proven.
Automated review by Quint (Claude) of 70010f1. It reads the code, it does not build or run it; a maintainer reviews and merges.
| **Live `m3u8` on the loopback path** (#363). The raw live path reads bytes, not playlists. It used to reject an `.m3u8` with a typed `hlsPlaylistOnRawLivePath` error that named the reader the host should have built. Now it builds that reader itself, with `LoadOptions.httpHeaders` on the playlist, every segment and every AES key, which is what a tokenized IPTV origin checks per request. Credential headers stay with the playlist's own origin: a segment or key on another host, or on http:// behind an https:// playlist, gets the other headers but not the token. A custom `IOReader` with the same mistake still gets the typed error, because it has no playlist URL to ingest from. | ||
|
|
||
| **Non-live `m3u8` on the loopback path** (#154). The bundled FFmpeg is built without network support, so the playlist can never be demuxed locally, and remote HLS is AVPlayer's job anyway. On the bypass, the engine lists the stream's external WebVTT renditions (the legible `AVMediaSelectionGroup`) as `subtitleTracks`. `selectSubtitleTrack(index:)` and `clearSubtitle()` drive AVPlayer's media selection, and AVPlayer draws the cues. | ||
| **Non-live `m3u8` on the loopback path** (#154). The bundled FFmpeg is built without network support, so the playlist can never be demuxed locally, and remote HLS is AVPlayer's job anyway. On the bypass, the engine lists the stream's external WebVTT renditions (the legible `AVMediaSelectionGroup`) as `subtitleTracks`. `selectSubtitleTrack(index:)` and `clearSubtitle()` drive AVPlayer's media selection, and AVPlayer draws the cues. The reroute is decided by the body (`#EXTM3U`), not by the URL, so the engine tells AVFoundation what it found: the asset declares `application/vnd.apple.mpegurl` (`AVURLAssetOverrideMIMETypeKey`). A playlist behind a URL without `.m3u8` that the origin serves as `video/mp4` or `application/octet-stream` plays instead of failing with AVFoundation -11829 / -11828. A host that sets `nativeRemoteHLS` itself gets no declaration; AVFoundation types that URL as it always has. |
There was a problem hiding this comment.
Nit: this paragraph now covers two separate topics: AVPlayer media selection for WebVTT renditions, and declaring the MIME type on the reroute. CLAUDE.md asks for one idea per paragraph and for new facts not to be appended to an existing one. Consider moving the new sentences into a short paragraph of their own right after this one, for example Mis-typed playlists on the reroute (#154), keeping the same three facts: the reroute is decided by #EXTM3U, the asset declares application/vnd.apple.mpegurl, and a host-set nativeRemoteHLS load gets no declaration.
…wn paragraph The superuser404notfound#154 paragraph covered two topics: AVPlayer media selection for WebVTT renditions and the MIME declaration on the reroute. The declaration now has its own paragraph with the same three facts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Automated review
Status: 🟢 Clean. Nothing left to fix, ready for a maintainer.
I checked the new head (feae34a). The earlier nit is fixed: the guide now gives mis-typed playlists their own paragraph, Mis-typed playlists on the reroute (#154), at docs/guide.md:420. Nothing else in this push affects the review. There are no open findings.
Checklist: CHANGELOG yes, docs yes, tests yes, traits both ways n.a.
Needs a device run: whether tvOS and iOS honour the override the same way against a real IPTV origin, since all the measurements are from macOS.
Thanks for the quick follow-up.
Automated review by Quint (Claude) of feae34a. It reads the code, it does not build or run it; a maintainer reviews and merges.
|
Thanks. feae34a moves the MIME declaration into its own paragraph, Mis-typed playlists on the reroute (#154), right after the media selection paragraph, with the same three facts. On the device run: the before/after numbers are from macOS only. We have not run this on tvOS or iOS hardware yet, and we will not test against a real provider URL here. We are arranging a run of the same synthetic fixture on an Apple TV and an iPhone: a playlist behind an On variant playlists under |
50bae75
into
superuser404notfound:main
|
Merged in 50bae75, thanks! The before/after table made this an easy one to follow, and keeping the declaration to the cases where the engine has read the body is exactly the right scope. Two small things changed in the merge: the CHANGELOG entry moved to It ships with the next engine release. I'm looking forward to the Apple TV / iPhone run, including the master whose variant playlists sit under |
CLAUDE.md, the PR template and Quint's review checklist now say it outright: each changed behaviour, option, format or CLI flag goes to the docs page that owns the topic, in plain short sentences, and the CHANGELOG entry does not count. Quint checks placement against the current docs, because a branch that predates a restructure can write into a file that no longer holds the topic (PR #1040). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SeT6NgMt1vv32kPBhUmsUz
…laration as fork-only until upstream superuser404notfound#1040 Co-Authored-By: Paperclip <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The #154 reroute moves a VOD load onto the AVPlayer bypass because the engine read
#EXTM3Uin the body, but AVFoundation types a URL by its path extension andContent-Type, never by its body. A playlist at/movie.mp4served asvideo/mp4orapplication/octet-stream(a common shape for IPTV VOD links) therefore failed on the bypass within a third of a second with AVFoundation -11829 / -11828, after the engine had already found the route that plays it. The rerouted asset now declaresapplication/vnd.apple.mpegurlwithAVURLAssetOverrideMIMETypeKey.What changed
LoadOptionsgets an engine-internalhlsPlaylistProvenByBody(not settable from the public initializer, likeisLiveRejoin). The Support remote HLS external WebVTT subtitles in loopback mode (non-nativeRemoteHLS) #154 reroute and the AE#246 second-open reroute set it next tonativeRemoteHLS = true. It ridesloadedOptions, soreloadAtCurrentPositionand the other rebuilds of a rerouted session, which go straight onto the bypass without a probe, keep it. Added toSessionOptionCorrection.knownFields.NativeAVPlayerHost.SessionLoadContract.declaresHLSPlaylistMIMEType, set byloadRemoteHLSfrom that flag. Session-wide likehttpHeaders, so in-place swaps keep it.assetCreationOptions(httpHeaders:declaresHLSPlaylist:)adds the override key; the load log line gainsmime=hls(body)when it is set.nativeRemoteHLSload and the loopback path declare nothing; AVFoundation types those URLs as before.MisTypedPlaylistRerouteTests;CHANGELOG.md(Fixed) anddocs/guide.md(the Support remote HLS external WebVTT subtitles in loopback mode (non-nativeRemoteHLS) #154 paragraph).Test plan
testsrc2+sine, H.264 Main / AAC, 6 x 2 s MPEG-TS segments, VOD playlist, behind a local origin that serves the playlist at/movie/<case>.mp4, directly or through a 302, with a chosenContent-Type. Plus the suite's own 32 s H.264 / AAC TS fixture.aetherctl play --seconds 6per case, with the override disabled and then enabled, same build otherwise:/movie/x.mp4,video/mp4/movie/x.mp4,application/octet-stream/hls/play(no extension),video/mp4/hls/play,application/octet-stream/hls/stream.mp4,video/mp4/movie/x.mp4,application/vnd.apple.mpegurl/hls/index.m3u8, HLS typeMisTypedPlaylistRerouteTests(7 tests): the asset option seam; a playlist at/vod/movie.mp4typedvideo/mp4andapplication/octet-streamreachesreadyToPlaythroughengine.load;reloadAtCurrentPositionmounts a new item that still declares the type and plays; a host-setnativeRemoteHLS.m3u8load and a real MP4 at the same URL shape declare nothing. With the override disabled the two playback tests and the rebuild test fail (failure != nil,isReady == false), the others pass.swift build --build-tests, thenMisTypedPlaylistRerouteTests,Issue119RemoteHLSHeaderTests,Issue460ReloadWithOptionsTests(field inventory),Issue246SecondOpenRerouteTests,Issue440LiveJoinRollTests,Issue316BypassExternalSubtitleTests,PublicAPIDocumentationTests,DocumentedConstantsTests: XCTest 34/34, swift-testing 100 passed.Scripts/check-doc-links.pyandScripts/check-test-hygiene.pyclean.ItemSwapStillTests500 ms bound,SourceFailureDiagnosticsTestslive connection error) pass when rerun alone; three (Issue220SoftwareDecoderDrainTests,APACEncodePipelineTests,LiveAudioProgressTests.test_videoDelivery_sourceReadHeld_drainsReadyVideo) fail the same way on 7.58.0 without this change on this Mac, so I read them as local environment, not this PR.Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))LoadOptionsfield is internal)🤖 Generated with Claude Code