Skip to content

fix(subtitles): preserve secondary track identity across rebuilds - #824

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/fix-secondary-subtitle-lifecycle
Oct 21, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/fix-secondary-subtitle-lifecycle

Conversation

@orut34iop

Copy link
Copy Markdown
Contributor

Summary

The audio-switch rebuild restores a primary registered subtitle through its registry id, but restores its secondary companion through only the URL. This loses the external identity, explicit headers and selected stream inside a subtitle container. Restore the secondary companion through its existing registry entry too, with coherent teardown and load ownership.

What changed

  • Snapshot the secondary external id before internal teardown and re-select that id after rebuilding. One-shot sidecars retain the URL fallback, embedded tracks retain their source-time anchor.
  • Clear a stale sidecar URL when selecting embedded subtitles, and clear active external identity on internal teardown while preserving the rebuild registry.
  • Guard late secondary decode success and failure publication with the captured load generation, in addition to task cancellation.
  • No new public API, bitmap/ASS capability, prepare/commit transaction, or restriction on using one track in both channels.

Test plan

Host: Apple Silicon Mac17,3, macOS 26.7.1, Swift 6.4. Existing synthetic multi-subtitle container fixture; tests verify the selected Spanish stream and registry identity after restoration, teardown, removal, stale-generation publication, embedded selection and same-track dual-channel behavior. Tests exercise the restoration routine called by the audio rebuild, not a physical audio-track switch or an AVPlayer media session. No new device acceptance is claimed for this isolated PR.

  • Regression proof on untouched upstream production code: three tests failed with four assertions covering retained external id, stale sidecar URL, and stale decode publication into the next load generation.
  • With the fix, 30 focused Swift Testing regressions across six suites passed under LIBDISPATCH_COOPERATIVE_POOL_STRICT=1, including multi-stream restoration and same-track dual-channel compatibility.
  • Full default-traits run passed: 795 XCTest cases (one existing skip), 4,619 Swift Testing tests in 633 suites, zero failures.
  • Native host build passed. Test bundle and CLI were signed and verified with an Apple Development identity; linker ad-hoc signing was disabled.
  • Documentation links and git diff --check passed. Platform builds and all-traits coverage remain for upstream CI.

Checklist

  • CHANGELOG and API behavior documentation updated
  • Conventional Commit
  • Engine fix, reuses existing registry
  • No new public API or dependencies

@superuser404notfound
superuser404notfound merged commit 57ab376 into superuser404notfound:main Oct 21, 2026
4 checks passed
superuser404notfound pushed a commit that referenced this pull request Oct 21, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Thanks @orut34iop, merged in 57ab376.

Short review:

The branch conflicted with #822 (origin-scoped subtitle headers). Resolved additively: the secondary decode keeps #822's resolvedSubtitleHeaders and gains your sessionGeneration fence. On the merged tree the full suite passed locally (780 XCTest cases with the existing skip, 4705 Swift Testing tests in 649 suites). Follow-up 00079b0 only rewrites the CHANGELOG entry into the house format. Ships with the next engine release.

@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.45.0 (52802af).

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.

2 participants