Skip to content

fix(player): show Loading only when playback actually stalls - #641

Closed
Rhainland wants to merge 0 commit into
Silo-Server:mainfrom
Rhainland:fix/player-buffer-loading-pill
Closed

Rhainland wants to merge 0 commit into
Silo-Server:mainfrom
Rhainland:fix/player-buffer-loading-pill

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Rebase status

Rebased onto main at 34cedf4dbf5e4f320a01fcad810b9865bdb4cd19. Both commits in this PR already shipped in #620 (ba16529c3c73c0669ec0a058b346fc7affe78fa4), so the rebased branch has no remaining diff against main.

Verified that PlayerStallPresentation.swift and its tests match the original PR exactly, and that main retains the view model integration, including the replacement preparation guard and stall watcher. git diff --check and scripts/ci/check-no-api-v1.sh pass. No new build or runtime verification was run because the rebase leaves no code changes. The validation below describes the original implementation.

Problem

Related issue: N/A
Validation tasks: changes #337 C5

When the server stops during direct play, video keeps playing from the read-ahead buffer for several minutes, but the "Loading…" capsule showed the whole time and the player controls stayed hidden. Aether reports a reconnecting source as PlaybackPhase.stalled even while frames keep advancing, and the player mapped .stalled straight to loading. This shows Loading only when playback has actually stopped.

Approach

  • PlayerStallPresentation decides isLoading from the phase. Over a stalled source the player counts as loading only while it means to play and, for at least one second, either the playhead has not moved or the engine has held no media ahead of its clock.
  • The buffer check covers a seek past the buffer: Aether's clock then keeps running without a frame, so a moving playhead alone does not prove playback. Audio-only loads have no buffer reading and are judged by the playhead.
  • While the phase stays .stalled, the view model checks again every 250 ms, so the capsule appears once the buffer runs out and clears when frames move again.
  • A real rebuffer on the AVPlayer path still shows through isBuffering; .loading and .rebuffering are unchanged. isLoading also hides the controls and pauses the intro-skip and credits logic, so those now keep running while frames play.

Validation

  • Unit tests for the stall decision (moving and stopped playhead, no sample yet, running clock with nothing buffered, paused player, other phases): pass.
  • Manual, iPhone simulator: server stopped during direct play; no Loading capsule for 60 s while frames advanced, and subtitles kept rendering.
  • scripts/ci/check-no-api-v1.sh: pass.
  • All 22 app fixes from this validation run, merged together on main (6242652): the full iOS unit suite ran 2,691 tests. The only failures are ArtworkURLTests.testDeliveryCapabilityOnIOSUsesV2RouteAndResets and ImageSizeCapabilityTests.testResetClearsCapability, which fail the same way on main. tvOS build-for-testing and the macOS build succeed.
  • Local builds used Swift 6.3.3, which needs the ThumbHash type annotations from fix(build): annotate ThumbHash cosine tables so Swift 6.3.3 can type-check them #608 to compile. That change was applied locally and is not part of this PR.

Simulator screenshots (iOS 26.5, tvOS 26.5):

a2-loading

Risks

None identified. The capsule still appears for a real stall, after one second instead of immediately.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Rebase and PR update: Codex harness in T3 Code, model gpt-6.1-sol; tooling: Git, GitHub CLI, Python.

  • Harness: Claude Code, running in T3 Code

  • Tool(s): Claude Code subagents, xcodebuild, Xcode Simulator (simctl, Maestro), GitHub CLI

  • Model(s): claude-opus-5-5

  • Involvement: Fully AI-generated, human verified

  • Adversarial review: A separate Claude Code reviewer agent (claude-opus-5-5) read this branch's diff against main at medium effort, checking behaviour, platform guards (iOS, tvOS, macOS), tests and commit hygiene. It found that after a seek past the buffer with the server down, Aether's clock keeps running, so the first version would have shown a frozen frame with no capsule for about 80 s. The player now also treats an empty buffer ahead of the clock as a stall, with tests for that case.

Note

Show Loading in player only when stalled playback actually stops

  • Adds PlayerStallPresentation.isLoading, which classifies a stalled phase as loading only when a replacement is being prepared, the playhead has been frozen for 1 second, or the buffer ahead of the engine clock has been empty for 1 second in PlayerStallPresentation.swift
  • PlayerViewModel now tracks the last finite playhead sample and first buffer-empty time, and a 250 ms polling task re-evaluates loading while a load stays stalled in PlayerViewModel.swift
  • Audio-only loads are excluded from the buffer-ahead criterion; paused playback stays non-loading
  • Adds an XCTest suite with a fixed clock covering all presentation cases in PlayerStallPresentationTests.swift
  • Behavioral Change: stalled playback with a still-moving playhead and readable buffer is no longer presented as Loading; the intro-skip prompt now follows the recalculated loading value during stalls

Macroscope summarized 974a73c.

@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f923127-6073-491d-b256-4cf122e748c9
📥 Commits

Reviewing files that changed from the base of the PR and between 6242652 and 974a73c.

📒 Files selected for processing (3)
  • iosApp/Tests/PlayerStallPresentationTests.swift
  • iosApp/iosApp/Screens/Player/PlayerStallPresentation.swift
  • iosApp/iosApp/Screens/Player/PlayerViewModel.swift
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

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

@silo-kody

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

Comment on lines +1252 to +1255
let loading = self.currentPhaseIsLoading()
guard loading != self.isLoading else { continue }
self.isLoading = loading
self.syncIntroSkipPrompt()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Premature loading-state reset occurs when the stall watcher clears isLoading during a Protocol V3 replan: the outgoing stalled load still has buffered playback, and its epoch remains active while attemptProtocolV3Replan awaits sessionBridge.replanProtocolV3, removing the loading presentation and resuming the intro prompt before preparation finishes. Preserve the replan's loading state separately from the engine stall judgment, or prevent the watcher from overriding it while preparation is in flight.

Prompt for LLM

File iosApp/iosApp/Screens/Player/PlayerViewModel.swift:

Line 1252 to 1255:

Premature loading-state reset occurs when the stall watcher clears `isLoading` during a Protocol V3 replan: the outgoing stalled load still has buffered playback, and its epoch remains active while `attemptProtocolV3Replan` awaits `sessionBridge.replanProtocolV3`, removing the loading presentation and resuming the intro prompt before preparation finishes. Preserve the replan's loading state separately from the engine stall judgment, or prevent the watcher from overriding it while preparation is in flight.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 974a73c: while a replan, credential reload or fresh start is being prepared, a .stalled phase from the outgoing load now stays loading, so the stall watcher no longer clears the capsule or resumes the intro prompt before the replacement load reports its own phase. Other phases are judged as before. Covered in PlayerStallPresentationTests.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks—the fix described in 974a73c8 addresses the reported race: the outgoing load’s .stalled phase can no longer clear loading or resume the intro prompt while replacement preparation is in flight.

Keeping other phase handling unchanged preserves this PR’s intended buffered-playback behavior. The added PlayerStallPresentationTests cover the reported fix; I haven’t independently inspected the commit or run those tests.

@silo-kody

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants