Skip to content

fix(native): a recovery reload leaves a paused viewer paused (#93) - #623

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
brandomoore:fix/recovery-keeps-paused-viewer-paused
Sep 24, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
brandomoore:fix/recovery-keeps-paused-viewer-paused

Conversation

@brandomoore

@brandomoore brandomoore commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What goes wrong

Item death (failedToPlayToEndTime) parks AVPlayer at .paused whatever the viewer wanted, which is why the #93 revive runs the stage-2 reload with the pause guard bypassed. That reload (reloadStalledConsumerItem) and the #98 media fallback (fallBackToMediaPlaylist) then call host.play() on the fresh item unconditionally. So a title the viewer had paused starts itself again whenever its item dies.

On tvOS this happens reliably behind the screensaver: pause an HDR title, the screensaver takes the display two minutes later, the paused item dies with -11868, and the recovery's play() dismisses the screensaver.

Field log

Apple TV 4K (3rd gen), tvOS 27.0, HDR10+ HEVC Matroska over Jellyfin, host app Plozz. The viewer never touched the remote after pausing:

13:30:02  paused at 6004.6 s
13:32:06  [NativeAVPlayerHost] #1 failedToPlayToEndTime AVFoundationErrorDomain/-11868 'Cannot open'
13:32:09  [AetherEngine] #93 item death (failedToPlayToEndTime) at 6004.67s; reloading item through stage-2 recovery (attempt 1, pause guard bypassed)
13:32:09  [NativeAVPlayerHost] #2 startup .failed is a master rejection (code=-11868); signalling engine for media fallback instead of surfacing
13:32:11  host app returns to the foreground: the screensaver was dismissed

The change

Both call sites now play only when the host's durable intent (transportIntentIsPlaying, #122) says the viewer was playing:

if host.transportIntentIsPlaying { host.play() }

playIntent is written only by play(), pause(), setRate(_:) and a full (non-in-place) unload; no KVO path writes it, so AVPlayer dropping to rate 0 when its item dies leaves a playing viewer's intent intact, and the in-place swap keeps it. A playing viewer is therefore resumed exactly as before, which is what #93 exists for; only a genuinely paused one now stays paused.

The other host.play() sites (startup readiness gate, AirPlay watchdog, the stage-1 nudge, which only runs for a playing consumer) are unchanged.

Tests

In Issue93ItemDeathReviveTests.swift, next to the existing item-death tests, a @MainActor suite drives the real stage-2 reload through forceStalledConsumerReloadForTesting() on an engine holding a mounted NativeAVPlayerHost:

Against main without the change, the paused-viewer test and the fallback test fail and the playing-viewer test passes, so the suite pins the new behaviour and guards the #93 one.

swift test on macOS, rebased on 4d7c60d2 (with #621 merged): 3400 Swift Testing tests in 460 suites and 629 XCTest tests (1 skipped) pass.

Test plan

On device, Apple TV 4K (3rd gen), tvOS 27.0, same HDR10+ HEVC Matroska over Jellyfin, Plozz built against this branch plus #621:

  • paused at 2605.23 s; the screensaver started two minutes later, the item died with -11868, the stage-2 reload and the media fallback ran, and the screensaver stayed on (no foreground return); the position held at 2605.25 s
  • a paused recovery item still loads without play(): it reached its own item.status (here failed, which drove the fallback)
  • waking the TV and pressing play resumed at 2605.25 s and played

Related: #621 (merged) fixed where the same fallback resumes; this branch is rebased on it.

🤖 Generated with Claude Code

…er404notfound#93)

Item death parks AVPlayer at .paused whatever the viewer wanted, so the
fallback then called play() on the fresh item unconditionally.

Field log, Apple TV 4K 3rd gen, tvOS 27.0, HDR10+ HEVC Matroska: paused,
the tvOS screensaver took the display two minutes later, the item died
with -11868, and the recovery started the title and dismissed the
screensaver.

Both now resume only when the host's durable play intent (superuser404notfound#122), which
the in-place swap keeps, says the viewer was playing. A playing viewer is
resumed exactly as before.
@brandomoore
brandomoore force-pushed the fix/recovery-keeps-paused-viewer-paused branch from 4b881fd to 9b8e4ee Compare September 24, 2026 19:57
@superuser404notfound
superuser404notfound merged commit ee6a86b into superuser404notfound:main Sep 24, 2026
7 checks passed
superuser404notfound pushed a commit that referenced this pull request Sep 24, 2026
…med session (#623)

`aetherctl play --host-calls pausereload,playreload,extplayreload` forces the #93/#65 stage-2
item reload at t=10 on a session paused at t=6, on one left playing, and on one paused through
the engine and resumed straight on the AVPlayer the way AVKit's transport does. The run fails
with exit 4 if the clock moves after the paused reload or stands still after a playing one.

Measured on a 90 s testsrc fixture: before #623 the paused session came back at +7.20 s,
state=playing; after it holds at +0.00 s, state=paused. The AVKit-resumed case, whose engine
intent still reads paused, comes back playing because the in-place swap keeps the player's rate,
so #623's intent check needs no second signal.

Refs #626

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged, thank you. The device run behind a real screensaver is exactly the evidence this needed, and the engine-level tests through forceStalledConsumerReloadForTesting() are a better pin than a source read alone.

Follow-up on main (d49516e): aetherctl play --host-calls pausereload,playreload,extplayreload drills the same reload headless on macOS. Before this PR a paused session came back at +7.20 s, playing; now it holds at +0.00 s, paused. The third drill checks a concern about the intent-only check: a session paused through the engine and then resumed straight on the AVPlayer (as AVKit's transport does) still reads paused intent, but the in-place swap keeps the player's rate, so it comes back playing and no second signal is needed. It will ship with the next engine release.

@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.16.1 (4ef5ef95). Thank you again.

neurekadev pushed a commit to neurekadev/silo-aether-engine that referenced this pull request Oct 1, 2026
…ng (superuser404notfound#98)

When a dead item's recovery reload was refused (-11868), fallBackToMediaPlaylist
swapped in the media playlist and called play() unconditionally, so a title
paused behind the tvOS screensaver started itself. The item-death reload now
keeps the viewer's pause (clearing the host's play intent), and the fallback
reads that same intent before it plays.

Ports the fallback half of upstream superuser404notfound#623; the
reload half is covered by this fork's own item-death change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Rhainland pushed a commit to Rhainland/AetherEngine that referenced this pull request Oct 9, 2026
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]>
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