Repository navigation
Description
What happened?
Calling selectSubtitleTrack(index:) mid-playback without pausing on a large/remote (high-latency) source shows the first on-screen cue ~25–35s later, instead of the ~1–2s the API docstring promises.
The side Demuxer (runEmbeddedSubtitleReader) anchors at the playhead captured at call time and reads forward. On a slow source the open (demuxer open + duration*0.5 prewarm seek + seek-to-playhead) costs several seconds, during which unpaused playback advances — so the reader seeks to a now-stale position behind the live playhead and pages forward over already-played content. Those cues arrive behind the playhead and are dropped by the current-cue lookup until the read catches up.
The anchor is correct for the instant it was captured; the gap is that the reader never re-samples the playhead after the slow open. Not a crash — purely a latency at activation.
Steps to reproduce
engine.load(url:)a large remote (high-latency) HEVC source with an embedded text (SubRip) subtitle track; start playback and let it run a few seconds so the playhead is advancing. Do not pause.- Call
selectSubtitleTrack(index:)for the text track. - Measure time from the call to the first in-window cue: ~25–35s.
Isolating contrasts (each freezes one variable and the delay disappears):
- Pause first, then activate, then resume → cues present immediately on resume, same remote source.
- Small/local source, no pause → ~1s (open is fast enough that the playhead barely moves).
AetherEngine version or commit SHA
6bc4e75 3.11.2
Host app
Custom / my own integration
Platform
macOS
OS version
macos 27, iOS 27
Device / chip
m2, a19 pro
Playback path
Native AVPlayer
Source media (for playback bugs)
MKV · HEVC (Main 10) · Dolby Vision Profile 7 · ~3840×2160 · audio: ANY. Streamed from a remote CDN (high origin latency). ffprobe output available on request. Reproduces on any source whose side-demuxer open is slow relative to playback (large / remote / high-latency); not on small/local fixtures.
Error codes / log lines
embedded subtitle reader started: stream=19 startAt=4626.60s seekTo=4624.60s ← this line lands several seconds after the selectSubtitleTrack call (slow open)
subtitle first cue: pktPTS=4624669 → startTime=4624.669s
... first emitted cues sit behind the still-advancing live playhead ...
... reader pages forward; cues only get ahead of the playhead tens of seconds later → first visible cue
Anything else
Root cause (hypothesis). runEmbeddedSubtitleReader derives seekTo once from the startAt captured before demuxer.open + the prewarm seek; on a slow source those steps consume wall-clock during which (unpaused) playback advances, but the reader never re-samples the playhead before seeking. (Per CONTRIBUTING this is engine-side — it traces to the side-demuxer, not anything a host could cleanly work around.)
Suggested direction (you know the engine's invariants far better than I do — this is a hint, not a prescription, and it's untested against your tree): after the open + prewarm, re-sample the live playhead and seek there instead of the startAt captured before the (slow) open, rather than reading forward from the stale anchor. It would re-target the single existing seek (no extra network seek), and should be a no-op when paused, on a fast/local open, and on the seek re-arm path (clock.sourceTime is already the seek target there). Two things I'd watch if you go this way: keep the -2.0 bitmap-SETUP lead-in on the new target, and initialize the read-ahead playheadSnapshot to the re-sampled value too, or the first packet trips the park gate immediately.
Activity
fix(subtitles): re-sample playhead after slow side-demuxer open (#52)
superuser404notfound commentedon Jun 20, 2026
Thanks for the unusually precise report, including the isolating contrasts (pause-first, small/local) that pin it to the slow open rather than the anchor math. Your root-cause read is exactly right.
runEmbeddedSubtitleReadercaptured the playhead (startAt) beforedemuxer.openand theduration*0.5prewarm seek. On a high-latency source those steps cost several seconds of wall-clock, during which unpaused playback advances, so the seek-to-startAt-2lands behind the live playhead and the reader pages forward over already-played content. Those cues arrive behind the playhead and get dropped by the current-cue lookup until the read catches up, which is the tens-of-seconds activation delay.Fixed on
main(1909138) along the direction you suggested: after the open + prewarm, the reader re-samples the live playhead and re-targets the single existing seek to it instead of the stale pre-open anchor. No extra network seek. Amax(startAt, fresh)guards the direction so it never seeks behind the requested anchor, which keeps it a no-op when paused, on a fast/local open, and on the seek re-arm path (wheresourceTimealready equalsstartAt). Both of your watch-outs are handled: the-2.0bitmap SETUP lead-in is kept on the new target, and the read-aheadplayheadSnapshotis seeded from the re-sampled value so the first packet does not trip the park gate.The
embedded subtitle reader startedlog line now prints bothstartAtandeffectiveStartso the re-sample is visible in diagnostics.This will ship in the next tagged release. If you can retest off
mainagainst your remote DV7 source in the meantime, a confirmation that first-cue latency drops back to ~1-2s would be appreciated.chore(release): 3.11.5 — subtitle stale-anchor activation fix (#52)
rrgomes commentedon Jun 21, 2026
On 3.11.6 this fix also resolved two symptoms we (a separate host integration) had been chasing independently — both narrower-looking than the activation-delay this issue was filed for, but the same root cause:
PGS "catch-up burst" on a mid-file start. Starting a title ~25–40 min in flooded the screen with a rapid burst of PGS cues before settling. The
embedded subtitle reader startedlog showed exactly the stale anchor described here — e.g.startAt=0.00s -> effectiveStart=2469.28s— i.e. the reader was seeking to 0 and paging forward over the entire already-played span, and those cues landed at the host as one burst. With the re-sample they start at the playhead and the burst is gone.PGS subtitles that never appeared at all. On a large DV-P7 / FLAC / PGS title, the selected PGS track produced no on-screen cues whatsoever (
startAt=0.00s -> effectiveStart=60.14s). Same mechanism — every cue arrived behind the live playhead and was dropped by the current-cue lookup, so nothing ever displayed. Now they show.So the fix had broader reach than the slow-remote activation delay. Thanks — nice catch by @reckloon and clean fix.
fix(subtitles): re-anchor the overlay subtitle reader after a wedged …
fix(subtitles): reanchor PGS re-arm at the pre-stop source PTS on an …