Skip to content

fix(tv): draw ASS subtitles over the whole video, not the title-safe area - #1012

Open
Rhainland wants to merge 4 commits into
Silo-Server:mainfrom
Rhainland:fix/tv-libass-overlay-full-frame
Open

Rhainland wants to merge 4 commits into
Silo-Server:mainfrom
Rhainland:fix/tv-libass-overlay-full-frame

Conversation

@Rhainland

@Rhainland Rhainland commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: unblocks #324 C4; unblocks #323 C4
Paired pull requests (same report): Silo-Server/silo-server#4639, Silo-Server/silo-server#4640, Silo-Server/silo-server#4641, Silo-Server/silo-server#4642, #1010, #1011, #1013, Silo-Server/silo-apple#1237, Silo-Server/AetherEngine#30

Other clients: Apple N/A (Apple does not render ASS through this libass overlay or inset it to a title-safe canvas); Roku N/A (no libass overlay); Web N/A (no libass overlay)

On Android TV, ASS signs and positioned lines did not appear where the script puts them. The libass overlay is a child of Media3's caption canvas, and the TV insets that canvas by a 5% title-safe margin (96 px left and right, 54 px top and bottom at 1080p), so libass scaled the whole script into the inset frame: a sign at the frame's corner landed 96 px and 54 px inside it, and the script's layout no longer lined up with the picture. A detected letterbox narrowed the frame the same way.

Approach

The title-safe inset stays for Media3's text and bitmap cues. The libass overlay is now placed over the displayed video rectangle, in the canvas's own coordinates, and the canvas and the content frame stop clipping while the overlay reaches past the canvas. libass positions events in the script's PlayRes space with the script's own margins, so it needs the video's frame. This replaces the Bottom-preset height constraint: the overlay keeps the video's frame instead of following the canvas into the letterbox bar.

Two padding cases keep their old effect:

  • While the TV controls are up they pad the canvas's bottom so text cues rise above them. A padded canvas clips to its padding on every side, which would cut the overlay at the title-safe inset again, so that clip is off and the overlay gets its own clip that hides only what is below the lifted bottom. Bottom ASS lines are hidden while the controls show, instead of the whole script being squeezed above them as before.
  • The phone pads the canvas's right side while a player menu is docked. A padded side still bounds the placed overlay, so ASS re-centres in the visible picture as it did.

The overlay's params are written from the content frame's layout listener, so a change to them now also has the canvas laid out again through the existing request-then-place path.

Validation

  • ./scripts/test-check-build-supply-chain.sh and ./scripts/check-build-supply-chain.sh: pass.
  • ./gradlew testDebugUnitTest: pass, including table tests of the overlay rectangle (title-safe canvas, Bottom canvas in the bar, docked-menu padding) and the controls clip.
  • :android-shared:lintDebug :androidApp:lintDebug :androidTvApp:lintDebug :androidApp:lintVitalRelease :androidTvApp:lintVitalRelease: pass.
  • :androidApp:assembleDebug :androidTvApp:assembleDebug: pass.
  • Played the synthetic "ASS Edges (2021)" file, which places labels at the frame's corners and edges, on an Android TV emulator with main and this branch (with the review follow-ups), with the controls hidden and shown (captures below).

Evidence

Evidence: https://evidence.siloserver.org/r/silo-android/pr-1012/

Surface and build: Android TV emulator (Android 14, 1080p) and Android phone emulator (Android 16, landscape), debug builds of main and this branch. On the phone, the letterbox file kept the canvas on the full video frame, so the overlay takes the fill path and the captures (menu closed and docked) look the same before and after; the letterbox-inset and Bottom-in-the-bar placement paths, and the docked-menu bound on them, are covered by the geometry tests. Tablet and foldable use the same phone code path and were not captured.

Risks

While the TV controls are up, ASS lines in the band the controls cover are hidden rather than squeezed above them. On TV, whenever libass is available, the caption canvas no longer clips its children, so a Media3 cue box positioned at the very edge can draw into the title-safe margin.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code, Codex CLI (review only)
  • Model(s): claude-opus-5-5 (author and reviewer); gpt-6.2-sol and gpt-6.2-astra via Codex CLI, Claude Fable 5.2 (reviewers)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: three rounds of a four-model review (Sol, Astra, Opus, Fable) on the branch diff. Fixed: the placed overlay ignored the phone's docked-menu padding; the overlay's new params could wait for a layout that never came, including when that placement was deferred; RTL gravity; the bridge's sentinel arguments and test placement. Kept as designed and noted under Risks: hiding instead of squeezing ASS under the TV controls. Dismissed: Zoom crop scaling to the visible viewport (unchanged from before).

Note

Fix ASS subtitle overlay to cover the whole video, not the title-safe area

Positions the libass overlay over the full video rectangle in canvas coordinates instead of constraining it to the inset caption canvas. New geometry helpers in SubtitleManager.kt translate the video rect into the canvas and clip only the portion hidden below the controls lift (bottom padding).

  • LibassBridge.placeOverlay now sets overlay width, height, and margins from the derived rectangle; fillHost restores match-parent sizing for the fallback path (see LibassBridge.java).
  • Overlay drawing can extend beyond the caption canvas: SubtitleVideoRectSync.setCanvasClipping disables child clipping on the subtitle view when the overlay overflows it.
  • applyLayoutParams and placeSubtitleCanvas force a relayout when overlay layout parameters change, even if the canvas bounds are unchanged.
  • Adds unit tests for overlay geometry and controls-lift clipping in LibassOverlayGeometryTest.kt.

Macroscope summarized 1cdb13b.

…canvas

On Android TV the libass overlay was cut 96 px left and right and 54 px
top and bottom on a 1920x1080 screen, so signs an ASS script places near
the frame edges were clipped. The overlay is a child of Media3's
SubtitleView, and the TV insets that caption canvas by a 5% title-safe
margin (titleSafeFraction = 0.05f), so libass was handed the inset frame.

The title-safe inset stays for Media3 text and bitmap cues. The libass
overlay is now placed over the displayed video rect in the canvas's own
coordinates, and the canvas and content frame stop clipping it while it
reaches outside the canvas. libass positions events in the script's
PlayRes space with its own margins, so it needs the video's frame. This
also replaces the Bottom-preset height constraint: the overlay keeps the
video's frame instead of following the canvas into the letterbox bar,
and no longer takes the detected-letterbox inset either.
With the playback controls showing, the TV pads the bottom of the caption
canvas so text cues sit above the controls. A padded view clips its
children to the padded area on every side, so the full-video libass
overlay was cut at the title-safe inset again: signs at the left, right
and top edges were sliced 96 px and 54 px in, mid-word, until the
controls hid.

While the overlay reaches past the canvas, the canvas now stops clipping
to its padding as well as to its bounds. The overlay instead gets its
own clip that hides only what lies below the lifted bottom, so ASS still
stays out from under the controls as it did before.
…ked menu

The phone pads the caption canvas's right side while a player menu is
docked, so cues re-centre in the part of the picture left visible.
Before the overlay was placed over the whole video it filled the
padded canvas and followed. A placed overlay has an explicit width, so
ASS kept the full video width and was cut at the menu's edge or drawn
under it. A padded left or right side now bounds the placed overlay
as it bounds Media3's cues.

The overlay's params are written from the content frame's layout
listener, after the canvas has been laid out, so a change to them now
also has the canvas laid out again (the same request-then-place path
the canvas itself uses) instead of relying on a later pass.

The bridge takes the bottom clip as one visible height and has a named
reset (fillHost) instead of sentinel arguments, and the overlay
geometry tests live in their own class.
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe186b74-956f-4dbc-9c3c-fe9f41a49ed0
Commits

Reviewing files that changed from the base of the PR and between 1b4732d and 1cdb13b.

Files selected for processing: 3

  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/SubtitleManager.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/LibassOverlayGeometryTest.kt
  • libass-bridge/src/main/java/org/siloserver/silo/libass/LibassBridge.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-kody

silo-kody Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@macroscopeapp

macroscopeapp Bot commented Nov 20, 2026

Copy link
Copy Markdown

The Evidence section is still marked “pending upload,” so no playback captures are available. The shared playback code changes ASS subtitle placement relative to the video frame (and its clipping while TV controls are shown); this reaches Android phone, tablet, foldable folded and open, and Android TV. Please provide before-and-after captures of the same playback and media on each device, showing the affected letterbox/Bottom placement on the phone app and the edge-positioned subtitles with TV controls hidden and shown on TV; identify the device and build/commit for every capture. The geometry tests do not replace these visible-change captures.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish labels Nov 20, 2026
@silo-triage

silo-triage Bot commented Nov 20, 2026

Copy link
Copy Markdown

The Evidence section says this also changes phone subtitle placement when letterboxing is detected or the Bottom preset reaches into the bar. Geometry tests do not show that visible change. Please add before-and-after playback captures for those cases on an Android phone, tablet, and foldable (folded and open), identifying the build for each; for any device you omit, explain why the change cannot reach it.

… fill it

The fill path ignored whether fillHost changed the overlay's params, so
an overlay leaving its full-video placement could keep its old bounds
until some later layout. Pass the result as childrenChanged, as the
placed path already does.
@silo-kody

silo-kody Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌
⚠️ 5 Kody Rule(s) were not evaluated

These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:

  • Validate download ownership before publishing subtitle bytes
  • Bind playback markers to the actual playing file
  • Share route-aware audio decisions and preserve original-format decoder fallback
  • Apply playback route eligibility consistently at admission and media loading
  • Serialize cache read-modify-write operations

@macroscopeapp

macroscopeapp Bot commented Nov 20, 2026

Copy link
Copy Markdown

The linked evidence covers Android TV, but playback evidence is still missing for the phone app. SubtitleManager.kt is shared with phone, tablet, and foldable playback; its overlay placement changes for letterboxed video and the Bottom preset, and phone docked-menu padding also affects placement. Please add before-and-after captures of the same affected playback on an Android phone, tablet, and foldable (folded and open), with the device and build identified. Geometry tests do not show these visible changes.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@Rhainland

Copy link
Copy Markdown
Contributor Author

Evidence is published at https://evidence.siloserver.org/r/silo-android/pr-1012/ (the body said "pending upload" briefly while it went up). It now includes Android phone captures of the synthetic letterbox file, with the player menu closed and docked, on main and this branch. On that emulator the canvas stayed on the full video frame, so the phone takes the unchanged fill path and looks the same before and after. Placement on letterbox-inset and Bottom-in-the-bar canvases, including the docked-menu bound, is covered by the geometry tests. Tablet and foldable run the same phone code and were not captured separately.

@Quick104

Copy link
Copy Markdown
Contributor

Review summary

Reviewed head: 1cdb13b4836603f3ad5d4a1a98f2e2bfeaedb3b9

Fit: 8/10 · Readiness: 8/10 — conditional (CI is green)

I found no verified defect in this PR. Drawing libass over the whole video is how ASS is meant to render: scripts position events in the video's own PlayRes space, so the title-safe inset was cutting off signs placed near the frame edges. The canvas math, the FrameLayout padding-plus-margin offset, the controls-lift clip, the docked-menu bound and the forced relayout all trace correctly through their callers in both apps. setClipBounds on AssSubtitleView covers both ass-media renderers, because the view is a FrameLayout that wraps either the canvas view or the TextureView.

Fit. This fixes a real rendering bug in a core playback path, and it leaves Media3's text and bitmap cues alone. It stretches the boundary, though. The overlay stays a child of Media3's caption canvas and works around that canvas's insets with negative margins, clipping turned off on three views, a clip rect for the controls lift, and forced relayouts. If the overlay were a sibling of SubtitleView inside exo_content_frame, which already is the video's frame, most of that would go away, and the Zoom crop below would be fixed at the same time. That would be a follow-up, not a reason to hold this PR: the current version was checked on a device, and a rework would need the same TV, controls-lift and docked-menu checks again.

Readiness. Holding it at 8: this review didn't reproduce the bug live. The author's TV captures show the change. The phone letterbox and Bottom-in-the-bar paths are covered only by the new geometry tests, and those tests call helpers this PR adds, so they can't fail on the base.

Candidates checked and not kept

  • Clipping is off for the whole TV session whenever libass is available, even with no ASS track. That's real, and the PR's Risks section already says so. The content frame's parent (the PlayerView) also loses its clip, although the overlay never leaves the content frame. I found no visible effect: Zoom only happens full-screen, and Next Up shrinks the player but forces Fit first. Gating the overlay on an active ASS render, or clipping only the frame, would narrow it.
  • The padding change might not re-run placement while the content frame's layout request goes unserviced (the hosting problem requestSubtitleLayout describes). Before this PR, Media3 cues and the overlay went just as stale in that state, because both needed a canvas layout. Not introduced here.
  • A deferred forced placement could use stale geometry. It can't: applyLayoutParams writes the new params and returns before placeSubtitleCanvas whenever the geometry changes, so a second call that reaches placement in the same pass has the same geometry.
  • dispose leaves the canvas unclipped. The AndroidView update block calls syncSubtitleVideoBounds again, which rebuilds the disposed sync and sets the canvas clip on both paths.
  • Under Zoom, the overlay covers only the visible crop. That predates this PR, and the author already weighed it. The new KDoc's "the whole displayed video" doesn't hold in that mode.
  • Nit: canvasPaddingLeft has no caller that sets left padding (the phone pads only the right, the TV only the bottom).

Tests

CI passes on this head. Locally, :android-shared:testDebugUnitTest --tests 'org.siloserver.silo.common.player.*' passes both LibassOverlayGeometryTest cases. One unrelated test, AndroidPlaybackJournalStoreTest, failed in the local environment; it passes in CI and this diff doesn't touch it.

Validated features

No case recorded as passed on the 1.0 board touches this code. The Validation tasks: line said changes #324 C4; changes #323 C4, but C4 hasn't been run on either task, so I've changed it to unblocks #324 C4; unblocks #323 C4. This fix is what lets the format-matrix check pass for ASS.

Other checks

  • User manual: unaffected. The subtitles page doesn't describe where ASS is drawn or how cues move with the controls.
  • Apple parity: the PR rules Apple out because Apple doesn't render ASS through this overlay. I didn't check that in the Apple source.
  • Cross-provider review, one round: Opus scored it 7/10 and Gemini 6.5/10. Sol didn't run (it failed to start twice). I checked Gemini's higher-severity points against the source, and none holds as a defect this PR introduces (see above).

🤖 Claude Code (claude-opus-5-5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working evidence-required Needs before-and-after evidence before the Evidence check passes impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants