Repository navigation
Conversation
…urces A 2.39:1 image mastered inside a 1920x1080 frame is a 16:9 video to every layer of the stack, so `AVPlayerLayer.videoRect` (and the CoreMedia equivalent) covers the full height and a bottom-anchored cue renders inside the black bar instead of over the image. Nothing in the container reveals the bars — only the pixels do — so the server measures them with cropdetect and publishes fractions of the frame height on the playback session response. Decode those, and inset the displayed video rect by them before the subtitle overlay is keyed to it. On tvOS that is the libass margin the "Bottom" preset positions against; on iOS/macOS it is the overlay frame itself. Only applied under `.resizeAspect`. The fill/zoom gravities crop the frame by an amount this code cannot see, so the bars that survive on screen are smaller than the fractions describe and insetting by the full amount would push cues into the picture — worse than the problem being fixed. Those modes keep today's behaviour. Fractions are clamped client-side as well as server-side: a bad measurement must not be able to place subtitles mid-picture, and a bar under 2% is rounding noise rather than a letterbox. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
|
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 (7)
📝 WalkthroughWalkthroughChangesBaked-in top and bottom letterbox fractions are decoded from playback sessions, stored in Baked letterbox geometry and session contract
Player state and rendering wiring
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PlaybackSessionResponse
participant PlayerViewModel
participant PlayerView
participant PlayerSurface
participant VideoDisplayRect
participant SubtitleOverlay
PlaybackSessionResponse->>PlayerViewModel: decode letterboxTopFraction and letterboxBottomFraction
PlayerViewModel->>PlayerView: publish bakedLetterbox
PlayerView->>PlayerSurface: pass bakedLetterbox
PlayerSurface->>VideoDisplayRect: calculate pictureRect
VideoDisplayRect-->>PlayerSurface: return adjusted picture rectangle
PlayerSurface->>SubtitleOverlay: position overlay within picture rectangle
Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/PlayerViewModel.swift`:
- Around line 2995-2998: Convert both PlaybackSessionResponse letterbox fraction
values to CGFloat when constructing BakedLetterbox at
iosApp/iosApp/Screens/Player/PlayerViewModel.swift:2995-2998 and 4088-4091,
covering the fresh-load and transcode-restart call sites. Update the topFraction
and bottomFraction arguments without changing other behavior.
🪄 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: bc8f45e7-17ad-4e57-8182-4c887e536ca1
📒 Files selected for processing (10)
iosApp/Tests/VideoDisplayRectTests.swiftiosApp/iosApp/Networking/Models.swiftiosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerSurface.swiftiosApp/iosApp/Screens/Player/CoreMedia/PlayerSurface.swiftiosApp/iosApp/Screens/Player/PlayerView.swiftiosApp/iosApp/Screens/Player/PlayerViewModel.swiftiosApp/iosApp/Screens/Player/Subtitles/VideoDisplayRect.swiftiosApp/iosApp/macOS/AVPlayerSurface.swiftiosApp/iosApp/macOS/PlayerSurface.swiftiosApp/iosApp/macOS/PlayerView.swift
…itle-inset # Conflicts: # iosApp/iosApp/Screens/Player/AVPlayerRoute/AVPlayerSurface.swift # iosApp/iosApp/macOS/AVPlayerSurface.swift # iosApp/iosApp/macOS/PlayerSurface.swift
|
Closing with Silo-Server/silo-server#483. This implementation depends on server-provided static fractions; we want the Apple clients to own detection and layout based on the media they actually render. The client-side geometry and subtitle-placement problem remains valid, but it should be reimplemented without a server-contract dependency and validated across protocol V3 and legacy playback, AVPlayer and CoreMedia, iOS, macOS and tvOS, changing-aspect content, and HDR or protected playback surfaces. |
Problem
A 2.39:1 image mastered inside a 1920x1080 frame — routine on WEB-DL sources — is a 16:9 video as far as the container, the decoder, and
AVPlayerLayerare all concerned.videoRecttherefore covers the full height of the frame, and a bottom-anchored subtitle renders inside the baked-in black bar rather than over the picture. On a TV that reads as subtitles floating in the void below the image.Nothing in the file's metadata reveals this; only the pixels do.
Approach
The server measures the bars with
cropdetect(sampled across the runtime, intersected so a fade-to-black can't be mistaken for a bar) and publishes them as fractions of the frame height on the playback session response —letterbox_top_fraction/letterbox_bottom_fraction. Server side: Silo-Server/silo-server#483 — this PR needs it to land first, and degrades to today's behaviour without it.This PR decodes those fractions and insets the displayed video rect by them before the subtitle overlay is keyed to it:
BakedLetterboxandVideoDisplayRect.pictureRect(in:letterbox:gravity:)live alongside the existingSubtitleVideoInsetsgeometry inVideoDisplayRect.swift; both AVPlayer-backed and CoreMedia-backed surfaces on all three platforms go through them.Deliberate limits
.resizeAspect. The fill/zoom gravities crop the frame by an amount this code cannot see, so the bars that survive on screen are smaller than the fractions describe — insetting by the full amount would push cues into the picture, which is worse than the bug being fixed. Those modes keep today's behaviour. Handling them properly needs the presentation size at the inset site; worth doing as a follow-up if anyone plays letterboxed content zoomed.Alignment
Matches the Android client, which consumes the same fractions off the v3 plan's source descriptor and applies them via
SubtitleManager.letterbox. Apple does not speak protocol v3, which is why the server publishes the same measurement on the v2 session response.Testing
xcodebuild buildgreen on all three schemes:Silo(iOS Simulator),SiloTV(tvOS Simulator),SiloMac(macOS).VideoDisplayRectTests.swiftcovering the inset geometry, the fill-gravity carve-out, asymmetric bars, and the clamping — passing alongside the existing suite.(1080 − 1920/2.39) / 2 / 1080) and cues moved onto the picture. The Apple side of this change has not yet been run on a device or simulator against a live server — it is the same measurement and the same arithmetic, but that verification is still outstanding.AI-use disclosure
Written by Claude Opus 5 (Claude Code) working with @RXWatcher, who reviewed the change, directed the approach, and ran the on-device verification described above.