Skip to content

Bitmap subtitle history on tvOS: footprint, offset and backward-seek acceptance #929

Closed

Description

@qoli

Problem and requested behavior

Track the bitmap-history memory problem separately from its proposed implementation in #879 (the upstream counterpart of our downstream 0010-subtitle-bitmap-storage.patch).

Dense PGS / DVB / DVD subtitle history can retain substantial expanded pixel storage. We need to reduce that retention while preserving rendered pixels, alpha, crop, placement, forced flags, subtitle offsets and backward-seek reconstruction. The engine owns the retained images, so replacing only the host's visible view does not release that history.

The discussion in #879 established two different costs: compressed history helps retained-but-unsubmitted images, whereas presenting lazy PNG images directly through Core Animation can decode on main and retain expanded pixels. The maintainer selected a raw-RGBA cue-byte budget, released in 7.49.0. This issue tracks the remaining device acceptance and downstream patch exit criteria; it does not establish a regression in that budget.

Version and environment

  • Current downstream baseline: AetherEngine 7.52.0, db35d50e5c3d5b617551ca27ec7ef4a3d4e534e3; FFmpegBuild 3.11.0.
  • Custom host: Syncnext 1.205 (572), signed Debug build, physical Apple TV running tvOS 26.6.
  • Source: 4K REMUX with HEVC Dolby Vision Profile 7 FEL, TrueHD Atmos rendered as APAC 7.1.4, and selected embedded PGS.
  • The latest device run includes our full local integration patch set, including PNG backing. It is supplementary integration evidence, not a measurement of an unmodified 7.52.0 build or of PR perf(subtitles): retain bitmap images with deferred PNG backing #879's branch.

Evidence and its limits

The earlier matched ten-minute raw/PNG comparison and controlled Core Animation counterexample are recorded in PR #879's device report. That report distinguishes expanded layout, encoded bytes and measured process footprint, and records the direct-presentation regression.

On the current patched 7.52.0 integration, a fresh uninterrupted device observation recorded:

Measurement Result
Wall observation 120.154 s
Renderer advancement 120.250 s
Samples 116
Maximum retained bitmap images 46
Maximum images with known encoded backing 46
Maximum total encoded backing 922,658 bytes
Sampled peak process physical footprint 951.85 MiB
Reported memory-pressure events 0

The process footprint includes the full FEL + object-audio pipeline. The encoded byte total is not app RAM or a memory bound. This short, single-mode run cannot establish a raw/PNG improvement, the raw budget's benefit, long-duration behavior, offset compatibility, or visible backward-seek reconstruction.

The full patched integration's focused tests previously passed (33 XCTest + 38 Swift Testing tests). The reporting-time rerun of HTTPDiscMIMERecognitionTests|SubtitleBitmapStorageTests|Issue628PGSOffMainDecodeTests also passed all 18 Swift Testing tests using the already-built test binary. Pixel/lifetime tests do not establish post-presentation process footprint.

Acceptance to resolve

  • Compare the tagged upstream raw-RGBA budget against the existing ten-minute baseline on the same title/device with fixed build provenance and process-footprint sampling.
  • Record the host's exposed subtitle-offset range and verify cues at its supported positive and negative offsets. The current upstream floor is 60 seconds; the protected floor and logical 64 MiB target are not a hard process-footprint cap.
  • Seek backward by one or two minutes into an evicted region and verify actual packet-store/decode/presentation recovery at the landing, including visible PGS.
  • Preserve pixel/alpha/geometry/forced semantics and check cancellation and track changes for the selected solution.
  • If PNG backing remains under consideration, resolve its provider-layout/API contract and direct-Core-Animation decode/cache costs explicitly. perf(subtitles): retain bitmap images with deferred PNG backing #879 already documents those tradeoffs; it is not merge-ready acceptance of PNG as a general memory fix.

Related: #879 (existing implementation PR and maintainer decision), #921 (bitmap-sidecar packet storage/drain; a different retention surface).

No private media URL, credentials, full device logs, or copyrighted sample are included.

Activity

  1. added
    area: subtitles
    enhancement
    on Oct 29, 2026
  2. superuser404notfound commented on Oct 30, 2026

    @superuser404notfound
    Owner

    Thanks for splitting this out with clear acceptance points. I ran the backward-seek part on the Mac with aetherctl play against a synthetic PGS fixture, and it turned up one gap in the budget, now fixed on main (6cf30ab, unreleased).

    Fixture. 300 s, one display set every 3 s with its clear 2 s later. The engine crops each image to its alpha bounding box, so a full-frame ODS with a one-line band costs only about 353 KB (1104x80) and never reaches the 64 MiB target on a short file. The fixture therefore carries a 1120x900 opaque block, about 4 MB of RGBA per cue. Each run plays 140 s, seeks back to 20 s and plays on.

    What held on 7.52.0 + #879:

    • Eviction happens exactly at the floor. The first cue (ended at 8 s) left at playhead 68 s, and the rest followed in order.
    • The seek back into the evicted stretch recovers through the backscan. In a release build the landing cue (21 to 23 s) publishes in the tick after the seek lands, before the playhead reaches 21 s.
    • In a debug build, the same landing cue arrived about 3 s late and was never shown. The backscan decodes its whole window (25 large images here) in one batch before it publishes anything. I could not reproduce this in release. Since your device runs are signed Debug builds, a late or missing first cue after a seek on that build may come from debug decode speed rather than from the policy.

    The gap. After the backward seek, the old position's floor and lead (cues from 84 s to 204 s) count as cues ahead of the new playhead, and the budget never evicts those. The retained images grew from 165 MB to 246 MB and stayed there until playback got back to them. On a dense track, every seek back therefore roughly doubles the retained images.

    Fix (#929, f95b4c4). Under budget pressure, cues that start beyond playhead + 60 s drain lead + 15 s margin, and beyond the cursor's last decoded packet, are now evicted first, furthest first. The cursor has not reached them yet and decodes them again from the packet store when it gets there (the packet store evicts from behind only), and insertCueSorted replaces by start and geometry, so nothing is duplicated. History behind the playhead is evicted only after those cues, so host-offset history is never traded for them.

    Same fixture, release build, both arms run in parallel:

    before after
    retained bitmap bytes right after the seek 241.9 MB 96.8 MB
    retained bitmap bytes at playhead 44.6 s 246.0 MB 116.9 MB
    mallocMB at 150 s (first probe after the seek) 299 126
    physFootprint at 240 s 326 MB 205 MB
    landing cue 21 to 23 s next tick next tick

    physFootprint lags malloc: it read 301 against 302 MB at 150 s in the two arms and separated only by 210 s. A footprint sample taken right after a seek will therefore understate the difference. The 117 MB left at 44.6 s is the protected part, the 60 s floor plus the lead, which on this fixture is above 64 MiB by design. As before, that target is not a cap.

    Four unit tests cover the new eviction order (Issue929BitmapBudgetAheadTests), and the AE#879 suite is unchanged and green.

    What is still open from this issue, and needs your device and your host:

    • The offset range Syncnext exposes. Offsets up to +/-60 s always find their cue. If the host offers more, I would rather tie the floor to a host-declared maximum than have the downstream patch work around it.
    • The ten-minute footprint comparison against the raw-RGBA budget on the same title and device, ideally on a Release build and with this commit included once it is tagged.
  3. superuser404notfound commented on Oct 30, 2026

    @superuser404notfound
    Owner

    Released in 7.53.0 (4a82484).

  4. qoli commented on Nov 6, 2026

    @qoli
    ContributorAuthor

    I ran a new ten-minute pair on the original 57.8 GB REMUX and the same physical Apple TV, now on tvOS 26.6.1. Both fresh processes used Syncnext 1.212 (579) in the app's signed Release configuration, SyncnextHybrid efefa276, AetherEngine 7.56.0 (76ad51a7) and FFmpegBuild 3.12.1. Both included the current upstream bitmap budget and its rewind fix. The raw arm omitted downstream patch 0010 and the PNG arm included it. The playback route was native AVPlayer with P7-to-P8.1 conversion and the TrueHD-to-EAC3 bridge, audio stream 1, PGS stream 6, 1× playback and a 12.00 s forward-buffer preference.

    Ten-minute measurement Raw RGBA budget PNG history
    Playback-clock advancement 600.032 s 600.028 s
    Process footprint samples, nominally 5 s apart 119 116
    Peak sampled physical footprint 561.99 MB 451.05 MB
    Median physical footprint over the last 120 s 506.18 MB 419.99 MB

    All 120 playback-clock samples per arm reported playing at 1×. MB is decimal and the footprint covers the entire process. A first PNG run had the playback information overlay enabled. The table uses the fresh overlay-off run to match the raw arm.

    The older 7.47.0 Debug pair on this title measured 815.84 MB raw and 589.55 MB PNG at the sampled peaks. That pair supplies historical context across different engine and build versions. Earlier device comparison

    After each measurement I sought back 120 s, from about 604.70 to 484.72 s. The pre-seek diagnostics showed 360 retained bitmap cues with the earliest at 521.146 s and zero covering the target. Both arms resumed video and rendered the PGS overlay in the landing region, captured on the TV by 491–493 s. In a separate diagnostic device run on the raw variant, PGS 6 → 5 → 6 mounted the selected track's image on every change, including an authored forced cue with its 1920×1080 canvas geometry. Switching again and stopping cleared both cue history and overlay. Forty focused raw-variant tests passed for pixel and alpha preservation, crop and placement, forced cues, seek landing and cancellation. The current Syncnext host uses a 0 s embedded-subtitle offset.

    The raw seek and presentation checks passed. PNG history still reduced sampled peak footprint by 110.94 MB (19.7%) and the late-window median by 86.19 MB (17.0%) on this workload. I am leaving the downstream PNG retirement decision open with these results.

  5. superuser404notfound commented on Nov 6, 2026

    @superuser404notfound
    Owner

    Thanks for the matched Release pair and for running the seek and track-switch checks on the device. The 0 s offset answers the open question from my last comment, and it points straight at where most of the 111 MB comes from.

    Where it comes from. The 64 MiB budget never touched two windows: 60 s of history behind the playhead (the floor that lets a host offset find its cue without a seek) and the drain's 60 s decode lead ahead of it. Both were sized for offsets up to +/-60 s. On a dense track those 120 s alone are well above 64 MiB, so the target never applied. Your pre-seek dump (360 retained cues, the earliest about 84 s behind) has that shape. A PNG history keeps the same cues, only compressed.

    Change (ca8e3be, merged to main as d8f4c41, unreleased). A new AetherEngine.maximumSubtitleOffsetSeconds lets the host declare the largest offset of either sign it applies to the overlay. Both bitmap edges follow it, never below 15 s (the backscan a seek re-decodes, and enough to cover a backward nudge under the 2.5 s jump threshold, which does not re-decode), and the lead never above 60 s. The default stays 60, so nothing changes until a host sets it. A host without an offset control, Syncnext today, sets 0. softwareSubtitleDelaySeconds is always covered, and text tracks are unaffected.

    Measured with aetherctl play on a 300 s fixture: an opaque 1120x900 PGS image (about 4 MB of RGBA) every 3 s, 140 s of playback, a seek back to 20 s, then 80 s more. Release build, all three arms run in parallel:

    reach 60 (current) reach 10 reach 0
    retained bitmap cues / bytes, steady 41 / 165.3 MB 16 / 64.5 MB 16 / 64.5 MB
    right after the seek back 24 / 96.8 MB 16 / 64.5 MB 16 / 64.5 MB
    mallocMB, 120 s to 210 s 129 to 202 86 86
    physFootprint at 150 s / 180 s 348 / 354 MB 182 / 182 MB 183 / 183 MB
    authored sets missing after the seek (20 to 101 s) 0 0 0
    cues published after their start 0 0 0

    With a reach of 0 or 10, the protected part (15 s each side, about 40 MB here) fits under the budget, so the retained images now sit at the 64 MiB target. A second run at reach 0 with a forward nudge (30.6 s to 32 s) and a far forward seek to 200 s also missed no set. The nudge kept the cues it had already decoded, and the far seek dropped them.

    On your title the retained total should fall to about the budget, unless 15 s each side of that track already exceeds it on its own. Comparing that against the 451 MB PNG run would settle whether PNG still pays for itself downstream. The decision is yours either way. If you rerun it, it needs only engine.maximumSubtitleOffsetSeconds = 0 before the load, with this commit or the release that carries it.

  6. superuser404notfound commented on Nov 6, 2026

    @superuser404notfound
    Owner

    Released in 7.59.0 (b6b3ff7).

  7. qoli commented on Nov 9, 2026

    @qoli
    ContributorAuthor

    I reran the ten-minute comparison on the same 57.8 GB 4K REMUX and physical Apple TV (tvOS 26.6.1). Both runs used signed Release builds of Syncnext 1.214 (581) with AetherEngine 7.61.1 (5f225054) and FFmpegBuild 3.13.0 (9282e592). Both used native AVPlayer, Dolby Vision P7 → P8.1, the TrueHD bridge on audio stream 1, PGS stream 6, a 12 s forward buffer preference, and 1× playback with the playback information overlay off.

    Syncnext uses a fixed 0 s embedded subtitle offset. The raw RGBA arm omitted downstream patch 0010 and set engine.maximumSubtitleOffsetSeconds = 0 before load. The PNG arm kept 0010 and the default 60 s reach. The device logs confirmed 0.0 and 60.0, respectively.

    Ten-minute measurement Raw RGBA, 0 s reach PNG history, 60 s reach
    Playback clock advancement 600.022 s 600.049 s
    Process footprint samples 117 119
    Peak sampled physical footprint 462.34 MB 431.25 MB
    Median physical footprint over the last 120 s 446.33 MB 403.93 MB

    All 120 playback clock samples in each run reported playing at 1×. Process physical footprint was sampled nominally every 5 s and is reported in decimal MB.

    After each measurement I sought back 120 s, from 604.43 s to 484.43 s in the raw arm and from 603.40 s to 483.40 s in the PNG arm. Both targets were earlier than the earliest retained bitmap cue, and neither had a retained cue covering the target. The raw arm held 282 bitmap cues and about 63.98 MiB of estimated decoded image layout at that point. Video resumed and PGS stream 6 was visibly restored on the TV in both runs. The host logged a mounted PGS overlay at about 485.00 s in both. The raw configuration also passed 118 focused engine tests on macOS, including offset reach, rewind, track selection, and cancellation.

    The 0 s raw configuration passed the backward-seek check. On this matched pair, PNG still lowered the sampled peak by 31.10 MB (6.7%) and the median over the last 120 s by 42.39 MB (9.5%). For context, the earlier 7.56.0 PNG run peaked at 451.05 MB. Earlier Release comparison

  8. superuser404notfound commented on Nov 9, 2026

    @superuser404notfound
    Owner

    Thanks for the matched 7.61.1 pair. It shows where the rest of the gap comes from.

    Where the 31 to 42 MB come from. At your seek point the raw arm held 282 cues and 63.98 MiB, so it sat exactly at the byte budget. With a reach of 0, only 15 s on each side of the playhead is protected. Everything else in those 64 MiB was history behind the floor, and that history is what your PNG patch stores compressed. That history does almost nothing:

    • a backward nudge under 2.5 s stays inside the protected 15 s;
    • any larger seek back re-decodes its own 15 s window from the packet store anyway (.resetAndDecode).

    So it only ever saved a re-decode when a seek happened to land inside it.

    Change (b1f922d on main, unreleased). Once a host assigns maximumSubtitleOffsetSeconds, bitmap cues that ended behind max(reach, 15 s) are dropped immediately instead of being kept up to 64 MiB. A host that never sets it keeps the AE#879 budget unchanged. Text tracks are unaffected, and softwareSubtitleDelaySeconds is still covered.

    Same aetherctl play fixture as before (300 s, an opaque 1120x900 PGS image of about 4 MB every 3 s, a seek back to 20 s at 140 s, Release build, arms run in parallel):

    default (undeclared) reach 0, 7.61.1 reach 0, b1f922d reach 10, b1f922d
    retained bitmap cues / bytes, steady 41 / 165.3 MB 16 / 64.5 MB 11 / 44.4 MB 11 / 44.4 MB
    right after the seek back 25 / 100.8 MB 16 / 64.5 MB 5 / 20.2 MB 5 / 20.2 MB
    mallocMB at 150 / 180 / 210 s 129 / 168 / 207 86 / 86 / 86 42 / 57 / 57 42 / 62 / 62
    physFootprint at 150 / 180 s 344 / 346 MB 183 / 183 MB 160 / 162 MB 155 / 161 MB

    After the seek, the landing cue (18 s, covering 20.3 s) and every following set arrive exactly as on 7.61.1, all of them before their start times.

    On your title the retained raw images should fall from about 64 MiB to the 30 s window, which is roughly what your PNG history saves today. Rerunning needs no host change beyond the maximumSubtitleOffsetSeconds = 0 you already set, just this commit or the release that carries it. The PNG decision stays yours.

  9. superuser404notfound commented on Nov 10, 2026

    @superuser404notfound
    Owner

    Released in 7.62.1 (b1f922de): once a host sets maximumSubtitleOffsetSeconds, bitmap cues that ended more than max(reach, 15 s) behind the playhead are dropped at once instead of being kept up to the 64 MiB budget. Sodalite and AetherPlayer are bumped to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: subtitlesenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions