Repository navigation
feat(native): let a host request the in-place item handover for a foreground replacement - #483
Conversation
…eground replacement The AE#158 handover that keeps a PiP window alive across a native->native load() was gated on pictureInPictureActive alone. A host that mounts the engine's own AVPlayerLayer takes the nil-item gap on every next-episode transition, and on tvOS that gap can leave the layer black while the successor's audio and clock run. prepareForItemReplacement() arms a one-shot request that the next load() consumes; stop() cancels it and a non-native outgoing session ignores it. When the item is kept, NativeAVPlayerHost.prepareForItemHandover() retires the outgoing session's publishers before the engine subscribes for the successor, so the previous episode's EOF, readiness, rate and clock are not replayed. Main-actor hops queued by the outgoing item's KVO drop on the session guard instead of writing into the successor. The nativeRemoteHLS bypass now consumes the handover too; its callsite never read the flag, so even an active PiP window took the nil-item gap across a native->native remote-HLS load.
…e layer (#158) The in-place handover leaves the outgoing item mounted on the player layer through the load gap, which makes `isReadyForDisplay` the one observation that goes on firing there while every other one belongs to an item that is already being replaced. #483 put the session guard on the five item observers and left this one, so a hop queued by the previous episode's layer could still land after the successor subscribed and read as the successor's first frame. Same `sessionID == sid` guard the item observers carry. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4QpZDsHPJfbz5gkxxPXF7
|
Merged as 145d3c8. Thanks for this, and for writing up the reasoning rather than only the patch. Verified here before merging: both The One follow-up pushed on top (bb36f22): One thing to aim your Apple TV round at, from reading rather than measuring. |
Takes upstream main through dd1d5f8: 7.14.0 to 7.28.3 plus the unreleased transport, audio-selection and subtitle-delay changes. Retired fork changes, now covered upstream: - In-place handover (dfe11a0, 745de1c): upstream superuser404notfound#483, already in the merge base. - Media fallback position (a48b2bb): upstream superuser404notfound#621. - Item-death and media-fallback pause handling (fork Silo-Server#10, Silo-Server#11): upstream superuser404notfound#623's play intent. The fork's AVPlayer rate stamps are removed. A Play or Pause pressed in iOS PiP while an item dies is no longer counted. Kept, and fitted onto upstream's code: - Refreshable HTTPRequestAuthorization on upstream's sealed relay and CredentialScope. Static headers follow upstream's anchor scoping. Resolver output stays the host's per-URL decision. - Bounded resource fetches use upstream's held-body limit, and the resolver preflight keeps the 2 MB playlist cap. - Native subtitle 503 while extraction is pending, nativeTimelineOffsetSeconds, ASS for local primary rendering, and sidecar decode off the cooperative pool. - 16-thread software decode cap; TrueHD Atmos to APAC. New: - The premature-end recovery keeps a pause made during its re-seek. - An overlay-drawn injected ASS track keeps its rendition selected behind a suppressing legible output, so AE#616 keeps measuring sourceTime. - The APAC bridge reports an object decoder that produces nothing (AE#641). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Summary
Lets a host that mounts the engine's own
AVPlayerLayerrequest the AE#158 in-place item handover on a foreground episode change, instead of taking the nil-item gap that only PiP is protected from today. Also makes thenativeRemoteHLSbypass honour the handover, which it never did, even under PiP.Refs #158. The host-side mitigations recorded there as failing are the ones we hit too.
What changed
prepareForItemReplacement(): a one-shot public request. The nextload()consumes it,stop()cancels it, and a non-native outgoing session ignores it.shouldHandOverItemInPlacegains ahostRequestedinput; PiP behaviour is unchanged.NativeAVPlayerHost.prepareForItemHandover()retires the outgoing session's publishers before the engine subscribes for the successor, so the previous item's EOF, readiness, rate and clock are not replayed into the new session. The same-content Loopback-HLS: a single backward seek on heavy 4K can wedge the segment producer (video stalls, audio continues -> A/V desync) #93 recovery swap keeps its clock as before.unloadCurrentItemretires the session id up front for that reason.nativeRemoteHLSbypass callsite now readspendingInPlaceItemHandoverlike the loopback callsite does. Before this, a native->native remote-HLS load dropped the item to nil even while a PiP window was active.CHANGELOG.mdentry,docs/api.mdrow, and four new cases inPiPItemHandoverTests(one-shot consume, non-native ignore,stop()cancel, PiP independence).Why the host cannot solve this on its own side: the gap is between
stopInternaldetaching the item and the successor'sreplaceCurrentItem, and the engine owns both ends. We tried keeping the surface and layer stable through the gap and presenting the successor only after first frame; the layer still came back black on Apple TV. That matches the three host-side mitigations recorded as failing in #158.Test plan
nativeRemoteHLS), 1080p SDR. Direct-play MP4 through the loopback path.AVPlayerItemswap and zero nil items on the shared player, same view and layer, successor first frame ready. Silo's regression test asserts exactly that on both routes; before the bypass change it recorded 2 item changes and 1 nil item on the remote-HLS route.swift test: 2634 tests, 360 suites; the one failure isIssue458AudioLanguageMetadataTests"three-letter labels ICU cannot name", which fails identically on unmodifiedmainwith Xcode 27 beta (ICU locale data).PublicAPIDocumentationTests,DocumentedConstantsTests,PiPItemHandoverTestspass.Scripts/check-doc-links.pyclean. tvOS and iOS Simulatorxcodebuildbuilds pass.Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))Built for Silo, a self-hosted media server client. Drafted with AI assistance (Claude Code); reviewed and tested by the author.