Repository navigation
Description
Environment
- AetherEngine 6.18.1 and 6.15.3 (A/B'd on the same device and asset: identical behavior — not a recent regression)
- iPadOS 26.6 (iPad Pro M5) and tvOS 26.5 (Apple TV 4K 3rd gen) — both affected
- Native loopback-HLS VOD path (avc1 1920x1080 direct play)
- Subtitle: PGS (
hdmv_pgs_subtitle) in MKV, declared 0x0 (Could not find codec parameters … unspecified size);native subtitles: prepare=false eager=false textTracks=0 bitmapOCR=1 enable=false→ overlay fed by the packet-store drainer
Summary
On a PGS-subtitled VOD on the native loopback path, overlay cue delivery permanently stops within a handful of user seeks. The subtitle pipeline itself keeps working — #250 subtitle-resolution continues to advance resolvedThrough/decodedThrough spanning every subsequent landing — but applySubtitleEvent never fires again for the rest of the session. Because a delivered PGS cue carries endTime = start + 2^32 ms and is only retired by its successor's trim, the last delivered cue then stays on screen indefinitely while playback continues normally elsewhere in the file.
Observed in three sessions on two devices (one two-device session, two solo). The number of seeks before starvation varied (2, 4, 8), and both directions appear before and at the kill point — so we can't name "first backward seek" as the trigger, only that delivery dies early in a seek sequence and never recovers. A fresh load clears it.
Repro (minimal)
- Direct-play an MKV with a PGS stream (a 1953 feature, avc1 1080p, FLAC 1.0 audio) with subtitles enabled; cues display normally.
- Seek forward a few minutes — cues resume at the landing.
- Keep seeking and playing normally. Within a few seeks,
applySubtitleEventstops permanently: in the cleanest session, 22 consecutive seeks (both directions, minutes of playback in between) produced zero deliveries while resolution kept pace with every landing.
Trace excerpts (6.18.1, solo)
Healthy decode-ahead delivery before the seeks:
03:12:55.330 [applySubtitleEvent #1] cueStart=2116.656s cueEnd=4297083.951s engine.currentTime=2117.400s
03:12:57.120 [applySubtitleEvent #14] cueStart=2144.893s cueEnd=4297112.188s engine.currentTime=2119.100s
First seek — delivery resumes at the landing:
03:13:05.126 seek#1 programmatic began target=3679.05
03:13:06.233 [applySubtitleEvent #15] cueStart=3684.222s engine.currentTime=3679.500s
03:13:07.884 [applySubtitleEvent #20] cueStart=3726.264s engine.currentTime=3681.100s
Second seek and everything after — silence from the drainer while resolution keeps pace:
03:13:31.755 seek#2 programmatic began target=2414.72
… seeks #3–#23 over four minutes, forward and backward, playback in between …
03:17:23.940 seek#23 programmatic landed rendered=2756.55 target=2756.55
03:17:24.204 #250 subtitle-resolution seekGen=22 stream=3 coveredFrom=2741.70 resolvedThrough=2816.48 via=pump decodedThrough=2816.48 reason=reconstruction
(no applySubtitleEvent after #20 at 03:13:07 for the rest of the session)
The user-visible wedge (two-device session, paused): both engines idle at coveredFrom=2060.08 resolvedThrough=2147.77 with the position at 2115.2s — cues resolved and decoded spanning the playhead, none applied. One device blank; the other still showing a cue delivered much earlier at a distant position, pinned by its open-ended end.
On 6.15.3 (same device, same asset) the shape is identical, with starvation beginning after seek#4 — a forward seek preceded by two backward seeks that each still delivered:
03:26:42.741 seek#2 began target=2798.18 → cues 2806/2814 delivered
03:26:45.274 seek#3 began target=1866.91 → cues 1866–1903 delivered
03:27:10.973 seek#4 began target=3280.25 → nothing again (seeks #4–#8 all silent)
Notes
- Presents like the Loopback path: subtitle cues permanently starve after a backward seek into cache-resident content — the packet store pruned behind the playhead can never re-harvest without a producer restart, and track switches drain the same empty store #125 class (cue starvation after a backward seek, fixed at the producer level) one layer up, at the drainer→overlay hand-off — and it interacts with the PGS cues arriving after a reader stall flash through the overlay one by one — each inserts with an open-ended endTime (start + 2^32 ms) and only its successor's trim removes it #100 open-ended-endTime behavior: starvation turns "no new cue" into "a wrong cue on screen indefinitely."
- Full engine logs for all three sessions are available, and we're happy to run instrumented builds.
Activity
superuser404notfound commentedon Aug 10, 2026
Thanks for the three sessions, and for A/B'ing 6.15.3 against 6.18.1 on the same device and asset. Before going after the drainer I checked what the
applySubtitleEventline can actually witness, and it cannot carry the central claim.The diagnostic is capped at 20 lines per load.
Sources/AetherEngine/AetherEngine+Subtitles.swift:subtitleCueDiagnosticCountis zeroed insideload()and nowhere else, so after the 20th primary-channel event carrying cues the line goes quiet for the rest of the session. That shape has been in the tree since 2026-05-13 and is an ancestor of both tags you tested, which is also why the A/B came out identical: the same blind instrument in both builds, rather than "not a recent regression".The decisive detail is in your own 6.18.1 timeline.
#20lands at 03:13:07.884, and seek#2 does not begin until 03:13:31.755. The line went silent 24 seconds of ordinary playback before the seek you attribute the starvation to, in a stretch where the first two seconds of the session alone produced 14 events. Delivery did not die at a seek. The budget ran out mid-playback.Three more observations line up with that:
#20, not an arbitrary number,Two further limits, independent of the cap. The line is emitted before
applyEventMutations, so it sits ahead of the stale-arrival gate, the reconstruction hold, the PGS trim and the sorted insert: it witnesses "an event carrying cues was decoded", never "a cue was published". It also skips clear-only events (event.cues.firstis nil for a zero-object PGS clear, which is exactly the composition that retires a line), never covers the secondary channel, and printscueStart(absolute source PTS) besideengine.currentTime(the AVPlayer axis), so the two numbers are not on the same clock whenever a playlist shift is in play.The check that can kill this explanation in two minutes: in each of the three logs, what is the highest
[applySubtitleEvent #N]? If all three end at exactly #20, the log half of the report is an instrument artifact. If one of them stops at #13, the cap is not the explanation, and that is the far more interesting answer.What this does not dismiss: the visible wedge. Two engines idle with cues resolved and decoded across the playhead, one screen blank and the other holding a line from a distant position, is a real observation, and I have no account of it that the current logs can support. Worth flagging for how you read the resolution line meanwhile:
resolvedThroughis a determination claim, not a promise that a cue exists at the playhead. A window whose packets all fail to decode (a drain decoder rebuilt at the backscan start, entering mid-epoch on a stream declared 0x0, sets with no acquisition point) still advances the cursor, anddecodedThroughadvances with it. That produces your picture precisely: resolution keeping pace while nothing renders.So the next build makes that distinguishable instead of guessable. Each drain tick names its outcome: no packets in the window, packets that produced no event, an event held by the gate, or cues published. The cap moves from per load to per seek generation, so a seek sequence stays observable to its end rather than dying in the first minute, and the line reports
sourceTimerather thancurrentTime. I will post here once it is tagged.Keeping this open until the wedge has been measured with an instrument that can see it.
Merge diag/357: state what each subtitle drain tick delivered (#357)
superuser404notfound commentedon Aug 10, 2026
Instrument is out as 6.19.1 (
58fa00e). Diagnostic only, no behaviour change on any playback path, so it can go straight on top of 6.18.1 or 6.19.0.What it adds.
#357 subtitle-delivery, one line per subtitle drain tick that changed class, plus one on every post-seek reset tick:outcome=is one of:noDecoderemptyundecodableheldduplicatetrimOnlypublishedThe
[applySubtitleEvent]line is budgeted per seek generation now instead of per load, so a seek sequence stays observable to its end, and it printssourceTimenext tocurrentTime.What would be most useful from a retest, same asset and same seek pattern: the
#357lines around the point where the overlay stops changing, and specifically theoutcome=on the reset tick of each seek that lands dark. Two candidates separate cleanly there.undecodablemeans the drain decoder, rebuilt at the backscan start of every reset, cannot compose the sets in that window, which is the shape a stream declared0x0with no acquisition points would produce and which#250cannot show because the cursor advances over those packets anyway.heldorpublishedon the same tick means delivery is doing its job and the problem is downstream of it.If the answer turns out to be
publishedon every landing, that is worth knowing too: it would put the wedge in the overlay rather than in the drain, and the two engines idling with different screens in your two-device session would fit that.diag(subtitles): state what each drain tick delivered, budget the cue…
rrgomes commentedon Aug 10, 2026
Your cap explanation is confirmed. Highest
[applySubtitleEvent #N]in every load we have:#NAll five end at exactly #20. The delivery-starvation claim in the report was the counter budget running out, as you said — retracted, and the A/B conclusion goes with it: "identical on both pins" was the same capped instrument twice.
Retest on 6.19.1 (
58fa00e), same device, same asset and stream, same seek pattern. One ~95 s session, 2026-08-10 18:53:39–18:55:10Z, 15 seek generations, and the visible wedge reproduced. The new line answers your question cleanly: no landing was dark at the delivery layer. Zeroundecodable, zeronoDecoder;heldappears exactly twice (seekGen 8, a +11 s hop inside the just-re-decoded region — the stale hold doing its job); every other post-reset tick that found packets reportspublished.Per landing, the first published cue against the landing point:
We can't tell from outside whether the "no" rows are authored gaps at the landing point or predecessors the backscan didn't recover — seekGen 4 landed in the opening-credits region, where an authored gap is plausible. Where a covering predecessor clearly existed near the landing, it arrived (8, 13, 14, 15).
Two things in the data localize the wedge downstream of delivery, where you said
published-everywhere would put it:outcome=duplicatenever occurs in the session, although seekGen 13 re-decodes seekGen 6's region — the cue at 1970.302 is published in both generations as a fresh admit.The two-device shape from the WT session fits the same picture: each overlay wedges on whatever it last rendered before its own seek landed, so one screen holds a line from a distant position while the other stays blank.
Happy to attach the full session log. The instrument is a big improvement — thank you for turning it around this fast.
rrgomes commentedon Aug 10, 2026
Found it, and it is not seeks. The trigger is the #127 paused-background teardown → foreground-return reload: the rebuilt session never resumes embedded-PGS delivery.
Retest on 6.19.1, same device/asset/stream, with extra host-side instrumentation: our bridge now logs the engine's published cue window (ids + endTimes) on every emission, plus every displayed-set transition.
Timeline (2026-08-10 UTC):
recon=1), delivery healthy — cues 537.4/542.2/561.0 arrive, trims arrive (537.4-540.5,542.2-546.3), display matches authored timingbackground grace window armed (15s) before paused teardown (#127)#151 forward prefetch exited, pump finished — and the published cue window empties (n=0)stream[3] hdmv_pgs_subtitlepresent)#357line, no post-seek reset tick, no#250tick, noapplySubtitleEvent, no cue emissionThe silence is the finding: 6.19.1 prints a
#357line on every post-seek reset tick, and three seeks after the reload produced none — the rebuilt session's drain has no subtitle target. The memprobe immediately before the teardown reportssubActive=true subTracks=1. A fresh load restores delivery, every time.This reframes the report. The seek counts (2/4/8) were incidental — those sessions contained pauses — and the actual trigger is a ≥15 s paused-backgrounded stretch, then resume. "A fresh load clears it" fits, as does the two-device shape: each device wedges at its own pause/resume, one holding whatever it last rendered, the other blank. Our earlier suggestion of an overlay holding its image was wrong, and with endTimes now logged we can retire it.
A second, softer observation from an earlier run today (19:33Z, same build): the cue at 542.167 (authored close: clear at 546.337; next cue 561.019 — ffprobe-verified) displayed from 542.2 until 561.0 — to the next cue's start, not its authored clear. In the 20:06Z run the same cue arrived already trimmed (
542.2-546.3) and cleared on time. Whether a closing trim reaches the published window before display looks timing-dependent. We only have the visual observation plus the authored-timing mismatch for the bad case (endTime logging wasn't aboard yet), so take it as a pointer, not a claim.Happy to attach the full session logs for both runs.
superuser404notfound commentedon Aug 11, 2026
Your trigger is right, and the cause is not in the drain at all. The reload restores a selection it snapshots after the teardown already deleted it.
Thank you for retracting the first claim on your own data and then finding the real one. The silence you measured is a real absence this time, and it has a single cause.
The mechanism. Every reload path snapshots the state it intends to restore immediately before its own
stopInternal: the #170 subtitle carryover, the audio pick, the disc title. That contract holds exactly as long as teardown and reload are the same call, which is true for the AirPlay LAN swap it was built for. The background path is not that.teardownVideoForBackgroundrunsstopInternalwhen the app goes to sleep, andreloadAtCurrentPositionruns on foreground return, in your log 38 seconds later. By thenstopInternalhas already executed:So the reload's
captureSubtitleSessionCarryover()snapshots an empty session,restoreSubtitleSelectioncomputes.nonefrom it, and nothing re-selects the stream. With no drain target,subtitleDrainTickreturns at its first guard. That is why three independent instruments went quiet in the same instant: there is no tick to classify, no resolution to state, no event to apply. The stream being present in the reopened demuxer is consistent with this, since nothing ever asked for it.The same gap swallows the audio pick and the disc title on that path. They are less visible because audio auto-selection usually lands on the same default track.
Why this survived so long, and a check you can run without any new build.
hostExplicitSubtitleActionis the one piece of subtitle statestopInternaldoes not clear, and it is the guard onapplyPreferredSubtitleSelection. So an explicitly picked track dies, while a track that arrived throughLoadOptions.preferredSubtitleLanguagescomes back, because the reload's re-run auto-selection re-arms it. If you repeat your 20:06Z sequence with the track auto-selected by preference instead of picked by hand, delivery should survive the pause and resume. That separates the diagnosis from the fix.Two more predictions in the logs you already have: after the reload,
activeSubtitleTrackIndexis nil, and there is nopreferred-subtitle auto-select stream=line.Fix, on
fix/357-background-teardown-selection(b084ddf9): both teardown paths, the grace expiry and the synchronous assertion backstop, park aBackgroundTeardownSelectionbeforestopInternal, andreloadAtCurrentPositionclaims it once, custom-source branch included. The live read stays authoritative for what actually survives a teardown (the external track registry, its ordinal counter, the host's subtitle authority) and for any selection made after it, which is newer intent; the snapshot fills only the fields the teardown wiped. Any otherload()andstop()drop it, so a parked selection cannot follow a different item. 8 tests over the handoff, the re-armed drain target, the merge rule and expiry; suite 1745 green, tvOS and iOS build clean.One thing I need from your side before this ships, because it decides whether the fix reaches you at all: what does your host call on foreground return? If it is
reloadAtCurrentPosition(), this is covered. If it callsload()itself with the same URL, the engine cannot tell that apart from a deliberate new session, the parked selection is dropped by design, and the host has to re-select after the load. Your log line reads like the former, but I would rather not guess.Worth noting on your device split: tvOS tears down on every backgrounding with no grace window, iOS only after
backgroundTeardownGraceSeconds(default 15 s). So the two-device shape you saw does not need both devices to have paused for the same duration.Your second observation is a separate thread and I am not folding it into this. A cue displayed to the next cue's start instead of its authored clear, with the closing trim present in one run and absent in the other, is a publication-timing question in the gate, not a delivery question. If you can reproduce it with the endTime logging aboard, the
#357line for the tick that carried the clear composition (outcome=trimOnlyis the one to look for) plus the published window right after it would tell me whether the trim never arrived or arrived and was dropped.Merge fix/357-background-teardown-selection: the background teardown …
superuser404notfound commentedon Aug 11, 2026
Shipped as 6.20.2 (
6031169). Drop-in from 6.20.1, no API change, nothing on any live session touched.Both teardown paths park the selection before
stopInternalandreloadAtCurrentPositionclaims it once. Verified on device in both directions: with the old pin the overlay stays dark for the rest of the session after the reload, with the new one delivery resumes normally.Two traps worth knowing for the retest, because both can make a broken build look healthy and a fixed one look untested:
shouldKeepVideoAlivekeeps the pipeline up, so there is no teardown at all and nothing to reproduce. Pause first, then background. On tvOS the Home button is enough.subtitleCuesstill holds the window the drainer had already filled, and the lead is 60 seconds. Subtitles keep appearing, correctly timed, for up to a minute after a reload that is delivering nothing at all. Your three post-reload seeks are what made it visible; without a seek past that window the first minute looks perfectly fine.The question from the previous comment still stands, since it decides whether this reaches you: does your host call
reloadAtCurrentPosition()on foreground return, or its ownload()? In the second case the parked selection is dropped by design and the host has to re-select after its load.Your softer observation, the cue that displayed to the next cue's start instead of its authored clear, is untouched by this and still open. If it survives on 6.20.2 it wants its own issue, ideally with the
#357line for the tick carrying the clear composition (outcome=trimOnly) next to the published window right after it.fix(subtitles): the background teardown hands its selection to the re…
rrgomes commentedon Aug 11, 2026
Answering the question: our host calls
reloadAtCurrentPosition()on foreground return — the app-active handler rebuilds the pipeline torn down on background and re-pauses to keep the user-must-resume behavior — so the parked selection is on our path, no host-side re-select needed.We've bumped to 6.21.0 (contains 6.20.2). The device re-gate is next on the docket, with both traps accounted for: the recipe pauses before backgrounding, and it seeks past the mirrored window after the reload (three seeks into the same dense-dialogue stretch as the report's runs). Our host's cue mirror is also generation-scoped since an adjacent fix on our side — a seek drops it — so a dead post-reload delivery can't hide behind it.
On the trim transient: agreed it's separate. We'll watch it on the new pin during the same session and file it with the
outcome=trimOnlytick next to the published window if it survives.Will confirm the re-gate result here either way.
rrgomes commentedon Aug 12, 2026
Re-gated on 6.21.0, and the fix holds. Trace from the reload:
#357 subtitle-delivery loadGen=3 … recon=1 outcome=emptyat the rebuild, thenloadGen=3 seekGen=2 playhead=484.07 … published=2 outcome=published0.6 s later, with cues flowing continuously from there — where the old pin gave silence at every post-reload reset tick. Recipe was pause → background ≥15 s → foreground → resume → three seeks into dense dialogue, so PiP never kept the pipeline alive, and our host mirror is generation-scoped (dropped on seek) so nothing could hide behind the 60 s window.The trim transient is gone as well: the cue at 542.167 now arrives carrying its authored clear at 546.337 (
outcome=trimOnlyright before it) and clears on time on screen. No separate issue needed.One observation from the same session, which we've handled host-side and are reporting only as data. After a forward seek to 2855.15 s, the republished window led with an open-ended cue starting at 2549.8 s — 305 s behind the new position,
endTime= start + 2^32 ms. Being the window's last cue it had no successor to trim it, so it read active at the new playhead and our overlay showed it for 24.5 s until a real cue displaced it. We now ignore open-ended cues starting more than 30 s behind the playhead, so this is closed for us; flagging it in case the engine would rather not carry a pre-seek set into a post-seek window at all.superuser404notfound commentedon Aug 13, 2026
Thank you for the re-gate, and for running it with both traps closed. A trace that shows
outcome=emptyat the rebuild andpublished0.6 s later is exactly the pair that was missing before, and a generation-scoped host mirror is the right call independent of this issue: it makes a dead delivery visible instead of survivable for a minute.Your third observation is an engine defect and it is fixed in 6.22.1 (
dc62e70). You reported it as data, but the engine should not have handed you that window.The mechanism. A PGS composition has no end of its own, so the decoder stamps it with FFmpeg's
end_display_time = UINT32_MAXplaceholder and the successor composition'spgsTrimAtcloses it. Your seek defeated both bounds the engine has:endTime, and a placeholder end is by construction never older than the retention window, however far the playhead moved. Your 305 s is past the 300 s window, so that cue was the only one left in the store, which is why it led the republished window rather than sitting somewhere in the middle of it.So the cue was neither closed nor pruned, and its window covered the new playhead. Any host that asks which cue is active at the playhead renders it, correctly, from a published window that was wrong.
The fix. A reset tick now closes every still-open cue that began before its reconstruction window, at that window's start (playhead minus the 15 s backscan). That boundary rather than a distance threshold, because it is the one the engine already defines as how far it looks back at a landing: nothing before it is re-decoded, so nothing there can be confirmed as still open. The cue stays in the retained list for a backward seek, only its unconfirmed end retires. An authored duration is untouched, which is what separates this from not carrying the pre-seek set at all: a long typeset sign keeps its own end and stays visible across a seek into it.
The store was not the only holder. The #100 stale-arrival gate keeps a held arrival and a reconstruction candidate carrying the same placeholder end, and the first post-seek trim closes those at a successor start AHEAD of the new playhead, which republishes pre-seek history as the active line. Same defect, second door. A reset now drops both before arming the next pass; anything that can still claim the landing comes back through the backscan's own re-decode.
Verified end to end, with an embedded PGS track whose last composition has no clear, so it is open forever, and a seek 280 s past it:
On 6.22.0 the same run produces no TRIM line and the cue keeps its placeholder end for the rest of the session, which is your report reproduced without a device. Plus 8 unit tests over the reported case, both boundaries, the no-op paths and the gate.
Your host-side filter is now redundant and can go. It is also slightly more permissive than the engine rule, so nothing regresses if you keep it.
Closing this: the background teardown is re-gated on your side, the trim transient resolved with it, and the carry is fixed and released. Please reopen if any of the three shows up again on 6.22.1.
fix(subtitles): retire a placeholder cue end the seek outran (superus…
fix(subtitles): take an open set's end from the next stored packet (#362
fix(subtitles): a derived cue end is revisable and bounded by the har…
fix(engine): a correction the session owns costs no rebuild, and the …
fix(engine): a second background teardown keeps the selection the fir…