Skip to content

PGS multi-object display set collapses to its last composition object in the retained store; no per-cue forced flag to distinguish the dropped sibling #146

Closed

Description

@cmcpherson274

What happened?

I played an MKV whose PGS display set carries multiple composition objects at the same start time
(e.g. a forced sign at the top plus dialogue at the bottom — a common real-disc shape).

Expected: both objects rendered.

Instead: the decoder correctly fans N objects into N same-start image cues, but the retained
store's same-start image replacement then replaces each sibling with the next before publish, so
ONLY the last object renders. The other object(s) are silently dropped, and there is no per-cue
forced flag anywhere on the engine surface, so a host cannot even tell a forced line was dropped.

Steps to reproduce

  1. Play an MKV whose PGS track has a display set with ≥2 composition objects sharing a start PTS
    (both ODS present in the SUP).
  2. Observe the overlay: only the last object renders; the earlier sibling never appears.
  3. Note there is no per-cue forced flag on SubtitleCue/SubtitleImage to detect which line was
    dropped (only TrackInfo.isForced, which is track-level).

AetherEngine version or commit SHA

5.5.1 / 33565b2 (FFmpegBuild 2.0.0). Cited code is identical at current main as of 2026-07-18.

Host app

Custom / my own integration

Platform

macOS

OS version

macOS 26.5.2 (arm64)

Device / chip

Apple Silicon Mac (arm64)

Playback path

Native AVPlayer

Source media (for playback bugs)

MKV, PGS subtitle track with a two-object display set (both ODS present, 1731 + 1863 bytes); a
synthetic fixture (3,417,863 bytes, SHA-256 b594429164…) with authored ground truth.

Error codes / log lines

No error (silent drop). Deterministic, every run: our two-object 30 s display set emits exactly ONE
cue — the last object (forced top sign, rect [685,110,550,59], bitmap SHA 3568d40d…); the
non-forced dialogue object ([685,910,550,59], f0d3e10c…) is silently dropped. Reproduced 15/15
joined events across an 18-dump sweep + two determinism runs, vs an independent range-reader
reference that presents both windows. Only host-visible fingerprint: a gap in the
session-monotonic cue ids.

Anything else

Mechanism (exact cite): Sources/AetherEngine/AetherEngine+Subtitles.swift, the insertCueSorted
image-replacement branch (~lines 403–445 at 33565b2; unchanged at main as of Jul 18). Its doc
comment justifies replacement with "a PGS composition has a unique start PTS, so a same-start image
cue is the same line re-decoded" — true per COMPOSITION, but false per composition OBJECT: N
objects of one composition legitimately share a start PTS.

Contrast with the text path (same function, #121 lineage): same-start TEXT cues with different
content are deliberately BOTH kept ("distinct simultaneous speakers … both kept"); the image path
has no equivalent content-aware guard.

The API facet: no per-cue forced flag exists — SubtitleCue/SubtitleImage carry no forced field,
AVSubtitleRect.flags (AV_SUBTITLE_FLAG_FORCED) is never read, only TrackInfo.isForced exists. On a
real disc showing a forced sign + dialogue simultaneously, the engine renders one line and the host
cannot tell which. Happy to split this API half into a separate enhancement if preferred.

Not reopening #112: the dedup was added in that rework and its own fixed defects remain fixed in our
measurements — this is a side-effect of the dedup's per-composition assumption, cross-referenced for
lineage.

Fix directions (offered): only replace when the incoming publish batch does not contain the prior
same-start cue as a sibling; or key replacement on (start PTS, object ordinal/window) instead of
start PTS alone.

Version note: 5.5.1; no release 5.6.0–5.8.6 touches the image-cue path, and the cited branch is
unchanged at main by inspection. Fixture + sidecar + dumps available on request.

Re-confirmed on HEAD 5.8.9. I built the pinned engine at tag 5.8.9 and ran the same seek battery (targets 165/22/120/175) against the same fixture as the original 5.5.1 report: byte-identical behaviour — after each seek only the cues after the landing point re-emit, and the landing-span line is still never repainted (the cue set matches 5.5.1 exactly, differing only by sub-second timing jitter). No release 5.6.0–5.8.9 mentions PGS. Happy to share the before/after dumps.

Activity

  1. added
    bug
    on Jul 19, 2026
  2. superuser404notfound commented on Jul 19, 2026

    @superuser404notfound
    Owner

    Fixed in 5.9.5 (PR #153). Exceptional report once again, the exact cite plus the authored ground truth made this a straight walk. Both halves shipped together:

    The collapse. Confirmed exactly as diagnosed: the insertCueSorted image-replacement branch keyed on start PTS alone, and its "unique start PTS" justification holds per composition, not per composition object. Of the two directions offered, the fix goes with keying the replacement on (start PTS, object geometry): normalized position + pixel size, both deterministic across re-decodes since the alpha-bounding-box crop is a pure function of the rect bytes. A re-decode still replaces its placeholder twin (the audio-switch / post-seek backscan contract the replacement exists for), sibling objects all survive, mirroring the text path's distinct-simultaneous-speakers rule. The batch-sibling direction would also have worked but keys on arrival grouping rather than on what the objects ARE; geometry stays correct even if a future path ever delivers siblings across separate inserts.

    Same collapse one level up. Reviewing the seek path turned up the identical assumption in the #112/#143 reconstruction pass: it held a SINGLE active-line candidate, so a multi-object landing set lost all but one object at seek time even with the store fixed. The candidate is now the whole same-start group; the #143 clear-trim applies per member.

    The API half. Kept in this release rather than split out: AV_SUBTITLE_FLAG_FORCED is now read off each decoded rect into SubtitleImage.isForced, surfaced per cue as SubtitleCue.isForced (source-compatible; track-level forcedness stays on TrackInfo.isForced). Since the flag rides inside the cue body, it survives every trim/re-wrap in the pipeline. Your dropped-sibling detection via cue-id gaps should no longer trigger at all, but the flag now tells you which line is the sign regardless.

    Covered by Issue146PGSMultiObjectTests with your geometry (sign [685,110,550,59] + dialogue [685,910,550,59] @1080p); the three collapse repros fail on 5.9.4 and pass on 5.9.5. If you get a chance to run your 18-dump sweep + determinism battery against the fixture with authored ground truth on 5.9.5, that confirmation would be appreciated.

  3. cmcpherson274 commented on Jul 20, 2026

    @cmcpherson274
    Author
    Re-ran against 5.9.7: confirmed fixed, both halves, with your geometry.
    
    The collapse: the 30 s two-object set now emits TWO coexisting same-start cues — dialogue
    [685,910,550,59] (bitmap f0d3e10c…) AND the forced sign [685,110,550,59] (3568d40d…) —
    matching our authored sidecar exactly, in two full sequential runs on two fixture variants
    AND through seek re-emission (both members re-emit together after a backward seek, so the
    one-level-up reconstruction fix you found is confirmed working too). The cue-id-gap
    fingerprint is gone.
    
    The API half: SubtitleCue.isForced reads correctly — true on the sign object only, false
    (not nil) on every other cue in every run, and it survives the re-emission path. Our
    harness now records it per cue; the geometry-keyed replacement's placeholder-twin behavior
    (re-decode still replaces, siblings coexist) is exactly what we observe in the dumps.
    
    Dumps + sidecar ground truth available on request.
    
  4. superuser404notfound commented on Jul 20, 2026

    @superuser404notfound
    Owner

    Perfect, that closes it out. Two coexisting same-start cues with your authored geometry, the forced flag true on the sign object only and false (not nil) everywhere else, and both members re-emitting together through the backward seek: that is exactly the intended behavior across all three fix points (geometry-keyed store replacement, the same-start reconstruction group, and the per-cue forced flag). The cue-id-gap fingerprint being gone is the confirmation that the store no longer collapses siblings.

    Thanks for the two-variant sweep plus the seek re-emission pass and the determinism check against your sidecar ground truth. No need to send the dumps unless something ever regresses. Appreciate the precise reports throughout this PGS series.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions