Repository navigation
fix(playback): rebuild a transcode after the request that triggered it ends - #4125
Conversation
…t ends A rebuilt transcode serves every request waiting on it, but its tone-map check, fallback order and FFmpeg start ran on the context of the request that triggered it. When that request ended, StartTranscode returned its error before FFmpeg ran for an HEVC target, a capped VAAPI encode, a tone-mapped stream and burned-in text subtitles, and the other requests got the error. Once a rebuild holds its reconstruct slot, the manager and the transcode node now run those steps on a context detached from the request. Waiting for the slot still ends with the request. Closes #4113 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 2 minutes. View limit details
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…quest's test Moves TestReconstructTranscodeOutlivesTriggeringRequest above its neighbour. Another open pull request adds a test at the same spot, and the two would conflict whichever merged second. No test or code changes. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Closes #4113
Related issue: N/A
Validation tasks: changes #1177 C3; changes #1178 C2
Other clients: Apple N/A (server-side recovery fix, no client change needed); Android N/A (same); Roku N/A (same)
When a transcode has to be rebuilt (after a server or node restart, or a lost FFmpeg process), every request for that session waits on one rebuild. If the request that triggered it ended before FFmpeg started, for example because the player seeked or timed out, the rebuild failed with
context canceledand the other requests got an error instead of the stream. This change lets the rebuild finish once it has been admitted, whether or not that request is still connected.It affects a rebuild that starts FFmpeg once: an explicit hardware backend, software, and any tone-mapped stream.
StartTranscodereturns an ended request's error before FFmpeg runs for an HEVC target, a bitrate-capped VAAPI encode, a tone-mapped stream, and burned-in text subtitles. #4110 fixes the later attempts of a rebuild under Hardware acceleration = Auto; this is the path it leaves alone.Approach
Once a rebuild holds its reconstruct slot,
TranscodeManager.doReconstructTranscodeand the transcode node'sspawnReconstructrun the rest of their preparation on a context detached from the request: the tone-map executor check, the choice of fallback order, and the FFmpeg start. The node already detached its tone-map check and its software retry; this makes the rest of the rebuild match.Notes for review:
StartReconstructTranscode, because the steps that run before it also failed the rebuild. On the manager, the tone-map executor check returns the ended request's error when its probe cache is cold, which is the state after a restart. Under Auto, choosing the fallback order on an ended request can return a disabled pipeline, so a failed GPU attempt gets no CPU retry.runTranscodeStartup, so it merges cleanly with fix(playback): start a rebuild's next FFmpeg attempt after the request that triggered it ends #4110 in either order.Jellyfin clients reach the same manager and node code, so they get the same fix. No API, setting, or client change.
Validation
context canceledand pass here. Reverting any one of the six detached call sites makes one of them fail.gofmt,go mod tidy -diff,go vet,make lint-changed, andmake lint-router-recoverypass.make test-gopasses forinternal/transcodenode. It fails ininternal/playback(one real-FFmpeg subtitle test),internal/api/handlers,internal/backup,internal/ebookconvert,internal/mediasample, andinternal/uploads. The same packages fail on the merge base on this host; the failures I read come from the host's temp directory mode and FFmpeg build.Evidence
Nothing visible changes. With a burned-in text subtitle, the session lost to a server restart, and two manifest requests 10 ms apart:
mainat 4030ffbreconstruct transcode start failed error="context canceled"transcode process reconstructed from recipe cardEvidence: https://evidence.siloserver.org/r/silo-server/issue-4113/
Risks
Checklist
AI Disclosure
go test), GitHub CLI🤖 Generated with Claude Code
Note
Fix transcode reconstruction being canceled when the triggering request ends
Rebuilds triggered by playback now outlive the request that started them. After a reconstruction slot is acquired,
playback.TranscodeManager.doReconstructTranscodeandtranscodenode.Server.spawnReconstructcreate a context without the request's cancellation or deadline, and use it for pipeline creation, tone-map executor resolution, transcode start, and the software-encoding retry.Macroscope summarized 8dae501.