Skip to content

fix(subtitles): subtitles off deselects the native rendition, not just its readers (Sodalite#156) - #563

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/clear-subtitle-deselects-rendition
Sep 19, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/clear-subtitle-deselects-rendition

Conversation

@superuser404notfound

Copy link
Copy Markdown
Owner

Reported by Vincent while testing the iOS remote view: with AirPlay running and subtitles on, switching subtitles off removed the text but left a grey caption box on the TV for the rest of the session.

What the device log shows (2026-09-19, iPhone 17 Pro to Apple TV)

The off, at 14:28:38.94:

38.941  #151 forward prefetch cancelled (reason=subtitlesCleared)
38.944  [PlayerVM] forced-subtitle fallback: forcedTrack(streamIndex: 3)
38.953  native subtitle readers exited (cancelled=true)

and then, after it:

40.406  GET /subs_1_380.vtt
44.152  GET /subs_1_381.vtt

The receiver is still fetching subs_1, the rendition it was handed when the language was switched. The engine has just cancelled the readers that fill it. The text was gone because nothing filled the rendition; the box stayed because nothing deselected it.

Root cause

Cancelling the readers stops filling a rendition. It does not stop anything from rendering it. clearSubtitle() had the deselect, but narrowed to the two cases the engine knew a selection by name: a remote-HLS selection (AE#154) and an injected external rendition (#316). Every session where a host asked for native rendering has one too, and there it was left standing.

Selecting a track followed correctly the whole time (native subtitle select: opt=Deutsch 2 ... subs_1.m3u8 fetched at 36.29), which is why a language switch always worked and only off did not. The contract was one-sided, the same shape as #562 earlier today.

One thing worth writing down

A sender-side textStyleRules hide is not an alternative here. It is a local text-renderer instruction and never reaches the receiver. That is exactly why this read as "the text obeys but the box does not", and it sent the first hypothesis in the wrong direction.

A trap avoided, and pinned

Deliberately the item-level deselect rather than setNativeSubtitleSelected(track: nil), whose job this otherwise is: that call also clears nativeSubtitleReapplyOrdinal, and nativeOrdinalToReplay is guarded on currentOrdinal == nil. Clearing it here would have let the #170 carryover replay fire on the .clear branch, i.e. re-select the rendition on the next session-preserving reload. A test pins that guard so the shortcut is not taken later.

Tests

Source-level, the shape Issue541ReloadCarriesHDRRouteTests uses. Both were run against the pre-fix source first and are red there (RemoteHLS gate = True, injected gate = True). Full suite, both runners: swift-testing 3107 tests in 424 suites, XCTest 17 tests, 0 failures.

To verify on device

Turning subtitles back on after an off, during AirPlay: #32 warns that a deselect detaches AVKit's legible renderer and it does not always re-attach after a seek. The select path is measured working mid-session here, but the off-then-on round trip is not.

🤖 Generated with Claude Code

https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F

…t its readers (Sodalite#156)

Measured on an AirPlay route, device log 2026-09-19. Turning subtitles off
cancelled the native readers and left the rendition SELECTED on the receiver.
The Apple TV went on fetching it (subs_1_380.vtt at +1.5s, subs_1_381.vtt at
+5.2s, both after the off) and drew an empty caption box over the picture for
the rest of the session: the text was gone because nothing filled the rendition,
the box stayed because nothing deselected it.

Cancelling the readers only stops FILLING a rendition. It does not stop anything
from rendering it. The deselect existed but was narrowed to the two cases the
engine knew a selection by name, a remote-HLS selection (AE#154) and an injected
external rendition (#316). Every session where a host asked for native rendering
has one too, and there it was left standing. Selecting a track followed the
route correctly the whole time, which is why a language SWITCH always worked and
only OFF did not: the contract was one-sided.

Worth stating because it cost a round to work out: a sender-side textStyleRules
hide is not an alternative here. It is a local text-renderer instruction and
never reaches the receiver, which is exactly why this read as "the text obeys
but the box does not".

Deliberately the item-level deselect rather than setNativeSubtitleSelected(nil),
whose job this otherwise is: that call also clears nativeSubtitleReapplyOrdinal,
and nativeOrdinalToReplay is guarded on `currentOrdinal == nil`. Clearing it
here would have let the #170 carryover replay fire on the `.clear` branch, i.e.
re-select the rendition on the next session-preserving reload, which is the
opposite of the point. The test pins that too.

Both source-level tests were run against the pre-fix source first and are red
there. Full suite, both runners: swift-testing 3107 in 424 suites, XCTest 17,
0 failures.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
@superuser404notfound
superuser404notfound merged commit 4d35b78 into main Sep 19, 2026
7 checks passed
@superuser404notfound
superuser404notfound deleted the fix/clear-subtitle-deselects-rendition branch September 19, 2026 14:53
superuser404notfound pushed a commit that referenced this pull request Sep 19, 2026
…#563)

It traded a grey caption box for no subtitles at all on AirPlay, which is
strictly worse, so it comes out while the cause is worked out off the device.

Device report and log, 2026-09-19 14:56: with the fix in, the native rendition
is never selected for the whole session. `#170 re-applying native subtitle
ordinal=0` fires at 22.767, and the only `native subtitle select` lines in the
capture come after the player is already torn down (39.548, 41.312), both
`selected=nil`. In between the readers re-anchor and start at the HEAD rather
than the playhead (`startAt=0.00s effectiveStart=0.10s seekTo=0.00s` at 26.234,
playhead 1461.10s) and exit immediately with `totalCues=0`, so the pre-fill that
gates the select never completes. The run before the fix did the same thing
correctly (`effectiveStart=1460.00s`, `pre-fill done cues=36`, `selected=Deutsch 2`).

What the fix did achieve is in the same log: `subtitles off: native rendition
deselected` at 33.218, and no `subs_*.vtt` fetched afterwards. The off half
worked. The on half did not, and the causal link between the two is a
before/after correlation plus a plausible mechanism, not a measurement, which is
not enough to keep a change in that leaves a device without subtitles.

Next attempt needs a reproduction that is not Vincent's living room: the select
is gated behind an async pre-fill, and this added a second async path that
touches the same item and the same media selection.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
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.

1 participant