Repository navigation
fix(playback): take the media runtime from the v3 plan - #105
Conversation
The plan's source descriptor was decoded but its runtime was ignored: the session took durationSeconds from the catalog FileVersion the client had picked. That is the wrong file whenever the server resolves a different effective version, and it is unavailable whenever the catalog value is missing. Prefer plan.source.durationSeconds and fall back to the catalog only for servers that predate the field. The property is Optional because every non-Optional property on the descriptor is a required key — a non-Optional duration would fail the entire plan against an older server. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe V3 source descriptor now carries an optional source runtime. ChangesPlayback duration handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 09e85e0a02
ℹ️ 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".
| // file the server actually chose. Fall back to the catalog version | ||
| // only for servers that predate the field; substituting it when | ||
| // the server reports an unknown runtime would reintroduce a guess. | ||
| durationSeconds: plan.source.durationSeconds ?? selectedVersion.duration, |
There was a problem hiding this comment.
Preserve an explicitly unknown plan duration
When a current server returns "duration_seconds": null because the effective source runtime is unknown, synthesized Codable produces the same nil as an absent legacy key, so this fallback substitutes selectedVersion.duration. If the server selected a different effectiveMediaFileId, that duration belongs to the requested file and produces incorrect scrubber/progress reporting—the case this change is intended to fix. Distinguish an absent legacy key from an explicitly unknown value and preserve the latter through the downstream catalog fallback.
AGENTS.md reference: AGENTS.md:L19-L22
Useful? React with 👍 / 👎.
Problem
The v3 plan's
sourcedescriptor was already decoded here, but its runtime was ignored:ApplePlaybackV3PlanAdapter.playbackSessiontookdurationSecondsfrom the catalogFileVersionthe client had selected.That is the wrong file whenever the server resolves a different effective version — the plan carries both
requested_media_file_idandeffective_media_file_idprecisely because they can differ — and it is unavailable whenever the catalog value is missing or wrong. The same underlying gap showed up on Android as a 90-minute movie playing back as about a minute.What this does
Prefers
plan.source.durationSeconds, falling back to the catalog version only for servers that predate the field.durationSecondsis declaredDouble?. This matters more than it looks: every non-Optional property onPlaybackV3SourceDescriptoris a required key under synthesizedCodable, so a non-Optional duration would throwkeyNotFoundagainst an older server and fail the entire plan — turning a missing runtime into dead playback.Scope
Client half of Silo-Server/silo-server#482, which adds
source.duration_secondsto the v3 plan and fixes the scanner rule that let a wrong duration persist. The Android half is Silo-Server/silo-android#104.Merge the server PR first. Without it the field is simply absent and behavior is unchanged from today, so this is safe to merge in either order but provides no benefit until the server ships.
Independent of the
feat/playback-v3-onlywork — this branch is cut frommainand touches neither the legacy fallback path nor the session bridge.Verification
Three tests added, per the repo guidance to cover critical shared-logic behavior:
duration_secondskey still decodes, guarding the Optional requirement aboveNotes
Not addressed here, and worth separate issues:
PlaybackSessionBridgereportsduration: 0withforceOverwrite: trueon stop, and the server clobbers a good stored duration with it.PlayerViewModel: the KVO observer onAVPlayerItem.durationre-fires on every playlist refresh and the monotonic-max guard only rejects smaller values, so a growing HLS window can still extend a known runtime. The server value seeds it rather than overriding it.PlaybackV3Timelinefields are decoded and never read; the seek path uses a hardcoded 30-second window instead ofseekWindowStartSeconds/seekWindowEndSeconds/canSeekAnywhere.AI Disclosure
Codabletreating every non-Optional property on the descriptor as a required key, so declaring the duration non-Optional would fail the whole plan against any older server; the third test exists to lock that in. Second, a proposed rule to represent duration as genuinely "unknown" in the UI was withdrawn after review foundTVPlayerScrubberdivides by duration with no guard (0/0→NaN, currently masked only by aduration > 0check) andNowPlayingControllerdrops the system scrubber when duration is zero. This client keeps treating0as unknown internally and only gains a trustworthy first source.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests