Repository navigation
Honor complete Apple subtitle preferences - #124
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR adds system-driven subtitle language selection and playback state handling. It also maps caption appearance settings into runtime styling, native overrides, previews, and layered rendering. Settings screens now describe and enforce device Accessibility control. ChangesSubtitle preferences and playback integration
Caption appearance and rendering
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant SystemCaptionSelectionPreferences
participant PlayerSettings
participant PlayerViewModel
participant PlaybackPrefsResolver
SystemCaptionSelectionPreferences->>PlayerSettings: Read current caption selection
PlayerSettings->>PlayerViewModel: Refresh system preferences
PlayerViewModel->>PlaybackPrefsResolver: Resolve ordered subtitle preferences
PlaybackPrefsResolver-->>PlayerViewModel: Apply selected, disabled, or unchanged state
sequenceDiagram
participant SystemCaptionAppearance
participant SubtitleStylingOverride
participant SubtitleRenderer
SystemCaptionAppearance->>SubtitleStylingOverride: Convert caption appearance
SubtitleStylingOverride->>SubtitleRenderer: Apply styling and compositing overrides
SubtitleRenderer-->>SubtitleStylingOverride: Render grouped caption regions
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f8725e454
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| behavior: behavior | ||
| ) | ||
| } | ||
| if behavior == .useValue { result.contentOverrides.insert(.colors) } |
There was a problem hiding this comment.
Preserve per-property color override precedence
When a native ASS track is shown and only one Apple color property has “Video Overrides Style” disabled—for example, foreground color is .useValue while background color remains .useContentIfAvailable—this single .colors flag causes SubtitleStylingOverride.apply to enable ASS_OVERRIDE_BIT_COLORS, replacing the track’s primary, outline, and background colors together. Consequently, authored values are lost for color properties whose individual Apple preference explicitly allows content to override them; retain precedence separately for each color/opacity property rather than promoting any one property to a category-wide override.
Useful? React with 👍 / 👎.
| let primaryBounds = paintedBounds(imgPrimary) | ||
| let secondaryBounds = paintedBounds(imgSecondary) |
There was a problem hiding this comment.
Draw caption windows per simultaneous cue
When a subtitle slot contains two simultaneous events at different positions, paintedBounds unions every libass image in the slot and the renderer draws one window around that union. This produces a large rectangle spanning the empty area between independent cues—especially common with ASS dialogue plus positioned signs—instead of a separate caption window behind each cue. The window bounds need to preserve event/cue grouping rather than collapsing the entire rendered slot into one rectangle.
Useful? React with 👍 / 👎.
| var assShadow: Double { | ||
| backgroundStyle == .shadow ? 1.5 : boxPadding | ||
| if systemTextEdgeStyle == .dropShadow { return 1.5 } | ||
| if systemTextEdgeStyle == .raised { return 1.0 } | ||
| if systemTextEdgeStyle == .depressed { return -1.0 } | ||
| return backgroundStyle == .shadow ? 1.5 : boxPadding |
There was a problem hiding this comment.
Render drop shadows independently from glyph backgrounds
When the Apple profile combines a nonzero glyph background with the drop-shadow edge style, boxEnabled selects ASS BorderStyle 4 while this branch supplies 1.5 as Shadow. As the comments above assBorderStyle and boxPadding note, libass interprets Shadow as box padding under BorderStyle 4, so the requested drop shadow is not rendered even though the preview shows the background and shadow together. The system edge needs a separate rendering path when a glyph background box is also enabled.
Useful? React with 👍 / 👎.
| if let forced = bestLanguageMatch( | ||
| nil, | ||
| in: inputs.availableSubtitles.filter(\.isForced), | ||
| preferForced: true, | ||
| preferAccessibility: inputs.preferAccessibilityTracks |
There was a problem hiding this comment.
Avoid selecting forced tracks in unrequested languages
When Forced Only is enabled and no forced track matches any Apple preferred language, this fallback calls bestLanguageMatch(nil, ...) and therefore selects the first forced track in an arbitrary language. For example, an English-only caption profile will enable a French forced track rather than disabling captions, despite the new language stack being the declared source of truth. Limit the fallback to a meaningful match such as the current audio language, or disable subtitles when none of the requested caption languages is available.
Useful? React with 👍 / 👎.
| case .outline, .none: | ||
| return 0xFF | ||
| return systemTextEdgeStyle == .dropShadow ? 0x80 : 0xFF |
There was a problem hiding this comment.
Make raised and depressed edges visible in playback
When Apple's edge style is Raised or Depressed and there is no glyph background box, assShadow supplies a nonzero directional shadow but this alpha calculation leaves BackColour fully transparent because it only recognizes .dropShadow. Libass uses BackColour for the shadow, so the directional component disappears and both styles render as the same uniform outline, unlike the distinct preview. Supply an appropriate visible shadow color/alpha for raised and depressed edges.
Useful? React with 👍 / 👎.
| for language in preferredLanguages { | ||
| if let pick = bestLanguageMatch( | ||
| language, | ||
| in: inputs.availableSubtitles, | ||
| preferForced: false, |
There was a problem hiding this comment.
Clear server-selected subtitles when system languages miss
When playback starts with a server-profile subtitle already selected but Use Device Settings specifies languages for which no track exists, this new language loop exhausts its candidates and the resolver eventually returns .noChange. applyAutoSubtitle then leaves the server-selected track active—for example, an English subtitle remains visible under a Spanish-only device profile—even though the UI disables the server preference controls and says selection follows Apple settings. Once an explicit system language stack has no acceptable match, disable the existing selection or apply a documented system fallback instead of preserving the server choice.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0eb8015be9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if img.type == IMAGE_TYPE_SHADOW { | ||
| if let backgroundColorOverride { |
There was a problem hiding this comment.
Create native ASS backgrounds instead of only recoloring shadows
When a native ASS cue has no authored shadow or box and Apple marks background color or opacity as .useValue, this branch has no IMAGE_TYPE_SHADOW bitmap to modify, while SubtitleStylingOverride.apply enables the border override only for .edge. The requested glyph background therefore remains completely absent; authored drop shadows can also be mistaken for backgrounds because they share this image type. Synthesize the system background or make libass emit an appropriate box whenever either background property overrides content.
Useful? React with 👍 / 👎.
| forcedOnly: true, | ||
| preferAccessibilityTracks: system.prefersAccessibilityTracks, | ||
| disableWhenNoLanguageMatch: true, |
There was a problem hiding this comment.
Route forced sidecars through the system language policy
When Forced Only is active and no embedded forced track matches the device languages, a later forced sidecar bypasses this restricted resolver: appendSidecarTracks selects the first forced descriptor at lines 7280–7285 and returns. Thus an English-only device profile can still enable a French forced sidecar despite disableWhenNoLanguageMatch; skip that unconditional fallback in device-settings mode or resolve sidecars through the same ordered language policy.
Useful? React with 👍 / 👎.
| mode: prefs.mode, | ||
| showForced: prefs.showForced, | ||
| forcedOnly: prefs.forcedOnly, | ||
| preferAccessibilityTracks: prefs.preferAccessibilityTracks, |
There was a problem hiding this comment.
Re-resolve when preferred sidecar tracks arrive
When embedded tracks are reported before sidecars, this preference can initially select a plain embedded subtitle and set prefsResolvedForCurrentItem. If an SDH/CC sidecar—or a track in an earlier preferred language—arrives afterward, appendSidecarTracks calls the resolver with forceWhenNoSelection: true, but the existing selection makes the guard at line 7401 return before this preference is considered. Re-run system resolution when the available track set expands unless hasExplicitSubtitleChoice is set.
Useful? React with 👍 / 👎.
| !handle.isNativeASS | ||
| || !currentParams.systemContentOverrides.intersection(.window).isEmpty |
There was a problem hiding this comment.
Preserve per-property precedence for native caption windows
Although the native color overrides are now split per property, this guard still collapses all three window behaviors: if only window corner radius is .useValue, for example, a native ASS cue also receives the device window color and opacity even when those properties are .useContentIfAvailable. Check the individual window override bits when deciding whether to create and style the compositor window so one forced property does not promote the entire window category.
Useful? React with 👍 / 👎.
| guard let self, self.settings.subtitleMatchesSystemAppearance else { return } | ||
| self.settings.refreshSubtitleSystemAppearance() | ||
| self.applySubtitleAppearanceToPlayer() | ||
| guard !self.hasExplicitSubtitleChoice else { return } |
There was a problem hiding this comment.
Preserve automatic selections across route recovery
When a system-selected subtitle is active and playback falls back to another route or rebuilds for a quality change, the recovery paths infer hasExplicitSubtitleChoice = true merely because a subtitle snapshot exists at lines 2190–2192 and 4948–4951. After that, this guard treats the automatic choice as manual and ignores later MediaAccessibility language or display-mode changes. Preserve the pre-recovery explicit-choice flag instead of deriving it from the presence of any selected track.
Useful? React with 👍 / 👎.
| disableWhenNoLanguageMatch: prefs.disableWhenNoLanguageMatch, | ||
| trackSignature: prefs.trackSignature, | ||
| availableSubtitles: allSubs, | ||
| currentAudioLanguage: audioLang |
There was a problem hiding this comment.
Re-resolve automatic captions after audio-track changes
The system Automatic decision depends on this current audio language, but selectAudioTrack never invalidates prefsResolvedForCurrentItem or invokes the subtitle resolver. For example, starting with preferred English audio can disable full captions, then manually switching to Japanese audio leaves them disabled instead of selecting the preferred English subtitle. Re-run the system subtitle policy after a successful audio selection unless the user made an explicit subtitle choice.
Useful? React with 👍 / 👎.
| if systemTextEdgeStyle == .raised { return 1.0 } | ||
| if systemTextEdgeStyle == .depressed { return -1.0 } |
There was a problem hiding this comment.
Match raised and depressed shadow directions to the preview
Fresh evidence after the prior visibility fix is that the no-box playback offsets are reversed: positive ASS shadow moves down/right for .raised and negative moves up/left for .depressed, while both the preview and the new compositor path use raised up/left and depressed down/right. Consequently, adding or removing the glyph background flips the emboss direction for the same Apple edge setting; swap these signs so both rendering paths agree.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift (1)
245-250: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPrefer an exact language-tag match before a primary-subtag fallback.
Line 249 places
pt-PTandpt-BRin the same pool. If the Brazilian track appears first, it can be selected for a Portuguese-from-Portugal preference.First filter for a case-insensitive exact tag match. Only use
languagesMatchwhen no exact match exists. Add a test withpt-BRlisted beforept-PT.Proposed fix
let pool: [PlayerTrack] if let lang = language { - pool = tracks.filter { + let exactMatches = tracks.filter { + $0.lang?.caseInsensitiveCompare(lang) == .orderedSame + } + pool = exactMatches.isEmpty ? tracks.filter { guard let trackLang = $0.lang else { return false } return languagesMatch(trackLang, lang) - } + } : exactMatches } else { pool = tracks }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift` around lines 245 - 250, Update the language-based pool selection in the playback preference resolver to first filter tracks whose language tags exactly match the requested language case-insensitively. Only fall back to the existing languagesMatch primary-subtag logic when that exact-match pool is empty, and add coverage with pt-BR ordered before pt-PT to verify pt-PT is selected.iosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift (1)
117-134: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy liftKeep
.topon a stable focus owner.When
subtitleMatchesSystemAppearancechanges,.topmoves between the Language row and “Use Device Settings”. The current focus target can then become invalid. Keep.focused(detailFocus, equals: .top)outside the conditional branches, or restoredetailFocusafter the update. Apply the same correction to the Language row.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift` around lines 117 - 134, Keep the .top focus modifier attached to a stable view outside the conditional branches for both the Language row and the “Use Device Settings” row in TVSubtitleSettingsView, so changing subtitleMatchesSystemAppearance does not invalidate the active focus target. Preserve the existing toggle behavior and ensure detailFocus remains associated with the same focus owner across state updates.Source: Coding guidelines
🧹 Nitpick comments (2)
iosApp/Tests/SystemCaptionAppearanceTests.swift (1)
27-37: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename
testWindowOpacityMapsToBoxto match its assertions.The test no longer asserts a box background. It asserts caption-window opacity, color, and corner radius. The current name describes the removed behavior.
♻️ Proposed rename
- func testWindowOpacityMapsToBox() { + func testWindowPropertiesMapToCaptionWindow() {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/Tests/SystemCaptionAppearanceTests.swift` around lines 27 - 37, Rename the test method testWindowOpacityMapsToBox to reflect that it verifies caption-window opacity, color, and corner-radius mapping, while leaving its assertions and implementation unchanged.iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift (1)
712-716: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
isDisjoint(with:)for the window override check.SwiftLint reports the
intersection(_:).isEmptypattern here.isDisjoint(with:)states the intent directly and avoids building an intermediate option set.♻️ Proposed change
guard currentParams.captionWindowEnabled, let handle, !handle.isNativeASS - || !currentParams.systemContentOverrides.intersection(.window).isEmpty + || !currentParams.systemContentOverrides.isDisjoint(with: .window) else { return [] }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift` around lines 712 - 716, Update the window override condition in the subtitle renderer’s guard to use isDisjoint(with:) instead of intersection(.window).isEmpty, preserving the existing logic that allows native ASS handles when systemContentOverrides overlaps the window option.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Player/Subtitles/SubtitleStylingOverride.swift`:
- Around line 105-114: Update assShadow in SubtitleStylingOverride to avoid
relying on a negative ASS Style.Shadow value for .depressed when generating
synthetic headers. Route the depressed direction through \xshad/\yshad overrides
or the existing compositor path, while preserving the current box, dropShadow,
raised, and default behavior.
---
Outside diff comments:
In `@iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift`:
- Around line 245-250: Update the language-based pool selection in the playback
preference resolver to first filter tracks whose language tags exactly match the
requested language case-insensitively. Only fall back to the existing
languagesMatch primary-subtag logic when that exact-match pool is empty, and add
coverage with pt-BR ordered before pt-PT to verify pt-PT is selected.
In `@iosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift`:
- Around line 117-134: Keep the .top focus modifier attached to a stable view
outside the conditional branches for both the Language row and the “Use Device
Settings” row in TVSubtitleSettingsView, so changing
subtitleMatchesSystemAppearance does not invalidate the active focus target.
Preserve the existing toggle behavior and ensure detailFocus remains associated
with the same focus owner across state updates.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift`:
- Around line 712-716: Update the window override condition in the subtitle
renderer’s guard to use isDisjoint(with:) instead of
intersection(.window).isEmpty, preserving the existing logic that allows native
ASS handles when systemContentOverrides overlaps the window option.
In `@iosApp/Tests/SystemCaptionAppearanceTests.swift`:
- Around line 27-37: Rename the test method testWindowOpacityMapsToBox to
reflect that it verifies caption-window opacity, color, and corner-radius
mapping, while leaving its assertions and implementation unchanged.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 67866d57-3205-423d-bb54-82138cc1f31e
📒 Files selected for processing (16)
iosApp/Tests/SubtitleAutoResolverTests.swiftiosApp/Tests/SubtitleStylingOverrideTests.swiftiosApp/Tests/SystemCaptionAppearanceTests.swiftiosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swiftiosApp/iosApp/Screens/Player/PlayerSettings.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/Sheets/PlayerSettingsSheet.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleAppearance.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleAppearancePreview.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleStylingOverride.swiftiosApp/iosApp/Screens/Player/Subtitles/SystemCaptionAppearance.swiftiosApp/iosApp/Screens/Player/Subtitles/SystemCaptionSelectionPreferences.swiftiosApp/iosApp/Screens/Player/tvOS/TVPlayerInfoHUD.swiftiosApp/iosApp/Screens/Settings/SubtitleSettingsView.swiftiosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0647b0de75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| canvas.draw( | ||
| imageList: imageList, | ||
| offsetX: frameOffsetX, | ||
| offsetY: frameOffsetY, | ||
| characterColorOverride: characterColor, |
There was a problem hiding this comment.
Suppress authored boxes when overriding native backgrounds
Fresh evidence after the prior native-background fix is that, when a native ASS cue already contains an authored box and Apple forces a different background color or opacity, the synthesized system rectangle is painted first but this call then composites the complete libass image list—including the authored non-character box—over it. An opaque authored box therefore continues to determine the visible color and opacity; filter or replace the authored background layer whenever the system background override is active.
Useful? React with 👍 / 👎.
| if params.systemContentOverrides.contains(.edge) { | ||
| systemBits |= Int32(ASS_OVERRIDE_BIT_BORDER.rawValue) |
There was a problem hiding this comment.
Keep edge overrides from forcing the fallback background
When a native ASS track has only the Apple edge option set to .useValue while background opacity remains .useContentIfAvailable, the mapped fallback background can still make boxEnabled true. Enabling this border bit then applies the override style's BorderStyle = 4, so changing the edge also replaces the authored border style with a glyph box even though the background preference explicitly yields to content. Apply the forced edge independently instead of passing the combined edge/background style through the atomic border override.
Useful? React with 👍 / 👎.
| let selectedLanguages = MACaptionAppearanceCopySelectedLanguages(.user) | ||
| .takeRetainedValue() as? [String] ?? [] | ||
| let languages = selectedLanguages.isEmpty ? Locale.preferredLanguages : selectedLanguages |
There was a problem hiding this comment.
Canonicalize all system caption languages
Apple's selected and locale language lists are not limited to the twelve languages covered by SubtitleAutoResolver.isoEquivalent, so valid two-letter/three-letter pairs outside that table never match. For example, a device preference of nl-NL and a subtitle track tagged nld are treated as a language miss and device-settings mode disables captions despite the languages being equivalent. Canonicalize these arbitrary system identifiers with a complete ISO mapping before passing them to the resolver.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12b74e8922
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !self.hasExplicitSubtitleChoice { | ||
| let modeRaw = prepared.watchDetail.effectiveSubtitleMode ?? "" | ||
| self.prefsForCurrentItem = PrefsSnapshot( | ||
| preferredLanguage: prepared.watchDetail.effectiveSubtitleLanguage, | ||
| mode: SubtitleMode(rawValue: modeRaw), | ||
| showForced: prepared.watchDetail.effectiveShowForcedSubtitles ?? false, | ||
| trackSignature: prepared.watchDetail.effectiveSubtitleTrackSignature | ||
| ) | ||
| self.prefsForCurrentItem = self.settings.subtitleMatchesSystemAppearance | ||
| ? self.systemCaptionPrefsSnapshot() | ||
| : self.serverSubtitlePrefsSnapshot(prepared.watchDetail) |
There was a problem hiding this comment.
Let device policy replace server-seeded launch picks
When Use Device Settings is enabled and the detail screen seeds preferredSubtitleTrackIndex from a remembered server signature or server mode .off (ItemDetailView.seedSubtitleOverrideIfNeeded), resetPublishedLoadState marks that index as an explicit user choice. This guard then skips creating the system caption snapshot entirely, so the pending server track or Off sentinel wins and Apple's language/display policy never runs. This remains fresh evidence after the no-language-match resolver fix because the resolver is not reached on this launch path; distinguish genuinely manual route choices from server-seeded indices, or ignore the latter in device-settings mode.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9852f04c89
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| preferredSubtitleTrackIndex = DetailPlaybackFormatting.launchPreferredSubtitleIndex( | ||
| version: effectiveVersion(for: detail, versionFileId: preferredVersionFileId), | ||
| signature: detail.effectiveSubtitleTrackSignature, | ||
| mode: detail.effectiveSubtitleMode | ||
| mode: detail.effectiveSubtitleMode, | ||
| usesDeviceSettings: PlayerSettings.shared.subtitleMatchesSystemAppearance |
There was a problem hiding this comment.
Clear cached subtitle seeds when enabling device settings
When a tvOS detail was first opened with device settings disabled, the server-derived subtitle index remains in the cached detail view model; after enabling Use Device Settings and returning to the same item, .task(id:) does not rerun and this guard prevents recalculating the launch value. Playback therefore still forwards that stale index as an explicit choice and skips Apple's caption policy. Fresh evidence after the launch-seed fix is that TVItemDetailView deliberately persists this selection in ItemDetailCache, while its onAppear does not clear or reseed it; invalidate server-seeded values when the device-settings flag changes while preserving genuinely manual selector choices.
Useful? React with 👍 / 👎.
| pool = exactMatches.isEmpty | ||
| ? tracks.filter { | ||
| guard let trackLang = $0.lang else { return false } | ||
| return languagesMatch(trackLang, lang) | ||
| } | ||
| : exactMatches |
There was a problem hiding this comment.
Prefer full-dialogue tracks before exact forced matches
When the preferred locale has an exact forced track but the only full-dialogue track uses a generic or sibling regional tag, this exact-match pool discards the full track before forced/full-dialogue ranking runs. For example, a pt-PT forced track plus a non-forced pt track causes Always On—or Automatic with foreign audio—to select the signs-only track, contradicting the resolver's invariant that forced subtitles must not steal a full-dialogue pick. Rank forced/accessibility status first among all primary-language matches, using regional exactness only to break ties within the same track class.
Useful? React with 👍 / 👎.
| self.prefsForCurrentItem = self.settings.subtitleMatchesSystemAppearance | ||
| ? self.systemCaptionPrefsSnapshot() | ||
| : self.serverSubtitlePrefsSnapshot(prepared.watchDetail) |
There was a problem hiding this comment.
Order the subtitle picker by the active device languages
When Use Device Settings is enabled and Apple's first caption language differs from the server profile language, this branch resolves and selects using the system snapshot but leaves subtitleOrderingLanguage set to prepared.watchDetail.effectiveSubtitleLanguage. The two in-player subtitle pickers therefore continue floating the disabled server language to the top instead of the active Apple language; settings-change notifications also replace the resolver snapshot without updating this ordering value. Set the display ordering from the system language stack whenever device policy is active, and refresh it alongside that snapshot.
Useful? React with 👍 / 👎.
| for language in [first] + inputs.additionalPreferredLanguages where !language.isEmpty { | ||
| if !result.contains(where: { languagesMatch($0, language) }) { | ||
| result.append(language) |
There was a problem hiding this comment.
Preserve regional entries in Apple's language order
When Apple's ordered caption languages contain multiple variants of the same primary language, this deduplication treats them as identical and removes every variant after the first. Moreover, the first variant's primary-subtag fallback can select an arbitrary sibling before a later exact preference is considered; for example, [pt-BR, pt-PT] with source-ordered tracks [pt-AO, pt-PT] selects pt-AO. Deduplicate only identical normalized identifiers and exhaust exact matches across the ordered stack before falling back to primary-language equivalence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift (1)
96-98: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winApply the empty-track result in
PlayerViewModel.Lines 96-98 return
.disablefor device settings with no subtitle tracks.PlayerViewModel.applyAutoSubtitlePreferencesIfNeededreturns before it callsresolvewhensubtitleTracksis empty. The player cannot clear an automatic subtitle selection in this case.Remove the empty-track guard or call
resolvewith the empty list. Preserve manual selections through the existinghasExplicitSubtitleChoiceguard.Proposed consumer change
let allSubs = subtitleTracks -guard !allSubs.isEmpty else { return } let audioLang = audioTracks🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift` around lines 96 - 98, Update PlayerViewModel.applyAutoSubtitlePreferencesIfNeeded so empty subtitleTracks still reaches PlaybackPrefsResolver.resolve and applies the .disable result. Remove the early return for empty tracks while preserving the existing hasExplicitSubtitleChoice guard so manual selections remain unchanged.
🧹 Nitpick comments (1)
iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift (1)
579-602: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winCache the solid-mask classification per frame.
isSolidBackgroundMaskscans the whole bitmap when the mask is solid. Solid background bitmaps are the largest ones in a cue. The classification runs repeatedly for the same image in one render:paintedRectsis called for primary, secondary, characters-only, and again insideshadowBounds;hasAuthoredGlyphBackgroundwalks both lists;CompositorCanvas.drawclassifies every image once per draw pass, and the uniform edge style adds eight extra passes.At 4K this repeats a full-area scan of the box bitmap more than ten times per composited frame, on the path this file already documents as the dominant render cost. Classify each image once per frame and reuse the result, for example by collecting the background image pointers in a
Set<UnsafePointer<UInt8>>before grouping and drawing, then passing that set intopaintedRectsanddraw.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift` around lines 579 - 602, Cache each image’s solid-background classification once per render frame instead of rescanning it in every consumer. Update the subtitle rendering flow around paintedRects, hasAuthoredGlyphBackground, shadowBounds, and CompositorCanvas.draw to collect background image pointers in a per-frame Set and pass or reuse that classification through grouping and all draw passes, including uniform edge-style passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@iosApp/iosApp/Screens/Detail/ItemDetailView.swift`:
- Around line 764-768: Update the iOS subtitle-selection flow around
preferredSubtitleTrackIndex and
DetailPlaybackFormatting.launchPreferredSubtitleIndex so active device settings
clear only existing non-manual server seeds before the guard can return.
Preserve manual selector choices by marking iOS selections as manual, and mirror
the tvOS behavior so Apple preferences handle selection when no manual choice
exists.
---
Outside diff comments:
In `@iosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swift`:
- Around line 96-98: Update PlayerViewModel.applyAutoSubtitlePreferencesIfNeeded
so empty subtitleTracks still reaches PlaybackPrefsResolver.resolve and applies
the .disable result. Remove the early return for empty tracks while preserving
the existing hasExplicitSubtitleChoice guard so manual selections remain
unchanged.
---
Nitpick comments:
In `@iosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swift`:
- Around line 579-602: Cache each image’s solid-background classification once
per render frame instead of rescanning it in every consumer. Update the subtitle
rendering flow around paintedRects, hasAuthoredGlyphBackground, shadowBounds,
and CompositorCanvas.draw to collect background image pointers in a per-frame
Set and pass or reuse that classification through grouping and all draw passes,
including uniform edge-style passes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3bbdfdc1-40f7-4236-83eb-3fd551040c9d
📒 Files selected for processing (14)
iosApp/Tests/DetailVersionSelectionTests.swiftiosApp/Tests/SubtitleAutoResolverTests.swiftiosApp/Tests/SubtitleStylingOverrideTests.swiftiosApp/Tests/SystemCaptionAppearanceTests.swiftiosApp/iosApp/Screens/Detail/DetailPlaybackFormatting.swiftiosApp/iosApp/Screens/Detail/ItemDetailView.swiftiosApp/iosApp/Screens/Detail/ItemDetailViewModel.swiftiosApp/iosApp/Screens/Player/PlaybackPrefsResolver.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleStylingOverride.swiftiosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swiftiosApp/iosApp/tvOS/Screens/Settings/TVSettingsView.swiftiosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift
🚧 Files skipped from review as they are similar to previous changes (4)
- iosApp/Tests/SystemCaptionAppearanceTests.swift
- iosApp/iosApp/tvOS/Screens/Settings/TVSubtitleSettingsView.swift
- iosApp/iosApp/Screens/Player/Subtitles/SubtitleStylingOverride.swift
- iosApp/iosApp/Screens/Player/PlayerViewModel.swift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbe5a0495a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if Self.isGlyphBackgroundImage(image), let bitmap = image.bitmap { | ||
| glyphBackgroundBitmaps.insert(UInt(bitPattern: UnsafeRawPointer(bitmap))) |
There was a problem hiding this comment.
Do not identify ASS backgrounds solely by solid masks
When native ASS contains an opaque rectangular \p drawing or another character image whose cropped mask is entirely 0xFF, this classifies that foreground bitmap as a BorderStyle 4 background. Its pointer is then excluded from character-only edge/color passes, can be recolored by the Apple background preference, and makes hasAuthoredGlyphBackground suppress synthesized backgrounds for other cues in the slot. Use image/style context in addition to mask solidity so solid authored drawings remain foreground content.
Useful? React with 👍 / 👎.
| let isCharacter = !isGlyphBackground(img) | ||
| && img.type == IMAGE_TYPE_CHARACTER | ||
| if (!charactersOnly || isCharacter), | ||
| img.w > 0, img.h > 0, img.bitmap != nil { |
There was a problem hiding this comment.
Preserve cue fades when synthesizing caption backgrounds
When a native ASS cue uses \fad, \fade, or an animated alpha and Apple forces a caption window or glyph background, paintedRects includes the image even when its rendered color is fully transparent, while the synthesized rectangle is drawn later at the fixed system opacity. The result is a visible empty box before the text fades in and after it fades out. Filter transparent render images or propagate each cue's current effective alpha into the synthesized window/background.
Useful? React with 👍 / 👎.
Summary
Root cause
The existing bridge only mapped a subset of MediaAccessibility into Silo's persistent appearance model. It quantized the system font scale, omitted foreground opacity and window radius, collapsed Apple's glyph background and caption window into one layer, and treated raised/depressed/uniform edges as the same outline.
The toggle also never participated in subtitle track selection, so Apple's language order, display mode, and CC/SDH preference were ignored in favor of the Silo profile settings.
User impact
When Use Device Settings is enabled, iPhone and Apple TV users now get one coherent system-driven experience: track choice, font, color, alpha, scale, edge, glyph background, caption window, and authored-style precedence all follow the active Apple accessibility profile. The Silo profile controls are disabled while the system source is active so the UI reflects the actual source of truth.
Validation
mainat671d4f1Summary by CodeRabbit
New Features
Improvements