Repository navigation
feat(playback): let profiles start on the embedded subtitle track - #461
d3mystified wants to merge 1 commit into
Conversation
A sidecar is cut for one release of the title and can play out of sync; the track inside the file cannot. Every client ranks the external one first, so there was no way to ask for the other one. playback.prefer_embedded_subtitles (settings contract revision 17, shipped server-side) re-ranks only the source tier, and only inside one track class. Language still decides first, a full track still beats a forced one, text still beats bitmap, an explicit pick and the remembered series signature are untouched, and with the preference off every surface picks what it picked before. Thread the flag through both starters, both player view models, TV's detail preview, and the phone's offline inventory, and add the switch beside "Show forced subtitles" on both settings screens.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (33)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing this. Silo-Server/silo-server#1849 is the server and web half, and it says Android and Apple "get matching PRs" — so the client halves are covered there and this was about to race them. Nothing here is needed for it: the pieces that would have transferred are the source tier on the candidate types, the class-before-source ordering, and the burn-in tier, all of which #1849 spells out precisely enough to implement against, and #1849's own tests name the cases. The branch is left up for now in case the diff is useful to whoever writes the client PR; delete it whenever. |
| pool.bestInClass(preferEmbedded) { (_, subtitle) -> !subtitle.isBitmap() } | ||
| ?.let { return it.index } |
There was a problem hiding this comment.
Source-preference bypass occurs because the phone's terminal selection branches return pool.first() when every matching track is bitmap or every forced track is hearing-impaired, causing an external-first pair in either class to select the sidecar even with preferEmbedded enabled. Apply bestInClass(preferEmbedded) { true } to both terminal returns, matching the shared resolver.
pool.bestInClass(preferEmbedded) { (_, subtitle) -> !subtitle.isBitmap() }
?.let { return it.index }
return pool.bestInClass(preferEmbedded) { true }?.indexPrompt for LLM
File androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleAutoSelection.kt:
Line 250 to 251:
Source-preference bypass occurs because the phone's terminal selection branches return pool.first() when every matching track is bitmap or every forced track is hearing-impaired, causing an external-first pair in either class to select the sidecar even with preferEmbedded enabled. Apply bestInClass(preferEmbedded) { true } to both terminal returns, matching the shared resolver.
Suggested Code:
pool.bestInClass(preferEmbedded) { (_, subtitle) -> !subtitle.isBitmap() }
?.let { return it.index }
return pool.bestInClass(preferEmbedded) { true }?.index
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| resolved(write(SettingKeys.PLAYBACK_SHOW_FORCED_SUBTITLES, JsonPrimitive(enabled))) | ||
|
|
||
| suspend fun setPreferEmbeddedSubtitles(enabled: Boolean): WriteResult = | ||
| resolved(write(SettingKeys.PLAYBACK_PREFER_EMBEDDED_SUBTITLES, JsonPrimitive(enabled))) |
There was a problem hiding this comment.
Race condition identified in write() and resolved(): write() calls setProfileValue() without a captured server/profile/authentication scope, and resolved() calls reresolve() without that scope, allowing an identity change during the suspended write to make the effective-settings reread resolve another profile or server's settings. Capture one scope before the operation, pass it through both helpers, and check its generation before publishing or caching the returned snapshot; apply the same fix at androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsViewModel.kt:588-588 and androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SettingsViewModel.kt:740-740, :688-688, :699-699, :239-239, and :692-692.
Kody rule violation: Bind settings operations and serialization to their captured identity
Prompt for LLM
File shared/src/commonMain/kotlin/org/siloserver/silo/domain/settings/ProfileSettingsController.kt:
Line 133:
Race condition identified in write() and resolved(): write() calls setProfileValue() without a captured server/profile/authentication scope, and resolved() calls reresolve() without that scope, allowing an identity change during the suspended write to make the effective-settings reread resolve another profile or server's settings. Capture one scope before the operation, pass it through both helpers, and check its generation before publishing or caching the returned snapshot; apply the same fix at androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsViewModel.kt:588-588 and androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/SettingsViewModel.kt:740-740, :688-688, :699-699, :239-239, and :692-692.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| codec = row.codec, | ||
| title = row.catalogLabel ?: row.label, | ||
| forced = row.forced == true, | ||
| source = row.source, |
There was a problem hiding this comment.
Incorrect source classification occurs because inventory candidate adaptation uses only row.source, assigning embedded rather than downloaded priority to a row identified by downloadId or catalogSource without a runtime source; with preferEmbedded enabled, an earlier downloaded row can beat a genuine embedded track in the same language/class. Preserve downloaded provenance when constructing candidates and apply the same classification in the phone's subtitleSourcePriority.
Prompt for LLM
File shared/src/commonMain/kotlin/org/siloserver/silo/model/playback/AutoSubtitleResolver.kt:
Line 284:
Incorrect source classification occurs because inventory candidate adaptation uses only row.source, assigning embedded rather than downloaded priority to a row identified by downloadId or catalogSource without a runtime source; with preferEmbedded enabled, an earlier downloaded row can beat a genuine embedded track in the same language/class. Preserve downloaded provenance when constructing candidates and apply the same classification in the phone's subtitleSourcePriority.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
Problem
Related issue: Silo-Server/silo-server#1848
Validation tasks: none
When a file carries a subtitle track inside it and an external sidecar in the
same language, both Android clients start on the external one. A sidecar is cut
for one release of the title, so it drifts against the picture; the track inside
the file cannot.
playback.prefer_embedded_subtitles(settings contractrevision 17, shipped server-side) lets a profile ask for the other one. This
pull request wires it through both clients: the flag reaches every
auto-selection site on phone and TV, and both settings screens expose the
switch.
Approach
The flag is threaded exactly where
playback.show_forced_subtitlesalreadyruns, and it re-ranks only one thing: the source tier, and only inside a single
track class. Five behaviours hold with the preference on:
external English one for a viewer who asked for English.
not full dialogue, so it cannot become the default while a full one exists.
sidecar for an embedded PGS.
The ranking is mirrored in the shared resolver (
AutoSubtitleContext), in TV'sresolveTvAutoSubtitleSelection/resolveTvAutoSubtitleIdentity, and in thephone's own cascade. The tiers mirror rather than list: an external sidecar
drops to the embedded track's place, embedded rises to the sidecar's, and a
downloaded subtitle — which the server can re-time — keeps its place either way.
TV's detail page resolves the same preference the player uses, so the Auto pill
previews the track playback will start on. Offline playback on the phone gets it
too, via
OfflineSubtitlePreferences.The phone's private cascade leads with a forced track when "show forced" is on,
which the shared resolver does not do. That divergence predates this setting and
is left alone; the new tests pin that the preference does not move that answer.
The vendored settings contract fixtures are re-copied from the server at
eb55481, soSettingsConformanceTestkeeps the manifest revision, thefixture, and the generated
SettingKeys.REVISIONin agreement.Validation
BUILD SUCCESSFUL — 1603 shared, 814 phone, 1210 TV tests, no failures. The same
two compile tasks, run together, are also BUILD SUCCESSFUL.
Tests cover the ranking on the shared resolver, the phone cascade, the offline
inventory, TV's launch-time fallback, and TV's Auto pill; plus the settings
viewmodels on both apps (canonical load, optimistic rollback, and a device
override narrowing the switch back). Each new case asserts one of the five
invariants above, and each suite pins its OFF behaviour against the answer it
gave before. The phone forced-track case also pins the pre-existing short
circuit described under Approach.
Not run:
./scripts/test-check-build-supply-chain.sh,./scripts/check-build-supply-chain.sh,lintDebug,lintVitalRelease,assembleDebug, and manual playback on a real deployment. No screenshots orrecordings are attached.
Risks
Off by default, and a server before contract revision 17 sends no field, which
reads as off — so no existing viewer moves. The setting is canonical-only: the
server resolves it, the clients mirror nothing into
user_profiles, and bothsettings screens show the effective value rather than the value the PUT stored,
so a
profile_devicerow that narrows the choice is visible. The player startcontract is unchanged; subtitle ordinals remain identity, so only Auto's choice
among them shifts.
Checklist
AI Disclosure
this change; the validation above is the author's own test run.
Note
Add embedded-subtitle track preference to playback subtitle auto-selection
playback.prefer_embedded_subtitlesboolean profile setting (settings contract revision 17), exposed throughProfileSettingsControllersnapshots and the settings writer in ProfileSettingsController.ktresolveAutoSubtitleresolver in AutoSubtitleResolver.kt now ranks candidates by source (embedded > downloaded > external) when the preference is on. Source ranking applies only within an already-selected language and subtitle class, so language, forced, hearing-impaired, and bitmap precedence is unchangedWatchDetailcarries the server-resolved value into playback-start results and player state on both platforms, so selection, offline playback, and TV subtitle previews all use the same resolved preferenceMacroscope summarized 576dee6.