Skip to content

fix(native): apply externalMetadata on iOS too - #15

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
Delarkz:fix-native-external-metadata-ios
May 24, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
Delarkz:fix-native-external-metadata-ios

Conversation

@Delarkz

@Delarkz Delarkz commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add import AVKit so the AVKit extension that declares AVPlayerItem.externalMetadata is in scope.
  • Widen the platform gate around both externalMetadata assignments from #if os(tvOS) to #if !os(macOS).

Why

AVPlayerItem.externalMetadata is declared by an AVKit extension on AVPlayerItem, not by AVFoundation (the doc URL lives under AVFoundation because that's the extended type, which is misleading). The file previously imported only AVFoundation, so the property was invisible on every platform. The original #if os(tvOS) gate hid the resulting compile error by skipping the assignment everywhere except tvOS — where some transitive import was apparently bringing AVKit in by accident.

After adding import AVKit, the property resolves on every platform that actually declares it. Apple ships it on iOS / iPadOS / Mac Catalyst / tvOS / visionOS — but not on macOS. So the correct gate is #if !os(macOS), not #if os(tvOS).

macOS hosts still skip the assignment; they have to write MPNowPlayingInfoCenter directly because there's no AVKit auto-publish path on macOS that reads externalMetadata.

Effect

  • iOS / iPadOS / tvOS: setExternalMetadata(_:) now actually feeds title / subtitle / artwork to AVKit, which auto-publishes to the system Now Playing surface (Control Center, Lock Screen, AirPlay receivers).
  • macOS: unchanged — assignment is still skipped; embedding apps must write MPNowPlayingInfoCenter directly.

`AVPlayerItem.externalMetadata` is documented as part of AVFoundation,
but in practice `import AVFoundation` alone doesn't resolve the
property — the Swift overlay that surfaces it is reached via
`import AVKit`. The file only imported AVFoundation, so the property
was invisible at compile time. The original `#if os(tvOS)` gate hid
the resulting error by skipping the assignment everywhere except
tvOS, where some transitive AVKit import was apparently in play.

Add `import AVKit` so the property resolves directly, and widen the
gate from `#if os(tvOS)` to `#if !os(macOS)` to match Apple's actual
availability — externalMetadata ships on iOS / iPadOS / Catalyst /
tvOS / visionOS, but not on macOS. macOS hosts still skip the
assignment; they have to write `MPNowPlayingInfoCenter` directly.

Updates the README's setExternalMetadata example comment to reflect
the wider platform support.
@superuser404notfound
superuser404notfound merged commit 0721f76 into superuser404notfound:main May 24, 2026
@superuser404notfound

Copy link
Copy Markdown
Owner

Thanks, this one's a great catch. Nailing the missing AVKit import as the root cause (instead of just rewriting the gate) is exactly the right read; the old #if os(tvOS) was masking the real issue. Merged and Sodalite's pin is already on the new SHA.

@Delarkz
Delarkz deleted the fix-native-external-metadata-ios branch May 24, 2026 13:44
superuser404notfound pushed a commit that referenced this pull request Jun 5, 2026
…eep system Now-Playing alive

AVKit binds its MediaRemote system Now-Playing registration to the
AVPlayer instance once, at first presentation, and never re-registers
against a swapped player (it fails with "Code=14 requires a client
callback to have been registered"). Every native reload built a fresh
NativeAVPlayerHost plus a fresh AVPlayer, so episode autoplay and
audio-track switches blanked the iPhone Control Center widget
(Sodalite issue #15).

Preserve the host and its AVPlayer across native->native reloads:
stopInternal gains keepNativeHost (it still unloads the item so the
AVPlayer stops fetching before the loopback server is torn down, but
keeps the host and the published currentAVPlayer), loadNative reuses an
existing host instead of constructing a new one and only re-publishes
currentAVPlayer when the instance actually changes, public load()
preserves the host when the prior backend was native, the software
dispatch branch releases a preserved-but-unused host (the SW path
relies on the nil publish), and reloadWithAudioOverride opts in.
currentAVPlayer now only goes nil on a real native->software transition
or a full stop.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 6, 2026
Patch release rolling up the persistent AVIO reader (#25), the
continuous-audio-off downmix fix (#24), and native AVPlayer reuse for
system Now-Playing (#15). No public API change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 6, 2026
…ay doesn't start audio before the display switch settles

The native AVPlayer host is reused across native->native reloads to keep
AVKit's system Now-Playing registration alive (issue #15), so the AVPlayer
instance carries its previous `rate=1.0` into the next load. unloadCurrentItem
swapped the item via replaceCurrentItem without ever pausing, so the new item
auto-resumed the moment it buffered, before the engine reached its
`waitForSwitch` + explicit `play()` gate in load() step 3.

On episode autoplay this beat the Match-Frame-Rate panel handshake: AVPlayer
started rendering audio while the HDMI output was still blanked mid
refresh-rate switch, so the user heard audio for a beat before video appeared.
Device logs confirmed it: on a cold start (fresh player, rate 0) playback
began via the post-handshake play() and came up in sync, while on autoplay
(reused player) timeControlStatus=playing fired before waitForSwitch returned.

Pause the player in unloadCurrentItem before the swap so the new item stays
parked until the explicit post-handshake play(). No-op on a cold load (rate is
already 0) and orthogonal to the issue #15 instance reuse (same instance, just
stopped across the seam).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 18, 2026
A paused native session left running into a multi-hour tvOS suspension
kept its mediaserverd decode session, the in-process loopback HLS server
sockets, and the upstream AVIO connection all allocated. On resume that
wedged the shared mediaserverd system-wide: every app (including
unrelated ones) could only paint the first frame until the Apple TV was
rebooted. Reproduced on tvOS 26.5 by pausing a video, sleeping the
device for hours, and waking it.

Replace the didEnterBackground pause() with teardownVideoForBackground(),
which calls stopInternal(keepNativeHost: true, keepCustomReader: true).
That unloads the AVPlayer item (replaceCurrentItem(nil)) and invalidates
the software VTDecompressionSession synchronously, releasing the
mediaserverd decode session before suspension. The native host shell and
currentAVPlayer are kept so AVKit's Now-Playing registration survives
(issue #15); clock/loadedURL/loadedOptions are preserved so the host's
foreground reloadAtCurrentPosition() resumes at the paused position. A
UIApplication background-task assertion spans the teardown so the
synchronous decode-session release and the loopback server's detached
socket close complete before tvOS suspends the process.

The foreground path already does a full pipeline rebuild on every
full-background return, so resume behaviour is unchanged; this only moves
the old session's release earlier instead of freezing it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 28, 2026
PiP shows only the AVPlayer item, not the host's on-frame overlay, so PiP subtitles need the native mov_text rendition (#55). Two changes: (1) make the native-subtitle readers LAZY — declare the mov_text moov at load when prepareNativeSubtitles, but only start the side-demuxer readers on the first setNativeSubtitleSelected and cancel on deselect, so a session that never uses PiP pays no standing reader cost. (2) Add setNativeSubtitleForPiP(_:) which maps the active subtitle's source stream to the native ordinal and selects/deselects it for AVKit's PiP window; no-op for bitmap/CC/sidecar tracks (no text equivalent). Host enables prepareNativeSubtitles + calls this on PiP start/stop.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…prep)

Muxing a tx3g/mov_text track into the A/V fMP4 segments is non-conformant for HLS (RFC 8216 §3.1) and fails the AVPlayer open (-11829/-12848). Stop feeding the muxer subtitles and drop the per-segment sample drain. Subtitles will ship as a separate WebVTT rendition. Cue stores, readers, and the selection API are kept for the WebVTT path.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
VideoSegmentProvider holds the cue-store references (threaded at init in start()) and serves nativeSubtitleRenditions + nativeSubtitleVTT + program duration for the WebVTT path. Cue stores are created before start() so the provider has them at init; shift applied + lazy readers armed after start(). Producer no longer carries subtitles (E1).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…tled sources (#15)

buildMasterPlaylistText emits one EXT-X-MEDIA:TYPE=SUBTITLES per text track (DEFAULT/AUTOSELECT=NO) + SUBTITLES= on the variant. start() forces the master for routing-safe subtitled sources (SDR any panel, HDR/DV on a capable panel) so a SUBTITLES rendition can be attached; HDR-on-SDR-panel and DV5-on-non-DV-panel stay media-direct (no PiP subs). Subtitle tags are orthogonal to video VIDEO-RANGE/CODECS, so routing is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…ylist (#15)

The native subtitle path is embedded-only and its reader parks ~90s ahead
of the playhead (embeddedSubtitleReadAheadSeconds), filling the cue store
incrementally; the store never holds the whole program. A single VOD .vtt
fetched once (the E5 shape) is therefore truncated for embedded subs.

Replace it with a windowed rendition that mirrors the video media playlist
one-for-one: one WebVTT segment per video segment (same count, per-segment
EXTINF, MEDIA-SEQUENCE, PLAYLIST-TYPE/ENDLIST), built from the same
notePlaylistBuild() snapshot. Each subs_{ord}_{seg}.vtt serves the cues
whose window overlaps that segment, read straight off the segment plan
(segments[i].startSeconds, correct for VOD and the live sliding window).

WebVTTBuilder gains a segment(cues:segmentStart:relativeToStart:) variant:
WEBVTT header + X-TIMESTAMP-MAP=MPEGTS:0,LOCAL:00:00:00.000 identity map +
absolute media-timeline cue times. The absolute-vs-segment-relative choice
is the one device-verify item; flipping relativeToStart at the provider
call site is a one-line change.

Protocol: nativeSubtitleVTT(ordinal:) -> nativeSubtitleVTT(ordinal:segmentIndex:),
drop nativeSubtitleProgramDuration; parseSubsOrdinal -> parseSubsPath
extracting ordinal + optional segment index. tvOS/non-subtitled paths
unchanged (renditions empty unless native subs are enabled and threaded).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
… CLI path (#15)

The aetherctl `serve --native-subs` path requests the native track before
start() but could only attach the cue stores AFTER start() (track count is
known only post-probe). By then VideoSegmentProvider was already built with
an empty store array, so the master never advertised the WebVTT SUBTITLES
rendition and the AVPlayer-open check (E8) had nothing to validate.

Auto-attach one store per non-bitmap text track inside start(), after the
demuxer probe and before the provider is built, guarded on
`enableNativeSubtitleTrackForSession && nativeSubtitleCueStoresForSession.isEmpty`.
The host full-session path (AetherEngine+Loading) sets the stores before
start(), so the guard is a no-op there and the tvOS/iOS host path stays
byte-identical. Exposure of the legible option only needs the rendition
declared; cue feeding via the lazy readers remains the host's job.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…ubtitle rendition (#15)

Standalone Foundation + AVFoundation harness (not an AetherEngine import, not
a swift-test target) that points an AVPlayerItem at the loopback /master.m3u8,
waits for .readyToPlay (dumping AVPlayerItem.errorLog() on .failed), and
asserts loadMediaSelectionGroup(.legible) exposes >= 1 option. This is the
open-time guard #55 lacked.

README documents the exact commands (aetherctl serve --native-subs + the
harness invocation), an ffmpeg recipe for a text-subtitle test file (Fixtures/
is gitignored), and the captured run: against /master.m3u8 the harness reports
readyToPlay + 1 legible option ("Subtitle 1", mediaType=sbtl) and PASSes;
the /media.m3u8 negative control reports 0 options and exits 1.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…eIsHDR (#15)

The #15 force-master gate used sourceIsHDR, which is inflated by effectiveDvMode (a device DV capability) even for SDR content. On DV-capable devices an SDR source therefore stayed media-direct, so the WebVTT SUBTITLES rendition never appeared and PiP showed no subtitles (device log: serving media.m3u8, useMaster=false, videoRange=sdr). Gate on the actual videoRange == .sdr (a SDR variant is routable on any panel) instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
AVPlayer prefetches subtitle segments at PiP start before the lazy reader has read them (store empty -> empty .vtt -> no PiP subtitles). Block the .vtt response until the reader has read past the segment window (readMaxCueEnd >= end), bounded at 4s so a far-ahead prefetch beyond the reader's parked window returns quickly. Server workQueue is concurrent, so video segment serving is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…enditions render (#15)

Two real defects kept the WebVTT rendition from rendering: (1) the 4s fill-wait block serialized the loopback connection (HLSLocalServer serves a connection's requests serially; AVPlayer uses 1-3 connections), stalling the legible-track pipeline; (2) the 90s reader fell behind AVPlayer's ~240s subtitle prefetch, so far segments were fetched empty and cached empty for the VOD rendition. Remove the block (always return immediately) and give the native readers a 300s read-ahead (vs the inline reader's 90s) so the window is filled before AVPlayer fetches. Authoring/timing/format were already correct (X-TIMESTAMP-MAP=MPEGTS:0,LOCAL:0 + absolute cues is the right fMP4@PTS0 form).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jun 29, 2026
…ng config (#15)

DEFAULT=YES + eager reader start (added while chasing the disable-after-2s)
stopped the native track rendering at all. Revert to the exact config that did
render (re-assert + lazy readers + DEFAULT=NO); the iOS host now drives native-only
(overlay suppressed) on top of it. DEFAULT threading kept but inactive.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01XZTEfmztPE8hAdjHdBr9BH
superuser404notfound pushed a commit that referenced this pull request Jul 2, 2026
…ils (#93 residual)

Device log: the stall-triggered nudge fired on schedule and reached
AVPlayer (rate re-asserted) yet ZERO GETs followed; the -15628 loader
poison ignores seeks. Stage 2 of the stall watchdog now reloads the item
at AVPlayer's position after a second silent grace window, same URL +
same host (the #15 reuse path keeps AVKit and the AVPlayer instance
alive); retention serves the reload instantly. Rendition selection is
per-item and lost on reload, acceptable against an endless spinner.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015GfG4uTjsQBFddBqUoD3by
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Jul 4, 2026
…uperuser404notfound#93 residual)

The recovery reload went through the default teardown: pause(), then
replaceCurrentItem(nil), then the fresh item. During Picture in Picture
the nil-item gap invalidates AVKit's content source; the PiP window was
dismissed ~16 s after an in-PiP recovery (renderer never re-attached to
the PiP host, audio-only background playback remained) and the pause
bounced transport enough to burn all three spurious-pause re-asserts
within 40 ms, so a trailing pause latched silently.

load() gains inPlaceSwap: observers are torn down and rewired as before,
but transport intent, clocks and the current item stay alive until
replaceCurrentItem swaps in the fresh one. Only the recovery reload opts
in; episode-switch reloads keep the pause-before-swap path that guards
the superuser404notfound#15 waitForSwitch audio-leads-video case.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015GfG4uTjsQBFddBqUoD3by
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Jul 5, 2026
Native subtitles have shipped as a separate WebVTT rendition (HLSLocalServer) since
superuser404notfound#15 / Sodalite#32; in-band timed text is non-conformant for HLS and fails the AVPlayer
open. The producer already hard-wired an empty subtitle array into every muxer
(allocateMuxer: "Never re-feed the muxer subtitles"), so the entire mov_text path was
dead at runtime: MP4SegmentMuxer never created a subtitle stream and writeSubtitleSample
had zero callers.

Remove the dead subgraph:
- MP4SegmentMuxer: SubtitleConfig, the subtitles: parameters + header stream synthesis,
  subtitleOutputStreamIndices, muxerSubtitleTimeBase, subtitleTicks, iso639_2 /
  bcp47ToISO639_2, writeSubtitleSample, and clearSubtitleTkhdEnabled.
- HLSSegmentProducer: movTextSamples plus the write-only enableNativeSubtitleTrack /
  subtitleCueStores / nativeSubtitleLanguages fields (set on every producer, read
  nowhere once the muxer stopped consuming them) and their assignment sites.
- MovTextSampleBuilder: sample / emptySample (the sanitize helper stays; WebVTTBuilder
  uses it).
- Tests: delete the mov_text muxer / injection-window suites; fold the ASS-stripping
  coverage into MovTextSampleBuilder sanitize tests.

Also drop the stale superuser404notfound#55 "CRITICAL INVARIANT" on embeddedSubtitleReadAheadSeconds: it
guarded the (now removed) tx3g track against the forward-buffer window. The overlay
reader is paced to the playhead and the native rendition is a separate WebVTT stream,
so the forward-buffer window does not gap subtitles. The constant and its superuser404notfound#31 jetsam
rationale stay.

No behavior change: the muxer already emitted no subtitle streams. Full suite green.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015GfG4uTjsQBFddBqUoD3by
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Jul 18, 2026
…ions (superuser404notfound#130)

AVPlayer filters a VIDEO-RANGE=PQ/HLG EXT-X-STREAM-INF that carries no
FRAME-RATE attribute out of the master at parse time and fails the item
with NSURLErrorDomain -1002 before ever fetching media.m3u8 (byte-exact
local repro against the served 213-byte master; SDR variants are
accepted without FRAME-RATE). Live MPEG-TS probes can leave
avg_frame_rate unset, so live HDR10 channels were served a master
AVPlayer provably rejects, with no recovery path: the superuser404notfound#98 fallback only
covered -11868/-11848 and the superuser404notfound#35 gate is VOD-only.

Three layers, all engine-side:

- The master FRAME-RATE now uses the same avg -> r_frame_rate fallback
  chain as the host probe (detectFrameRate), so live TS sessions carry
  a real frame rate in the manifest.
- resolveUseMasterPlaylist requires a known frame rate for non-SDR
  masters; a frame-rate-less HDR source routes media-direct instead of
  serving an unloadable master. SDR masters (subs-forced, superuser404notfound#15) are
  unaffected: VIDEO-RANGE=SDR is accepted without FRAME-RATE.
- Startup -1002 is classified as a master rejection
  (MasterFallbackDecision.isMasterRejectionCode) and reactively falls
  back to the media playlist, live sessions included; the live fallback
  rejoins at the edge via LiveReloadPolicy instead of replaying a stale
  start position.

Reported by digilearn-dev (superuser404notfound#130).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018PEEQm5QvBSZ97YZZo4BLv
superuser404notfound pushed a commit that referenced this pull request Jul 27, 2026
…s DV support (#227)

`servedSourceIsHDR` was `videoRange != .sdr || effectiveDvMode`, and
`effectiveDvMode` is a DEVICE capability. On any DV-capable iPhone or iPad it
therefore read true for SDR content (device log 2026-07-27:
`sourceIsHDR=true videoRange=sdr dvVariant=none`), so 5.23.8 kept downgrading
those sources to the media playlist and its subtitle fix was a no-op on exactly
the hardware it was written for. `resolveUseMasterPlaylist` carries the same
warning after the same mistake in #15.

Also settles the HDR-master experiment: it does not work. iPhone 17 Pro to an
Apple TV 4K in HDR mode, DV P8.1, the receiver takes the manifest and even
fetches the subtitle rendition, then AVPlayer never hands the stream over. The
picture stays at the start position and AVKit shows its "not playable on this
display" sign, with no -11868/-11848 and no failed item, so the readiness gate
cannot see it either (the rate flickers to playing for one tick and
hasEverPlayed latches). DrHurt's "TV MUST be in HDR or DV mode" is a necessary
condition, not a sufficient one. An SDR master over the same route plays with
subtitles, verified in the same session.

The HDR attempt is gone; what it taught is in the decision's doc comment. The
readiness gate stays armed on a master handed to a receiver, now for the
SDR-master case (a receiver without 4K HEVC would still reject it).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QYhPvBB1sLCYoZNasEXFeB
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Jul 29, 2026
The audio AVPlayer path already owns an auto-publishing MPNowPlayingSession
(AudioAVPlayerHost) because the shared MPRemoteCommandCenter /
MPNowPlayingInfoCenter aren't reliably bound to a bare AVPlayer: a
background pause drops the app as active Now-Playing and the shared center
stops receiving commands. The native VIDEO path had the same exposure with
no equivalent - custom-UI hosts (no AVPlayerViewController) got the
half-working bare-AVPlayer registration.

NativeAVPlayerHost now owns the same sanctioned session pattern:

- MPNowPlayingSession bound to the host's AVPlayer, auto-publish ON, so
  elapsed/rate/duration come from player truth and nobody writes the
  shared info center.
- The session persists with the host across native->native reloads
  (issue superuser404notfound#15), so MediaRemote registration survives the reload seam that
  previously blanked the system card.
- Per-item identity metadata staged via setNowPlayingInfo and replayed
  onto every fresh AVPlayerItem, so readiness-gate master reloads, media
  fallbacks, and in-place swaps keep the card.

Engine surface mirrors the audio contract exactly:
videoNowPlayingSession (hosts register transport commands on its
remoteCommandCenter) and setVideoNowPlayingInfo (caller-managed, empty
clears, safe before load(), replayed at host creation).

Shipped in a production tvOS consumer with a custom player UI; commands
and card verified against pause/resume, seek, and gate-reload seams.

Co-Authored-By: Claude Fable 5 <[email protected]>
superuser404notfound pushed a commit that referenced this pull request Aug 31, 2026
…f the cache

Retested on a device on 6.57.0 (tschuegy, AE#454 round 2): three of four
seams read `0.000s` and retired the correcting seek exactly as designed, and
the session's FIRST swap seeked an item that was already precisely where the
manifest had put it, then reported the place it held while the picture ran
6.76 s ahead of it. Once per session, invisible to the session's own numbers.

The item was blameless and so was the placement: its first requests were the
consumer's own segments and it came up at the served TIME-OFFSET to the
millisecond. What moved it was the check, and underneath the check, the axis.

That axis was a DIFFERENCE between two independently sampled quantities, the
segment cache's resident floor and the item's own reported seekable start,
latched for the item's whole life on the first tick that produced any number
at all. Fed the range of the item that just left, whose axis IS the session's
and whose seekable start is therefore the playlist floor itself, the
difference collapses to exactly 0, which is indistinguishable from "this item
has no offset" and is why the first swap of a session is the one that shows
it. The log line that would have named the axis is guarded on `> 0.01`, so a
collapsed measurement and an absent one look identical in a field capture.

The playlist knew the answer the whole time. It computes the placement offset
from the segments it lists, so the same build also states where the item's
timeline begins: both numbers are recorded when they are served. The readiness
check now compares against the value the playlist actually stated, which is a
statement about content and needs no axis at all, and the axis itself is the
stated one. A statement overrules a measurement even when a tick got there
first, because the serve and the engine's 100 ms tick are not ordered and a
latch is for the item's whole life.

Measured on the harness, both manifest routes: the stated axis is the same
45.00 s the measurement produced where the measurement was right, and it is
fixed before readiness instead of depending on where a tick falls. The check
now names its own provenance, so a field log says which number decided.

Second defect, found while instrumenting the first: a mirrored seekable range
belongs to the item it was read from. `NativeAVPlayerHost` reset `seekableEnd`
on attach and left `seekableStart` carrying the retired item's window, and a
KVO notification already in flight can land after the swap. Observed in a
harness log as `range=30.0..0.0` under the fresh item's generation. Both ends
now reset together and a reading is dropped unless it belongs to the item
under the host, the same `sid == sessionID` guard the end-of-media path has
carried since #15.

Not reproduced on the harness: five freeze legs latched the axis correctly,
so the window the device hits is wider than loopback's. The arithmetic is
reproduced instead, in the tests, with the reporter's own numbers.

2409 tests, 328 suites, plus 606 XCTest. Freeze legs green on the media-direct
and master-playlist routes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4QpZDsHPJfbz5gkxxPXF7
danielebogo pushed a commit to IPTVX/AetherEngine that referenced this pull request Sep 2, 2026
…ruser404notfound#458)

EXT-X-MEDIA:TYPE=AUDIO lives only in a master, and it is the only place
AVFoundation reads an audio language from on an HLS asset. 6.60.0 wrote the
rendition but did not route to it, so the label landed only where HDR or AE#187
had already forced the master. SDR H.264 on tvOS, and SDR HEVC off it, stayed
media-direct and kept showing "Not Specified" no matter what the segment's mdhd
said (htrung14, tvOS transport bar, Apple TV 4K 3rd gen).

`hasAudioRendition` is the same shape of reason as `hasNativeSubs` (superuser404notfound#15) and
AE#187: it forces the master only where routing is safe, so an unready HDR panel
still stays media-direct. A language is not worth a -11848. It is gated on the
audio having actually reached the variant, so a cascade that fell through to
video-only cannot force a master for a group its segments do not carry.

Measured against a `cmn`-tagged SDR H.264 fixture with `serve --no-dv` (the arm
where effectiveDvMode does not inflate sourceIsHDR): main serves media.m3u8 with
useMaster=false, this branch serves master.m3u8 carrying
LANGUAGE="zho". The serving log line now names the language it advertises.

Live is not excluded: the master is fetched from the engine's own loopback
server, so the extra request costs no origin round trip, and tvOS HEVC channels
have served a master since AE#187. AirPlay is unaffected, its playlist decision
keys on servedSourceIsHDR, not on master-ness.

swift test: 2445 tests, 332 suites, 0 failures.

Reported-by: htrung14
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4QpZDsHPJfbz5gkxxPXF7
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Sep 13, 2026
…by guessing (AE#459)

`UIScreen.currentEDRHeadroom` is the only tvOS property that ever reported what
the panel is presenting, and it goes silent in the "4K HDR10+" output format.
Measured on one Apple TV 4K 3rd gen on tvOS 26.6, one app process, one title,
Match Content off throughout, nothing changed but that one setting:

  4K HDR10+   currentEDR=1.00  panelIsHDR=false  media playlist   (x3)
  4K HDR      currentEDR=1.20  panelIsHDR=true   master playlist

The TV reports HDR in both. Selecting HDR10+ output on an HDR10+ panel is an
entirely reasonable thing to do, and it silently costs the master: the SUBTITLES
rendition (superuser404notfound#15), the AUDIO rendition that is the only place AVFoundation reads a
language from on an HLS asset (superuser404notfound#458), and SUPPLEMENTAL-CODECS. The picture
survives, which is why nobody reported it.

There is no API to ask instead. The tvOS 26 inventory is currentEDRHeadroom
(silent here), potentialEDRHeadroom (reads 1.00 even when currentEDRHeadroom
correctly reads 1.20), UITraitCollection.hdrHeadroomUsageLimit (unspecified on
both measured boxes), eligibleForHDRPlayback (true in every output format
including SDR), availableHDRModes (a capability table, deprecated, does not model
HDR10+ at all), referenceDisplayModeStatus and displayGamut (neither is about
dynamic range). AVDisplayManager takes criteria and never reports what is current.

So the engine stops predicting AVFoundation's answer and asks AVFoundation. That
is not a fallback dressed up: the display-compatibility gate is the component
that actually decides, and the proxy it replaces was never a mode readout. What
asking costs was measured before this was built: output locked to 4K SDR with
Match Content off, master forced, a PQ title, item failed with -11868 after 54 ms
with zero errorLog events, media playlist swapped onto the live AVPlayer at the
same position, playing 223 ms after the master was served, no visible black frame.

Three terms, each earning its place: a proven panel short-circuits so a box on
plain "4K HDR" pays nothing, eligibility is required so an SDR-only display is
never offered a master, and a refusal is latched for the process so a genuinely
SDR panel pays the 223 ms once rather than per title. Only the two display
rejection codes may set that latch; -1002 reaches the same fallback and is a
statement about the playlist (superuser404notfound#130), not about the display.

Two deliberate limits. Live never attempts: its fallback is a rejoin at the edge
rather than a restored position, and that cost is unmeasured. And the published
videoFormat is NOT moved by an attempt, because claiming HDR because a master was
served would assert exactly what this issue was opened about, one frame earlier.

9 tests, full suite green on both runners (XCTest 631 with 1 skipped,
swift-testing 2917 in 394 suites, EXIT=0). The repo's own LoadOptions
documentation guard caught the missing api.md row before the commit did.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01VDKAJrLjLXVsCvJVNdJEPw
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Sep 19, 2026
A tvOS backgrounding tears the video pipeline down and keeps the
NativeAVPlayerHost alive on purpose: AVKit registers its MediaRemote client
once per AVPlayer instance and never registers again against a swapped one
(issue superuser404notfound#15). The reload on the way back then threw that host away. It decided
whether to preserve it by reading playbackBackend, which the background
teardown had already reset to .none, so it answered "nothing native here" and
built a fresh AVPlayer.

The viewer came back from the screensaver to a video that played and a dead
Control Center card, with no lock-screen transport and no remote volume, until
they left the player entirely and a new AVPlayerViewController registered from
scratch.

shouldPreserveNativeHostAcrossLoad asks whether a host is still there rather
than which backend is running. Keeping one a load has no use for is already the
contract: the software and audio-only dispatch branches each release a
preserved-but-unused host before they build. The in-place item handover keeps
reading the running backend, because a background teardown has already unloaded
the item and there is nothing left to hand over.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Oct 1, 2026
… would (Sodalite#173)

The first round ended a cancelled load with a host stop(), which dropped
the native host and AVPlayer (superuser404notfound#15) and an AE#158 handover item that the
next load's own teardown would have kept, so every zap that cancelled a
load lost AVPlayer reuse. The cancelled generation is now ended with the
supersede teardown (native host and handover item kept, panel mode kept,
no audio-session release) plus the published reset to .idle.

A load following an AE#629 rebuild no longer cancels the rebuild's Task,
which the retained-reader branch never observed; it ends the rebuild's
generation instead, and the rebuild unwinds at its own checkpoints. A
load cancelled before it began withdraws a reroute's superuser404notfound#361 continuation,
and AVIOReader no longer logs streaming mode for a closed size ladder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TheFireKahuna added a commit to TheFireKahuna/AetherEngine that referenced this pull request Oct 26, 2026
…oves its video into the overlay

The load routes every stream AVPlayer cannot decode into the software overlay
over an AVPlayer placeholder (e651ce4), but an in-place rebuild still had a
road to SoftwarePlaybackHost: the host's software preference arriving on a
reload (superuser404notfound#461) and the AE#561 escalation of a session AVPlayer refused both
rebuilt on loadSoftware.

Both now rebuild through loadNative with overlayDecodesVideoWanted set, as
the load does: AVPlayer gets the placeholder instead of the video it refused,
the engine's decoder draws the picture. The reload no longer reaches
loadSoftware, keeps its AVPlayer host across the rebuild (superuser404notfound#15), and keeps the
audio-switch item unless the video moves into the overlay.

decodePathRefusal asks about the overlay: a session already in it is not
moved, and the IPT-only Dolby Vision refusal stays (the overlay's pixels never
reach the compositor that reshapes them). The demuxed-audio live refusal goes,
as it went from the load: the overlay plays through the native producer, which
merges side audio. SessionReloadRefusal.demuxedAudioLiveIsNativeOnly is removed.

The software-host audio rebuild test goes with the route it tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PWSnRuNk6kb3M4vtVEQPX6
anantprakash17 added a commit to anantprakash17/AetherEngine that referenced this pull request Nov 4, 2026
…ach rate change

A rate write while an item is loading can be the replaceCurrentItem swap, and clearing the latch
there parks the session at readyToPlay and paused (issue superuser404notfound#15). The mirror now acts only once the
current item is ready. Every rate change is logged with its reason, so a device run can show what
tvOS posts for a transport pause, an end of item and a swap.
anantprakash17 added a commit to anantprakash17/AetherEngine that referenced this pull request Nov 4, 2026
…ach rate change

A rate write while an item is loading can be the replaceCurrentItem swap, and clearing the latch
there parks the session at readyToPlay and paused (issue superuser404notfound#15). The mirror now acts only once the
current item is ready. Every rate change is logged with its reason, so a device run can show what
tvOS posts for a transport pause, an end of item and a swap.
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.

2 participants