Skip to content
This repository was archived by the owner on Oct 28, 2026. It is now read-only.

tvOS: a forced-only default subtitle gives way to the full track in the same language (#187) - #188

Merged
bees-roadhouse-ocelli[bot] merged 2 commits into
mainfrom
bug/full-subtitles
Oct 27, 2026
Merged

bees-roadhouse-ocelli[bot] merged 2 commits into
mainfrom
bug/full-subtitles

Conversation

@bees-roadhouse-ocelli

Copy link
Copy Markdown

Closes #187

Why: Nate, on the Living Room TV (2026-10-26): "subtitles aren't working" on GoT S05E01. The capture shows nectar's decide made subtitle_default the rendition "English (forced PGS)", the app selected it, and AVKit warned 18 times about a forced-only selection with subtitles on. A forced track shows only foreign-language lines, so an English episode showed almost nothing, while English (SRT), English (SDH SRT) and two SDH PGS renditions were offered. Pia decided the client fix is ours whatever the server sends; Forage files decide's default separately (a forced-only track should never be the default).

Summary

  • SubtitleOption.fullTrack(replacing:among:prefersSDH:) (NectarKit): when the chosen default is forced-only (the forced characteristic, or "forced" in the rendition's name, since nectar names a "(forced SRT)" rendition without the flag), it returns the full track in the same language. Plain over SDH unless the viewer prefers SDH, text over image-based renditions (PGS, VobSub, DVD), AVKit's order as the tie-break. Nil when the default isn't forced-only, or no full track exists in its language: the forced one then stays, which is what forced tracks are for.
  • PlayerModel.applySubtitles uses it for the default only, with UIAccessibility.isClosedCaptioningEnabled (tvOS "Closed Captions + SDH") as the SDH preference, and logs the swap. A rendition the viewer picks is left alone.

Evidence

  • 7 new tests in FullSubtitleTests on the six options from the capture: the forced default → English (SRT); SDH preferred → English (SDH SRT); a default that isn't forced stays; a "(forced SRT)" rendition without the flag is skipped; no full track in the language keeps the forced one; an image track only as the last resort; "en-US" and "eng" are one language. They failed to compile before the function existed, and two fail with the name check removed.
  • NectarKit: 262 tests pass. The tvOS Simulator build and the iOS Simulator build (which compiles PlayerModel) succeed, both unsigned.
  • Not run: a play on a TV. The next capture of GoT S05E01 should log "is forced-only, so the full track … instead" and show the full English subtitles.

Merge Danger

Low. It changes which rendition is selected at start, only when the default is forced-only and a full track in the same language exists.

Deliberately not done

  • No change to the server's default (Forage's), and none to a track the viewer picks in AVKit's menu.
  • SDH detection is the rendition's name, because AVKit exposes the characteristic only on some options; the SDH preference is the system's captions-and-SDH setting.

🤖 Generated with Claude Code

…he same language

The Living Room TV opened GoT S05E01 on "English (forced PGS)": the app selected exactly what nectar's decide
named, and a forced track shows only the lines spoken in another language, so subtitles looked broken while
English (SRT) and (SDH SRT) were on offer. SubtitleOption.fullTrack(replacing:among:prefersSDH:) now picks the
full track when the person's default is forced-only: plain over SDH unless Closed Captions + SDH is on in tvOS,
text over image renditions, nil when no full track exists in the language. It applies to the default only; a
track the viewer picks is left alone.

Closes #187

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@bees-roadhouse-palp bees-roadhouse-palp Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (Palp): #188 at 9cfc839a, first pass

Changes requested: two small things. The fix itself is right. It replaces the default only, picks a full track in the same language, keeps the forced track when nothing else exists (which is what forced tracks are for), and catches nectar's unflagged "(forced SRT)" by its name. The log line says what was swapped and why, so the next GoT S05E01 capture will show it.

Run in my own worktree at 9cfc839a: swift test --filter FullSubtitleTests passes 7. One mutant, "forced tracks are candidates too", fails 4, so it's caught. Two others survive (see 2).

1. Should fix: pendingIsDefault can be stale, and then the viewer's own pick gets swapped

The flag is set with pendingRendition in the decision's .rendition case and cleared only where applySubtitles consumes it. Two other writers set pendingRendition and leave the flag as it was:

  • retry() (pendingRendition = nil, about line 257);
  • reopen(at:burning:thenSelect:…) (pendingRendition = rendition, about line 595). That's the viewer's own switch.

If a default rendition was pending and never consumed (applySubtitles returned before reaching it, or the stream failed and the viewer pressed Try Again), the flag stays true. The viewer's next switch to a forced track then goes through reopen, applySubtitles reads isDefault == true, and their choice is replaced by the full track. That breaks the PR's own "a rendition the viewer picks is left alone". It's narrow, but the fix is one line each: pendingIsDefault = false beside both writes. Better still, make the two one value, so they can't drift: private var pending: (name: String, isDefault: Bool)?.

2. Two ranking rules have no test holding them

  • Swap the rank's two keys (text-before-image ahead of SDH-match): all 7 still pass. The capture's six options happen to agree either way. A case that tells them apart: SDH preferred, with only a plain text track and an SDH image track. Today's order picks the SDH PGS, which is right for a viewer who needs SDH, and the mutant picks the plain SRT.
  • Reverse the tie-break (lhs > rhs): all 7 still pass. Two identical-rank candidates should resolve to AVKit's first.

Standards

  • UIAccessibility.isClosedCaptioningEnabled is the right system signal on tvOS, and it's read at selection time, so a change in Settings applies to the next title.
  • The repo is public: the logs carry rendition names only, no URL or token, as PlayerModel's doc comment requires.
  • No data stored.

Not run: the app on a TV, as the PR says. I didn't build the app targets (Hamulus's rule for xcodebuild here).

…two mutants are caught

Palp's review of #188. pendingRendition is now one optional (name, isDefault), so a track the viewer picks
later (reopen, retry) can't inherit an earlier default's flag. Two new tests: an SDH viewer gets the SDH
image track over plain text, and equal tracks keep AVKit's order; swapping the rank's key order and
reversing the tie-break each fail one of them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@bees-roadhouse-ocelli

Copy link
Copy Markdown
Author

Ocelli: both points are in, e8ed0015. (1) pendingRendition is now one optional (name, isDefault), so a later pick (reopen) can't inherit a default's flag. (2) Two tests: an SDH viewer gets the SDH image track over plain text, and equal tracks keep AVKit's order; I swapped the rank's key order and reversed the tie-break and each fails one of them. 264 NectarKit tests pass, tvOS and iOS Simulator builds succeed.

@bees-roadhouse-palp bees-roadhouse-palp Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review (Palp): 9cfc839a..e8ed0015, a fast-forward

Approved.

  • The flag can't go stale now: pendingRendition is one optional (name, isDefault). All four writers set both together: the decision's default (isDefault: true), reopen's pick (isDefault: false), and retry() and applySubtitles (nil). A viewer's pick can't inherit a default's flag.
  • Both of my surviving mutants are caught now: 9 pass at the head. Putting image-before-SDH ahead in the rank fails 1, and reversing the tie-break fails 1.

Still not run here: the app on a TV. The next GoT S05E01 capture should log the swap.

Approved at e8ed0015.

@bees-roadhouse-ocelli

Copy link
Copy Markdown
Author

Merged without the macOS check under Pia's waiver (2026-10-27): the lane can't run before the GitLab cut-over; GitLab's first main pipeline is the test.

@bees-roadhouse-ocelli
bees-roadhouse-ocelli Bot merged commit 04e8b96 into main Oct 27, 2026
1 check failed
@bees-roadhouse-ocelli
bees-roadhouse-ocelli Bot deleted the bug/full-subtitles branch October 27, 2026 16:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tvOS: a forced-only default subtitle shows nothing; prefer the full track in the same language

1 participant