Skip to content

fix(player): show one centered loading spinner on phone and TV - #696

Merged
Quick104 merged 2 commits into
mainfrom
fix/player-centered-spinner
Oct 26, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/player-centered-spinner

Conversation

@Quick104

@Quick104 Quick104 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #79 (replan loading state; this PR shows the spinner during a replan but adds no copy)
Validation tasks: not checked. The v1.0 board needs a token scope this session didn't have; a reviewer should check player loading and stall cases.

Loading and buffering looked different on each Android surface:

  • Phone: a centered spinner with no delay. When the controls were up, they covered it.
  • TV: a top-right "Buffering" capsule, a separate spinner for reconnects, and a different full-screen spinner for the session request.

Apple and Roku are moving to the same behavior in companion PRs, so every client shows loading the same way.

Approach

  • One indicator: an unlabeled spinner, centered, with "Loading" for TalkBack. It covers the session request, the first buffer, a rebuffer, a seek that waits for data, and a reconnect. It shows after 500 ms and stays at least 500 ms. Phone and TV share this timing through rememberPlayerSpinnerVisible in android-shared.
  • Phone: the spinner follows the session request too, including one that keeps the old picture up (a version switch or Next Up). While the controls show, the spinner takes the play disc's place, and that slot still plays and pauses. While they're hidden, the spinner sits alone in the center. In tabletop posture it stays on the video pane, and on Up Next it sits in the video frame.
  • TV: the capsule, the reconnect spinner and the loading screen become the one centered spinner. While the HUD is open it sits below the card.
  • First load: the controls come in at the item's first frame. A mount with audio and no video uses its first play instead. Both milestones are checked against the mount, so a late callback from the outgoing item can't release the next one. Until then the screen is black with the spinner. Back exits, and on TV the D-pad ignores keys as it already did during the session request. The rule keys on the content id, so a retry, session renewal, reconnect or replan of the same item never hides the controls. The TV's auto-hide timer starts at the first frame.
  • Kept: the buffering quality pill, the Reconnecting notice and the Watch Party pill.

Validation

  • assembleDebug builds for both apps. With the default 2 GB heap, compiling TvPlayerScreen.kt runs out of memory, on main too; it builds with a 6 GB Kotlin daemon heap.
  • Player and picture-in-picture unit tests pass: phone 292/292, TV 481/481. TvPlayerVisibilityPolicyTest is removed because it only covered the deleted reconnect-spinner helper.
  • Phone and Android TV emulators, before and after: stalls with the controls hidden and shown (network off, then a seek past the buffer). First load after the change: no controls until the first frame, and TV key presses during the load are ignored.

Evidence

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

Surface and build: debug builds of main and this branch on API 36 emulators: phone (landscape), tablet, foldable (open and folded) and Android TV (1080p). Before and after: first load, and a stall with the controls hidden and shown. After-only recordings on phone and TV show the first load, the controls arriving with the first frame, and a stall. Not captured:

  • Tabletop: the emulator's half-open posture kept a vertical hinge in landscape, so the tabletop split never appeared.
  • Picture-in-picture, Watch Party, a stall during Up Next, and an audio-only item: not checked.

Risks

  • The recordings show the 500 ms delay only roughly, because the emulator renders too few frames to measure it.
  • On TV, with the HUD open, the spinner sits below the tallest possible card even when the open tab is shorter.
  • Not exercised: a first load that ends in a retry, a session renewal, or a Next Up auto-advance.

Companion changes: Silo-Server/silo-apple#918, Silo-Server/silo-roku#41.

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 (T3 Code)
  • Tool(s): Claude Code subagents, Android emulator tooling
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; human verification pending
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Unify phone and TV player loading into one centered delayed spinner

Replaces the separate phone and TV loading indicators with a single spinner policy. A new rememberPlayerSpinnerVisible composable delays the spinner 500ms after loading starts and keeps it visible at least 500ms once shown.

  • The spinner centers on the video when controls are hidden, fills the play/pause disc when they are shown, and appears in the Next Up video pane. TV uses a 64dp spinner; phone uses 56dp.
  • Removes TvLoadingScreen, the TV top-right buffering capsule, and the shouldShowReconnectSpinner helper along with its unit test.
  • Adds startedContentId and awaitingFirstFrame to both view models. Audio-only playback now marks an item as started via new onAudioOnlyPlaybackStarted handlers, so it no longer waits for a video-frame callback. Transport controls, gestures, and remote input are blocked until the first frame or audio start.
  • Behavioral Change: PlayerOverlay now takes a spinnerVisible parameter instead of showBufferingIndicator; TV suppresses the spinner during picture-in-picture; loading state combines session loading, buffering, and reconnecting.

Macroscope summarized 51d03aa.

Loading and buffering looked different on each Android surface. The phone
showed a centered spinner with no delay, which the controls covered, and
showed the controls over black during the first load. The TV did the
same, with a top-right "Buffering" capsule and a separate reconnect
spinner.

Both apps now show one unlabeled spinner, centered, for the session
request, the first buffer, a rebuffer and a reconnect. It appears after
500 ms and then stays up at least 500 ms, using timing shared from
android-shared. On the phone it takes the play disc's place while the
controls show, and the slot still plays and pauses. On TV it stays
centered beside the transport and sits below the HUD card while the HUD
is open. Up Next draws it in its video frame on both apps.

A new item's first load shows only the spinner over black, and the
controls arrive with its first frame (or first play, for audio). On TV
the remote does nothing but Back until then, and the auto-hide timer
starts at the first frame. The state is keyed on the content id, so a
retry, renewal, reconnect or replan of the same item never brings it
back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 26, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T15:51:09.451008Z 51d03aa New commits
🔒 Security Review ✅ Completed 2026-10-26T15:50:41.862717Z 51d03aa New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 26, 2026
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

The phone and TV players now use shared delayed spinner visibility and accessible loading indicators. Both track when current content starts or renders its first frame. The TV player also gates remote input and transport controls until first-frame readiness.

Changes: Player loading experience

Layer / File(s) Summary
Shared spinner timing and presentation
android-shared/.../PlayerSpinnerVisibility.kt, androidApp/.../PlayerChrome.kt
Adds a shared spinner visibility helper with a 500 ms show delay and minimum visible duration. Adds a reusable loading spinner and optional disc state description.
Android player loading integration
androidApp/.../PlayerViewModel.kt, androidApp/.../PlayerScreen.kt, androidApp/.../PlayerOverlay.kt, androidApp/.../PlayerControls.kt, androidApp/.../PlayerNextUpScreen.kt
Tracks first-frame readiness and passes spinner visibility to the phone player’s initial, tabletop, control, overlay, and Up Next views.
TV first-frame readiness
androidTvApp/.../TvPlayerViewModel.kt, androidTvApp/.../TvPlayerScreen.kt
Tracks when content starts or renders its first frame. Remote input, transport overlay display, and the controls auto-hide timer wait for first-frame readiness.
TV loading spinner presentation
androidTvApp/.../TvPlayerScreen.kt, androidTvApp/.../TvPlayerVisibilityPolicyTest.kt
Consolidates loading, buffering, and reconnect presentation into a spinner, with placement rules for picture-in-picture, the HUD, and Up Next. Removes the buffering capsule and the previous reconnect-spinner visibility test.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~40 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant TvPlayerViewModel
  participant TvPlayerScreen
  participant rememberPlayerSpinnerVisible
  participant TvPlayerOverlays
  TvPlayerViewModel->>TvPlayerScreen: Publish playback and first-frame state
  TvPlayerScreen->>rememberPlayerSpinnerVisible: Pass loading state
  rememberPlayerSpinnerVisible-->>TvPlayerScreen: Return delayed spinner visibility
  TvPlayerScreen->>TvPlayerOverlays: Pass loading state and overlay context
  TvPlayerOverlays-->>TvPlayerScreen: Derive spinner visibility, excluding PiP
Loading

Possibly related PRs

Suggested labels: bug, impact: playback, evidence-required, size/XL

Suggested reviewers: rxwatcher

Merge Risk: Moderate · up to 51f5b

Initial video controls can become available before the picture appears, TV Play/Pause can bypass the first-load gate, and some phone session requests show no loading spinner. Resolve these playback-experience regressions before merging.

Security architecture risk: Low · up to 51f5b

The changes primarily affect playback presentation and when controls become available. No new privilege or authorization bypass was established. Callback ordering and recovery behavior remain only partially validated, so the assessment retains some uncertainty.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated changed scope is the active phone or TV playback presentation and its local input lifecycle. The shared spinner holds no credentials, performs no network requests, and writes no persistent state. Public-symbol and fanout signals alone do not establish broader tenant, service, or data-store exposure.

Trust Boundaries and Controls

  • observed — The TV readiness gate declines remote events rather than consuming them, so it is not a security enforcement boundary. Unconsumed events can continue through activity dispatch. Existing room handling independently reconciles external MediaSession play/pause and seek changes, providing counterevidence to a new watch-party authority bypass.

Resilience and Maintainability Implications

  • observed — Session failure containment remains separate from readiness. Phone exit invalidates pending loads and stops only an owned session. TV terminal recovery checks session identity and load generation before clearing playback state, and exit uses a session-qualified stop. The PR's readiness mutations do not replace these existing ownership controls.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: one centered loading spinner for phone and TV players.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the problem (inconsistent loading indicators on phone and TV), the approach (one shared centered spinner with 500 ms show delay and 500 ms minimum visibility via rememberPlayerS…
Full details: Description check

Explanation

The description states the problem (inconsistent loading indicators on phone and TV), the approach (one shared centered spinner with 500 ms show delay and 500 ms minimum visibility via rememberPlayerSpinnerVisible, first-frame gating of controls, and removal of the TV buffering capsule and reconnect spinner), validation, evidence, and risks. It matches the changeset in the raw summary, so it is not off-topic. Some elements of the description do not appear in the file summaries (companion Apple and Roku PRs, the 6 GB Kotlin daemon heap note), but these do not make the description unrelated to the changes.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@silo-triage silo-triage Bot added bug Something isn't working impact: polish Annoyance, cosmetic, or nice-to-have priority: P2 Limited scope, workaround exists, or polish labels Oct 26, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The private evidence link covers the phone and Android TV emulator builds, but the phone-app changes also reach tablets and foldables through the shared player screen; tabletop placement specifically applies on foldables. The PR says tablet and foldable captures were not made. Please add before/after captures for an Android tablet and a foldable both folded and open, or explain why the changed code cannot reach a particular device.

The first-frame handoff was refined in the latest commit, so a short recording would show that transition; the PR explains the recorder produced empty files, and this evidence remains unavailable for reviewer consideration.

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

Posted via Macroscope — Visible change evidence

Posted via Macroscope — Visible change evidence

@coderabbitai coderabbitai Bot added evidence-required Needs before-and-after evidence before the Evidence check passes impact: playback Can't play, stalls, or wrong media size/XL 500–999 added + deleted lines (all files); change volume, not priority. labels Oct 26, 2026
@silo-triage silo-triage Bot removed the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🔇 Additional comments: 1
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreen.kt-4463-4463: 1

4463-4463: Minor · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Move the TalkBack description to a string resource.

The literal "Loading" cannot follow the device’s language. Use stringResource for the spinner’s contentDescription. Based on learnings, Android UI content descriptions should use string resources so they can be localized.

Source: Learnings


Review info
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: 33fbf834-1804-4388-bec5-fa4420d9b9ed
Commits

Reviewing files that changed from the base of the PR and between 3627b86 and 51f5b58.

Files selected for processing: 10
  • android-shared/src/androidMain/kotlin/org/siloserver/silo/common/player/PlayerSpinnerVisibility.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerChrome.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerControls.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerNextUpScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerOverlay.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreen.kt
  • androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModel.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreen.kt
  • androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerViewModel.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerVisibilityPolicyTest.kt
Files with no reviewable changes: 1
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerVisibilityPolicyTest.kt

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Any isPlaying callback ended a new item's first load. Audio can start
before the video's first frame, so the controls could appear over black.
A late callback from the outgoing mount could also mark the incoming item
started.

Video now ends the first load only through the mount-checked first-frame
callback. A mount with audio and no video ends it when it plays, and the
callback is checked against the same mount generation (phone) or nonce
(TV).

The phone spinner also covered only session requests without a stream.
A version switch or Next Up keeps the previous stream URL while it
requests the next session, so it showed nothing. It now follows
isLoading, as the TV does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 26, 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 ❌
⚠️ 4 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

@Quick104
Quick104 merged commit 529a9ee into main Oct 26, 2026
10 checks passed
@Quick104
Quick104 deleted the fix/player-centered-spinner branch October 26, 2026 17:29
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: playback Can't play, stalls, or wrong media 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.

1 participant