Repository navigation
Conversation
Note: SiloMac does not currently build on this machine (pre-existing Nuke swiftmodule incompatibility, also present on clean main), so this change is syntax-checked but not compile-verified.
Point sizes now scale against the video rect (1080-line playfield) instead of the full screen, which shrank the effective render size. Rebase the ladder ~1.4x on all platforms.
BorderStyle 3 fills its per-glyph-run box with OutlineColour at full opacity, so the user's background opacity (carried in BackColour) was ignored and the box always rendered opaque. Switch to libass BorderStyle 4: one background rect per event, filled with BackColour (alpha honored), padded via the Shadow field. Also give the drop-shadow style a visible 50% black shadow — its BackColour alpha was previously fully transparent, rendering no shadow at all.
…A order ASS_Style struct colors use libass's internal byte-swapped format (0xRRGGBBAA, inverted alpha in the low byte), not the ASS file format. The old (alpha<<24)|BGR packing put the box opacity byte in the red channel, so the translucent black default box rendered as opaque dark red once BorderStyle 4 started drawing BackColour. Also remove the compositor's dual-format color fallback: it existed to rescue those mispacked colors (documented read looked transparent, AABBGGRR read looked right) and could resurrect genuinely faded-out glyphs as opaque. With the packing fixed, the documented RRGGBBTT read is always correct.
…e CoreMedia path
The CoreMedia player demuxes subtitle packets in-band with video/audio
from a single forward-only demuxer that runs tens of seconds ahead of
the playhead; packets for unselected subtitle streams are discarded.
Enabling a track mid-playback only routed future packets — no seek —
so no cues appeared until the playhead crossed the toggle-time demux
head ("the buffer plays through").
Route runtime embedded selections through the existing
AVPlayerEmbeddedSubtitleExtractor instead: a dedicated subtitle-only
FFmpeg context that seeks to playhead-5s and feeds libass immediately,
throttled to 45s of read-ahead (same mechanism the AVPlayer route
already uses). The in-band pipeline still serves selections made during
open, where the demux head is at the playhead.
- extractor: configure(probe:) to skip track enumeration, stopFeeding()
to release a slot without closing its libass track,
selectedStreamIndex(for:) for selection state
- PlayerCore: lazy per-load extractor, re-seek on performSeek's final
target, teardown on load reset + media teardown, selection state
unified across both feed mechanisms for track list + stats HUD
…wPTS The initial subtitle selection on a resumed playback races openAndDemux: the playback clock isn't anchored to the resume position until buffering primes, so the extractor read ~0 and fed cues from the start of the file — no subtitles until the user scrubbed (which re-selected at the real target). Use max(clock, pendingSkipBelowPTS), the same guard performAudioTrackSwitch uses for the identical race, for both the select start position and the extractor's read-ahead throttle clock.
…reMedia pump) Disabling a track drops it from libass without a final render pass, and the CoreMedia overlay pump bailed out when no track was active — so whatever cue was composited on the CALayer at disable time stayed on screen indefinitely. Clear the overlay while no track is active, exactly as the AVPlayer route's pump already does; the per-tick clear also covers an in-flight session-queue render re-pushing a stale image just after the drop.
Explicit subtitle picks are persisted server-side, but the detail screens held the selection in per-visit @State and always reopened on "Auto" — the override looked lost on re-entry (audio was immune only because its selector falls back to the per-version effectiveAudioTrackIndex). Carry the watch detail's effective subtitle mode + track signature on ItemDetail during playback enrichment, re-match the signature against the displayed version's track list (same scoring as the player's SubtitleAutoResolver), and seed the selector state after each detail load — including next-up episodes and the post-player refresh, so a track picked inside the player shows up when the player dismisses. Seeded picks also flow to playback launch as an explicit index, making restore exact instead of relying on the in-player fuzzy match.
|
Warning Review limit reached
Next review available in: 53 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 (3)
📝 WalkthroughWalkthroughThis PR updates subtitle styling, sizes subtitle overlays from the displayed video rect, adds runtime embedded-subtitle switching, restores server-persisted subtitle selections in detail screens, and adjusts test project settings. Supporting tests cover subtitle styling and video rect computation. ChangesSubtitle Redesign, Latency, and Override Restore
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant PlayerCore
participant PlayerSurfaceHostView
participant SubtitleOverlayView
participant SubtitleRenderer
participant VideoDisplayRect
PlayerCore->>PlayerCore: publishVideoPresentationSize()
PlayerCore->>PlayerSurfaceHostView: onVideoPresentationSizeChange(size)
PlayerSurfaceHostView->>VideoDisplayRect: compute(videoSize, bounds, gravity)
PlayerSurfaceHostView->>SubtitleOverlayView: set frame / videoInsets
SubtitleOverlayView->>SubtitleRenderer: updateFrameSize(videoInsets)
PlayerCore->>SubtitleRenderer: renderOnSessionQueue(videoInsets)
sequenceDiagram
participant ItemDetailView
participant ItemDetailViewModel
participant DetailPlaybackFormatting
participant AVPlayerEmbeddedSubtitleExtractor
participant PlayerCore
ItemDetailView->>ItemDetailViewModel: loadDetail / enrichPlaybackMetadata
ItemDetailViewModel-->>ItemDetailView: ItemDetail(effectiveSubtitleMode, effectiveSubtitleTrackSignature)
ItemDetailView->>DetailPlaybackFormatting: serverPreferredSubtitleIndex(version, signature, mode)
DetailPlaybackFormatting-->>ItemDetailView: preferredSubtitleTrackIndex
PlayerCore->>AVPlayerEmbeddedSubtitleExtractor: configure(source, probe:false)
PlayerCore->>AVPlayerEmbeddedSubtitleExtractor: select anchored embedded track
AVPlayerEmbeddedSubtitleExtractor-->>PlayerCore: selectedStreamIndex(slot)
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
Need to run one last validation on tvOS |
There was a problem hiding this comment.
Actionable comments posted: 2
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/CoreMedia/PlayerCore.swift (1)
3490-3503: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPublish the presentation size on the MPEG2/software path
setupSoftwareVideoDecoder(...)only opens the decoder context, soPlayerSurfacekeeps seeing.zeroand subtitles fall back to full-bounds sizing for MPEG2 streams. Initialize and publish the video presentation size before returning from this branch.🤖 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/CoreMedia/PlayerCore.swift` around lines 3490 - 3503, The MPEG2 software decode branch in PlayerCore is returning after only opening the decoder, so the presentation size never gets published and PlayerSurface stays at .zero. Before calling setupSoftwareVideoDecoder(codecpar:codecparPtr:), initialize and publish the video presentation size using the codecpar dimensions in this AV_CODEC_ID_MPEG2VIDEO case, following the same pattern used by the hardware paths so subtitles and layout can size correctly.
🤖 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/DetailPlaybackFormatting.swift`:
- Around line 220-255: The bestSignatureMatch logic in DetailPlaybackFormatting
and SubtitleAutoResolver can pick a subtitle track even when there is no
meaningful match signal. Update bestSignatureMatch so it only returns a
candidate when at least one strong indicator matches, such as language, label,
or an explicit non-default metadata match, instead of awarding points for
default false-to-false forced/hearingImpaired equality. Keep the scoring in
SubtitleAutoResolver and this DetailPlaybackFormatting helper aligned so both
paths require a real signal before selecting a track.
In `@iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift`:
- Around line 107-114: The `videoPresentationSize` update in
`PlayerCore.publishVideoPresentationSize()` is happening off-main while
`PlayerSurfaceHostView.attach(player:)` reads the same property on the UI
thread, creating an unsynchronized shared access. Move the stored-property
assignment for `videoPresentationSize` into the existing
`DispatchQueue.main.async` block so both the write and the
`onVideoPresentationSizeChange` callback run on main.
---
Outside diff comments:
In `@iosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swift`:
- Around line 3490-3503: The MPEG2 software decode branch in PlayerCore is
returning after only opening the decoder, so the presentation size never gets
published and PlayerSurface stays at .zero. Before calling
setupSoftwareVideoDecoder(codecpar:codecparPtr:), initialize and publish the
video presentation size using the codecpar dimensions in this
AV_CODEC_ID_MPEG2VIDEO case, following the same pattern used by the hardware
paths so subtitles and layout can size correctly.
🪄 Autofix (Beta)
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: b32e97c8-42ff-4783-ad90-20a777c483b6
📒 Files selected for processing (16)
iosApp/Tests/SubtitleStylingOverrideTests.swiftiosApp/Tests/VideoDisplayRectTests.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Detail/DetailPlaybackFormatting.swiftiosApp/iosApp/Screens/Detail/ItemDetailView.swiftiosApp/iosApp/Screens/Detail/ItemDetailViewModel.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerCore.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerSurface.swiftiosApp/iosApp/Screens/Player/Subtitles/AVPlayerEmbeddedSubtitleExtractor.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleAppearance.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleRenderer.swiftiosApp/iosApp/Screens/Player/Subtitles/SubtitleStylingOverride.swiftiosApp/iosApp/Screens/Player/Subtitles/VideoDisplayRect.swiftiosApp/iosApp/macOS/PlayerSurface.swiftiosApp/iosApp/tvOS/Screens/Detail/TVItemDetailView.swiftiosApp/project.yml
…er box - tvOS overlays now cover the full frame and pass the video rect to libass via ass_set_margins; the Bottom preset enables use_margins so regular cues render below the picture in the letterbox bar (60px off the frame edge), and Lower Third takes Bottom's old anchor at the video's bottom edge. Native ASS and the secondary slot stay inside the video area. iOS/macOS placement unchanged. - Rebase the tvOS font-size ladder ~1.3x (Large is now the old X-Large+). - Halve subtitle box padding on iOS and tvOS.
- Require a strong signal (language or label match) before bestSignatureMatch returns a candidate, in both the detail seeding and player auto-resolver paths. Forced/HI/codec equality alone is meaningless (false == false holds for nearly every track) and could hijack Auto with an arbitrary first track. - Main-confine PlayerCore.videoPresentationSize: compare-and-assign inside the main hop instead of writing from the demux/control path, matching the UI-thread read in PlayerSurfaceHostView.attach.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bb1550892
ℹ️ 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".
| // this slot. | ||
| if let newId, SubtitleTrackIdSpace.isSidecar(newId) { | ||
| embeddedSubtitlePipeline.tearDownEmbeddedSlot(slot: slot) | ||
| runtimeSubtitleExtractor?.stopFeeding(slot: slot) |
There was a problem hiding this comment.
Clear stale runtime captions before opening sidecars
When the current subtitle was selected through the new runtime extractor (for example after a mid-playback embedded-track toggle), stopFeeding only cancels that extractor generation and deliberately leaves the libass track installed. openSidecar fetches asynchronously and only replaces the slot once the sidecar content arrives, so switching to an uncached or failing sidecar can keep rendering the old embedded captions during the fetch or indefinitely on failure; the AVPlayer route clears the extractor slot before opening a sidecar. Clear/close the slot before starting the sidecar fetch.
Useful? React with 👍 / 👎.
Conflict in AVPlayerBackend.pumpSubtitleOverlay: kept this branch's text/bitmap split (textOverlayMayHaveFrame + pumpBitmapCues) and grafted in main's videoInsets plumbing to renderOnSessionQueue. Semantic follow-through: main's a8fd931 makes the tvOS subtitle overlay full-frame (video rect communicated via videoInsets), which broke this branch's assumption that overlay bounds == videoRect for bitmap cue placement. pumpBitmapCues now maps normalized PGS/DVD cue rects into the video rect derived from the insets (zero on iOS/macOS, so unchanged there), and the render key tracks the video rect instead of raw bounds. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0146hwg1Q15YdeUhd9f37NWA
Closes #53.
Holistic subtitle appearance redesign for the Apple clients plus a batch of playback-toggle and preference-restore fixes surfaced during on-device testing.
Appearance
PlayerCoreand add aVideoDisplayRectaspect-fit helper.largematches the oldxxlarge, consistent across platforms.BorderStyle 4; pack override-style colors in libass internalRRGGBBAAorder (fixes the default box rendering as opaque dark red).Mid-playback toggle
AVPlayerEmbeddedSubtitleExtractorso enabling a track mid-playback is near-instant instead of waiting for the buffered region to drain.pendingSkipBelowPTSso a selection applied before the playback clock is primed feeds from the right position (fixes "no subtitles until I scrub").Preference restore
ItemDetail, re-match against the displayed version's tracks (same scoring as the player'sSubtitleAutoResolver), and seed the detail-screen selector + playback launch index after each load, on next-up episodes, and on the post-player refresh. The remembered subtitle track now shows on re-entry instead of reverting to "Auto".Testing
Silo) and tvOS (SiloTV) build clean;SiloTestsfull suite green (339 tests) at the time of the toggle work.SiloMacNuke swiftmodule build breakage is unrelated and deferred.Related
Summary by CodeRabbit
New Features
Bug Fixes
Tests