Skip to content

fix(remote-hls): sourceTime follows the presented frame on nativeRemoteHLS (AE#616) - #617

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/616-remote-hls-source-time
Sep 24, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/616-remote-hls-source-time

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Refs #616.

Problem

On the nativeRemoteHLS bypass clock.sourceTime was host.$renderedTime, i.e. AVPlayer's item time, while its docs promised the source PTS of the displayed frame. An origin whose playlist places a segment at its slot while the segment starts at the keyframe before it (Jellyfin restarts a transcode with -ss <slot> -noaccurate_seek -copyts) makes item time lead the picture. The reporter measured 1.1 to 8.3 s on device, so a host drawing libass from sourceTime drew every line early. The engine sees no segment on this route, so the lead can't be read where it arises.

Fix

The #316 WebVTT renditions are placed by media timestamp, so each line reaches a legible output at cue.start + lead. The engine wrote those cues, so it can match them back:

  • RemoteHLSCueClock (pure): indexes the injected cues by normalized text. Each delivery with a newly appeared line measures itemTime - cue.start. It skips the delivery at a time jump (a line active at the landing is stamped with the landing, not its start) and ignores lines ending. Repeated text resolves to a unique candidate first, then to the one nearest the current lead, inside a plausibility band of -2...30 s.
  • RemoteHLSCueClockObserver: a legible output on the bypass item with suppressesPlayerRendering = false. AVPlayer drawing is unchanged, a host's own suppressing output is unaffected, and the frozen-line trap from the report can't be triggered from here. timeJumpedNotification re-arms the landing skip.
  • sourceTime = max(0, itemTime - remoteHLSItemOffset) in the $renderedTime sink and at seek finalize. currentTime, seek(to:) and the scrubber stay on item time, so a seek round-trips. The offset is zero on every other path and is cleared at all three proxy teardown sites.
  • Docs: PlaybackClock.sourceTime, LoadOptions.nativeRemoteHLS (also no longer claims to be live-only, since AE#154 reroutes VOD there) and docs/api.md.

Limit, stated in the docs: this only measures while an injected rendition is selected and presenting. Without one, sourceTime is item time. Between a seek and the next line it keeps the previous value.

Verification

  • RemoteHLSCueClockTests: 9 cases.
  • Full suite with -strict-concurrency=complete: exit 0, XCTest 629 / 0 failures, swift-testing 3376 passed. tvOS and iOS generic builds pass.
  • End to end with aetherctl play --native-hls --picture-probe on a local fMP4 HLS built from Scripts/timecode-fixture.sh, where a 1.5 s dummy slot puts every playlist slot 1.5 s after its tfdt (a second 2.7 s dummy at seg 30 for the seek arm):
    • Before the rendition is selected: capErr -1.458 (the lead, sourceTime ahead of the picture).
    • After the first presented line (AE#616: item time leads the presented frame by 1.500s): capErr +0.042, one frame at 24 fps, which is the probe's sampling phase.
    • Seek 41 -> 90: capErr stays within one frame. Side observation: AVPlayer kept its 1.500 anchor across that seek even though the segments there sit 4.2 s after their tfdt, so on a local origin that does not restart, the seek did not re-anchor. The per-seek variation in the report therefore needs the real Jellyfin restart pattern, which this fixture does not reproduce. The re-measure path is covered by the unit tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f

… the injected renditions (AE#616)

On the nativeRemoteHLS bypass sourceTime was AVPlayer's item time. An origin
whose playlist places a segment at its slot while the segment starts at the
keyframe before it (a Jellyfin transcode restarted with -noaccurate_seek
-copyts) makes item time lead the picture, 1.1 to 8.3 s in the report.

The #316 WebVTT renditions are placed by media timestamp, so each line reaches
a legible output at cue start plus that lead. A non-suppressing legible output
on the bypass item matches presented lines back to the cues the engine wrote
and publishes sourceTime as item time less the measured lead. currentTime and
seek(to:) stay on item time. Without an injected rendition selected nothing is
measured and sourceTime stays item time, which the docs now say.

Verified with aetherctl --picture-probe on a local fMP4 HLS whose playlist sits
1.5 s after its tfdt: capErr -1.46 s before the first line, one frame after it,
and through a seek.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_014AVNwe8YDG9EQM7uHdjT3f
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