You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(subtitles): fetch a load-declared sidecar once per selection - #27
Selecting a subtitle declared in LoadOptions.externalSubtitles while the engine's native-store fill is still reading that file started a second download of it. A server that extracts an embedded track reads the whole source for each request, so on network storage the viewer waited through two full extractions. The selection now waits for the running fill and takes its result.
A selection whose track's fill job is running waits for it, showing the track as loading, then fills from it. A fill that ends early or fails hands the selection to its own decode, which refetches as before. A track queued behind another track's fill job still decodes on its own, so no selection waits longer than its own fetch would take.
The fill decodes with preserveASSMarkup. SubtitleDecoder can return the plain-text reading of the same packets beside the raw ASS lines (alsoPlainText), so the store gets exactly what it got before, and a styled ASS selection fills from the raw decode, also on a later reselect.
A fill that read the whole file and found no cues fills the selection empty instead of fetching again. A known bitmap sidecar (.sup, PGS, VobSub, DVB) never shares the fill, because the store keeps no image cues; any other track does, and a fill that decodes images reports that it doesn't hold the whole track, so that selection still decodes the sidecar itself.
Prepared tracks, secondary selections and tracks added after load keep their own decode. No public API changes.
A text sidecar (.srt, .ass, .ssa, .vtt, and no sourceStreamIndex) is read with one unranged request, in the fill and in every selection's own decode. That request has no reconnect or retry, so a read that is cut mid-file, refused with a status other than an authentication one, or unanswered falls back once to the ranged open, which resumes or retries it; a reopen that also fails reports the fuller cut.
When a shared pass over a multi-stream container fails, the targets after the first stop waiting on the per-target retries and decode on their own. A session teardown drops the fill state, and a removed track's styled result is evicted.
silo-apple pins this fork by revision. The pin bump follows once this merges; no silo-apple pull request depends on it.
Test plan
Device / OS: macOS 27.0 on Apple Silicon, swift test with Xcode 27.0. No iOS or tvOS device run.
Source media (container / video codec + profile / audio / HDR-DV): SRT and ASS sidecars written by the tests, and the suite's existing multi-stream subtitle container fixtures. No video media.
Result: full suite passed: XCTest 790 tests (1 skipped, 0 failures), Swift Testing 4,990 tests in 684 suites, and the separate authorization suites (56 tests in 5 suites), run as CONTRIBUTING describes.
After the merge with main and the review fixes (macOS 27.2, Xcode 27.2): the XCTest bundle passed, Swift Testing ran 5,804 tests with one failure, APACEncodePipelineTests, which fails the same way on main, and the authorization suites passed. Each review fix has a test that failed on the head before it.
Live check (macOS 27.2.1, debug aetherctl from main and from this head): aetherctl play --host-calls nativesubs --sidecar de=<url> --subs de on a local H.264 clip, with an 800-cue SRT served by an origin that logs each request and trickles the body over 6 s. Main served the sidecar body twice, once for the store fill and once for the selection. This head served it once with one unranged GET, and the selection waited for the fill and backfilled the same 800 cues. The logs are on the evidence page.
Fixed: the shared-pass wait, the ungated empty backfill, a container with a text hint reading sequentially, fill state surviving a teardown, styled results kept for removed tracks, a cut, refused or unanswered sequential read losing the track, and a cancelled reopen reporting a cut. Answered: an ASS stream that codecName labels subrip stays plain on backfill because hosts choose the renderer from TrackInfo.codec; the remote-HLS provider fill and codecName's bitmap aliases predate this PR and are left to follow-ups; an authorized sidecar from an origin that refuses unranged GETs but serves ranges still fails, because the relay ends the source on a refusal, as it did on main for any refused request.
AI disclosure: fully AI-generated with Claude Code in T3 Code (model claude-opus-5-5), using its shell and file tools, the GitHub CLI, and SwiftPM on a Mac build service. A maintainer approved opening it; no human has run it on a device yet. A separate read-only Claude Code session (claude-opus-5-5) reviewed it at high effort for deadlocks, stuck waits, early-ending fills and styled ASS. It found one issue, a complete fill with no cues still refetched, which the second commit fixes. Kody then found that a .sup sidecar could end up with no subtitles through that empty fill, and that the fix for it was too narrow for subtitle containers and extensionless URLs; the third and fourth commits fix both. A later /silo review (Claude Code, claude-opus-5-5) merged main and added the review fixes; see Council review.
Share load-declared sidecar store fills with track selection and read text sidecars sequentially
Selecting a load-declared external subtitle track now waits for its running native-store fill and backfills from it, instead of always starting a second sidecar decode. Styled ASS tracks backfill from a retained styled decode result; incomplete or failed fills fall back to an independent sidecar decode.
Text sidecars without a stream index are now fetched with one unranged sequential HTTP request, with fallback to the ranged open for recoverable failures (I/O errors, truncation, non-auth HTTP statuses). Tracks with a stream index keep ranged reads.
The decoder can return a parallel plain-text cue list (plainCues) alongside raw ASS markup, used to fill stores while keeping the styled result for selection.
Fill state (running IDs, retained styled results, waiting selections) is tracked with a generation counter and reset on session load, teardown, and subtitle-pipeline teardown. Covered by new tests in ExternalNativeSubtitleTests.swift and a new SidecarSequentialFetchTests.swift suite.
Behavioral Change: bitmap sidecars and prepared tracks with empty completed stores now decode via their own sidecar task instead of sharing a fill; see selectExternalSubtitleTrack in AetherEngine+Subtitles.swift.
Selecting a track declared in LoadOptions.externalSubtitles while its
native-store fill was still reading the file started a second decode of
the same URL. A server that extracts an embedded track reads the whole
source once per request, so on network storage the viewer waited for
two full extractions (silo-apple#600). Styled ASS always took that
second path, because the store keeps only plain text.
- A selection whose track's fill job is running now waits for it,
shows the track as loading, and backfills from the fill when it
lands. A fill that ends early or fails hands the selection to its
own decode, which refetches as before. A track still queued behind
another track's job decodes on its own, as before, so no selection
waits longer than its own fetch would take.
- The fill decodes with preserveASSMarkup. SubtitleDecoder can now
return the plain-text reading of the same packets beside the raw
ASS lines (alsoPlainText), so the store gets exactly what it got
before and a styled ASS selection backfills from the raw decode,
also on a later reselect.
- Prepared tracks, secondary selections and tracks added after load
keep their own decode.
Incremental cue publishing is not part of this change: the text
demuxers read the whole body at open, so it needs a streaming WebVTT
demux of its own.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…of refetching it
A selection that waited for its track's store fill, or a later reselect,
decoded the sidecar again whenever the store held no cues, because the
backfill required at least one. A fill that read the whole file and
found none is the whole track: a second fetch asks a server that
extracts an embedded track to read the whole source again, for the same
empty answer. The fill now records which tracks it read in full this
run, and those backfill even when empty. A fill that ends early or fails
still hands the selection to its own decode.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
External subtitle selection can wait for a compatible native-store fill and reuse its results when complete. ASS fills can provide plain cues for the store and styled results for overlays. Incomplete or failed fills lead to sidecar decoding. Text sidecar decoding also supports sequential reads.
Changes: External Subtitle Fill Reuse
Layer / File(s)
Summary
Decode styled and plain readings Sources/AetherEngine/Decoder/SubtitleDecoder.swift, Tests/AetherEngineTests/SidecarASSMarkupTests.swift
The decoder can return plain cues alongside markup-preserving ASS cues when requested. It also accepts sequential-source settings. Tests compare combined output with separate decoding.
Configure fill targets and sequential reads Sources/AetherEngine/AetherEngine.swift, Sources/AetherEngine/AetherEngine+Subtitles.swift, Sources/AetherEngine/Native/RemoteHLSSubtitleProvider.swift, Sources/AetherEngine/Subtitles/ExternalSubtitleTrack.swift, Tests/AetherEngineTests/SidecarSequentialFetchTests.swift
Fill targets carry track IDs and markup-preservation settings. Grouped jobs combine sequential-read settings. Track format properties and tests cover sequential fetching.
Track fills and backfill selections Sources/AetherEngine/AetherEngine.swift, Sources/AetherEngine/AetherEngine+Subtitles.swift, Tests/AetherEngineTests/ExternalNativeSubtitleTests.swift, CHANGELOG.md
Generation-scoped state tracks fills and styled ASS results. Selection reuses complete results or waits for a compatible fill. Incomplete or failed fills lead to sidecar decoding. Tests cover selection outcomes.
sequenceDiagram
participant AetherEngine
participant SubtitleDecoder
participant NativeSubtitleStore
AetherEngine->>SubtitleDecoder: Decode fill with optional ASS markup preservation
SubtitleDecoder-->>AetherEngine: Return plain cues and optional styled result
AetherEngine->>NativeSubtitleStore: Store plain cues
AetherEngine->>AetherEngine: Backfill selection or decode sidecar if fill is incomplete
Loading
Possibly related PRs
Silo-Server/AetherEngine#25: Both changes define how an early-ended external subtitle fill is treated, including when selection falls back to its own decode.
Silo-Server/AetherEngine#26: This change extends the fill and selection paths introduced there with ASS markup preservation, plain-text decoding, and fill-result reuse.
Suggested reviewers:orut34iop
Merge Risk: Low · up to d44dc
External subtitle selection now reuses the load-time fill instead of fetching the sidecar twice. Two narrow edge cases remain: a prepared subtitle may skip its size and cue limits when it is selected after a reload, and a selection triggered from a loading-state observer can stay stuck loading. Both are small fixes and worth resolving before merge, but they are unlikely to affect ordinary playback.
Security architecture risk: Minimal · up to d44dc
The sharing behavior remains scoped to the current playback session and retains existing credential protections. No material new security, ownership, or recovery risk was established in the inspected changes.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The inspected changed exposure concerns external subtitle responses processed by a playback instance, its in-memory subtitle state, and requests to the configured origin or redirects. Sharing does not add a new credential grant: requests remain separated by authorization identity, and callbacks remain scoped to the current fill generation and selected track.
Trust Boundaries and Controls
observed — Implicit media headers remain restricted to the media's exact HTTP origin. The sequential streaming delegate uses the existing redirect policy to remove recognized credential headers from disallowed destinations, delegates TLS challenges to the existing handler, and rejects HTTP responses other than 200 or 206 before admitting their bodies.
Resilience and Maintainability Implications
observed — The reused streaming reader trims consumed bytes, suspends and resumes transport around buffer watermarks, and cancels a transfer that exceeds its retained-buffer hard cap. Stalls, transport errors, and bodies shorter than their advisory length produce read errors rather than clean EOF. These controls bound transport buffering, not total decoded cues or styled-cache contents.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a load-declared external subtitle selection now reuses the load-time store fill, so the sidecar is fetched once per selection instead of twice. The changeset matches t…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description explains the change in detail: selections of load-declared external subtitles now wait for the running native-store fill instead of starting a second download. It also covers the text-…
Full details: Title check
Explanation
The title names the main change: a load-declared external subtitle selection now reuses the load-time store fill, so the sidecar is fetched once per selection instead of twice. The changeset matches this: fill-waiting logic in AetherEngine+Subtitles.swift, fill state in AetherEngine.swift, and tests for waiting selections and fallback decoding.
Full details: Description check
Explanation
The description explains the change in detail: selections of load-declared external subtitles now wait for the running native-store fill instead of starting a second download. It also covers the text-sidecar sequential read, bitmap-sidecar exclusion, the plain-text decode option, the test plan, and the council review. It is directly related to the changeset, so the description is on-topic and specific.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
silo-triageBot
added
bug
Something isn't working
triaged
High-confidence review completed; does not mean fixed, validated, or accepted for release.
labels
Oct 30, 2026
The reason will be displayed to describe this comment to others. Learn more.
Subtitle loss occurs in Sources/AetherEngine/AetherEngine+Subtitles.swift because a load-declared .sup track defaults to codec subrip, enters the non-OCR fill table, and satisfies the empty-store backfill condition through completedExternalStoreFillIDs even though NativeSubtitleCueStore.appendLocked discards image cues, leaving a finished, empty native store. Selecting the track then publishes no subtitles instead of using the previous image-capable sidecar decode; restrict empty-store reuse to decoded text streams or retain image results for the overlay.
Prompt for LLM
File Sources/AetherEngine/AetherEngine+Subtitles.swift:
Line 1497 to 1499:
Subtitle loss occurs in Sources/AetherEngine/AetherEngine+Subtitles.swift because a load-declared `.sup` track defaults to codec `subrip`, enters the non-OCR fill table, and satisfies the empty-store backfill condition through `completedExternalStoreFillIDs` even though `NativeSubtitleCueStore.appendLocked` discards image cues, leaving a finished, empty native store. Selecting the track then publishes no subtitles instead of using the previous image-capable sidecar decode; restrict empty-store reuse to decoded text streams or retain image results for the overlay.
The reason will be displayed to describe this comment to others. Learn more.
This is already handled on the branch. 73a7fe8 keeps a known bitmap sidecar off the store fill, and 0ef2268 makes a fill that decoded images report that it doesn't hold the track, so that selection decodes the sidecar itself. Since superuser404notfound#921 merged, a .sup reports pgssub and becomes an OCR entry, which the fill skips entirely, so it can't reach the empty backfill. The new empty-backfill branch is also gated on sharesStoreFill now.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification. Based on your description, the original .sup subtitle-loss scenario is addressed: known bitmap tracks skip the shared fill, and fills that encounter image cues fall back to an independent decode. The OCR classification and sharesStoreFill gate provide additional protection.
I haven’t independently verified the current branch, so I can’t confirm the implementation from the supplied diff alone.
A `.sup` sidecar declared at load is labelled subrip by codecName, so it
joined the native text table and its store fill. The store keeps no image
cues, so that fill always finished complete and empty. Selecting the track
while the fill ran waited for it, and once it finished the empty-fill
backfill published no subtitles in place of the sidecar decode that would
have shown its images.
A selection now shares the fill only for a text format, and a fill reports
that it holds the whole track only when it read the entire sidecar and
found no image cues. A bitmap sidecar decodes on its own, as before superuser404notfound#600.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Duplicate full-container fetching and decoding occurs through startSidecarDecode when a supported text track from an .mkv container or an extensionless URL without a format hint is selected during its fill, because the isTextFormat gate accepts only six text extensions and disables fill sharing, reintroducing the duplicate read this PR aims to eliminate. Distinguish known bitmap formats instead of requiring a recognized text extension, and use the decoded fill outcome to reject image results.
Prompt for LLM
File Sources/AetherEngine/AetherEngine+Subtitles.swift:
Line 1489:
Duplicate full-container fetching and decoding occurs through `startSidecarDecode` when a supported text track from an `.mkv` container or an extensionless URL without a format hint is selected during its fill, because the `isTextFormat` gate accepts only six text extensions and disables fill sharing, reintroducing the duplicate read this PR aims to eliminate. Distinguish known bitmap formats instead of requiring a recognized text extension, and use the decoded fill outcome to reject image results.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 0ef2268. Fill sharing is now decided by isKnownBitmapFormat rather than a text-extension allowlist, so a text stream in an .mkv or behind an extensionless URL waits for its fill (unknownFormatSharesFill covers both), and a fill that decoded images sends the selection to its own decode.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. The reported fix addresses the suggestion by allowing unknown formats to share the fill while falling back to a separate decode when the fill contains images. I haven’t independently verified the commit or tests.
Quick104
added a commit
to Silo-Server/silo-apple
that referenced
this pull request
Oct 31, 2026
head
Test branch only. Moves the pin from 13b64f2a to 73a7fe8e, which keeps a
bitmap sidecar off the text store fill, with the acknowledgements and
notices naming the same revision. The engine's package manifest is
unchanged, so nothing else in Package.resolved moves.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… bitmap
The bitmap guard allowed only six text extensions to wait for a running
store fill. A text stream of a subtitle container (an .mkv with several
subtitle streams) or an extensionless sidecar without a format hint then
started a decode of its own while the fill read the same file, the second
fetch this change set out to remove. A selection now skips the fill only
for a known bitmap format (.sup, PGS, VobSub, DVB). Any other track waits,
and a fill that decodes images reports that its store does not hold the
whole track, so that selection still decodes the sidecar itself.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Select cached ASS markup using the decoded format
With preserveASSMarkup enabled, selecting an ASS stream from a .mkv container or an extensionless URL while its fill runs now loses the raw ASS events and script header. codecName defaults these URLs to subrip, so wantsStyledASS is false even though the decoder recognizes ASS and the fill caches a styled result. When the wait resumes, this condition skips that result and the next branch publishes the plain store cues with assHeader: nil; previously, a selection during the fill ran its own format-sniffing decode and preserved the markup. Prefer the actual cached styled result when markup preservation is enabled rather than requiring an ASS filename or format hint.
The reason will be displayed to describe this comment to others. Learn more.
I checked this one and I'm leaving it as is. For an ASS stream inside an .mkv, or behind an extensionless URL with no hint, codecName reports subrip, and hosts pick their renderer from TrackInfo.codec: Silo's Apple client runs libass only for ass/ssa and draws every other track's cues as text. If the backfill published raw event lines for that track, the viewer would see 0,0,Default,,... on screen. The plain backfill matches what the host was told the track is, and it's what the finished-store path already did before this PR. The raw decode a selection used to get during the fill had the same mismatch. The root cause is codecName labelling these streams by URL; that predates this PR and is better fixed there, by taking the codec from the decoded stream. Silo's client always sends a formatHint, so it doesn't hit this path.
The reason will be displayed to describe this comment to others. Learn more.
Revises an earlier Kody suggestion on Sources/AetherEngine/AetherEngine+Subtitles.swift:1489 (2026-10-31 19:36 UTC).
ASS styling loss occurs when an ASS stream in an .mkv container or an extensionless sidecar joins the fill with preserveASSMarkup enabled: codecName labels it subrip, making wantsStyledASS false, so selection backfills plain cues with a nil header even though the fill retains the styled result. Revise the earlier fill-sharing expansion to prefer an available decoded styled result whenever markup preservation is enabled, without requiring the URL-derived codec to identify ASS.
Prompt for LLM
File Sources/AetherEngine/AetherEngine+Subtitles.swift:
Line 1491:
**Revises an earlier Kody suggestion** on `Sources/AetherEngine/AetherEngine+Subtitles.swift:1489` (2026-10-31 19:36 UTC).
ASS styling loss occurs when an ASS stream in an `.mkv` container or an extensionless sidecar joins the fill with `preserveASSMarkup` enabled: `codecName` labels it `subrip`, making `wantsStyledASS` false, so selection backfills plain cues with a nil header even though the fill retains the styled result. Revise the earlier fill-sharing expansion to prefer an available decoded styled result whenever markup preservation is enabled, without requiring the URL-derived codec to identify ASS.
The reason will be displayed to describe this comment to others. Learn more.
Same answer as the Codex thread on this line: the plain backfill matches TrackInfo.codec (subrip for these URLs), which is what hosts use to choose a renderer, so publishing raw ASS lines there would put markup on screen. The fix belongs in codecName, which predates this PR.
The reason will be displayed to describe this comment to others. Learn more.
That distinction makes sense. If hosts use TrackInfo.codec to select the renderer, returning raw ASS while reporting subrip could expose markup as text. I’d withdraw the suggestion to prefer the styled fill result on its own.
The remaining issue is that ASS in a container or at an extensionless URL may lose styling because its codec is misidentified. Correcting codec detection—and keeping the reported codec and returned cues consistent—sounds like a separate fix.
Quick104
added a commit
to Silo-Server/silo-apple
that referenced
this pull request
Oct 31, 2026
A selection decoded the sidecar once, but that decode sent four requests
when the origin ignored Range and gave no Content-Length, as a compressed
subtitle response does. The ranged open sent a tail prefetch, a ranged
request and a range check before the unranged GET it decoded, and the
origin answered each one with the whole file.
A text sidecar (SRT, ASS/SSA, WebVTT) is read front to back, so its
decode now opens with AVIOReader's sequentialOnly mode: one unranged GET.
The selection decode, the secondary decode and the load-time store fill
all use it. A fill reads sequentially only when every track it fills is
text. Containers and unknown formats keep the ranged open, since they may
need to seek.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Cooperative executor blocking occurs because the async test calls synchronous lengthlessOrigin(), occupying a cooperative thread while test-origin startup waits. Dispatch startup to a GCD worker and bridge its result through a checked throwing continuation.
File Tests/AetherEngineTests/SidecarSequentialFetchTests.swift:
Line 26:
Cooperative executor blocking occurs because the async test calls synchronous lengthlessOrigin(), occupying a cooperative thread while test-origin startup waits. Dispatch startup to a GCD worker and bridge its result through a checked throwing continuation.
**Also found in:**
- `Tests/AetherEngineTests/SidecarSequentialFetchTests.swift:38-38`
Suggested Code:
let origin = try await withCheckedThrowingContinuation { continuation in
DispatchQueue.global(qos: .utility).async {
continuation.resume(with: Result { try lengthlessOrigin() })
}
}
The reason will be displayed to describe this comment to others. Learn more.
Not changing this. ProbeHTTPTestOrigin.init binds a non-blocking loopback listener and starts its accept loop on its own thread; it doesn't wait on anything, and 28 other tests construct it the same way from async tests. The suggested DispatchQueue.global().async is banned under Tests/ by Scripts/check-test-hygiene.py, per CONTRIBUTING.
The reason will be displayed to describe this comment to others. Learn more.
Agreed. If ProbeHTTPTestOrigin.init only sets up the non-blocking listener and starts its accept loop without waiting, the suggestion’s premise that startup blocks the cooperative executor is incorrect. The proposed GCD dispatch also conflicts with the test hygiene rule.
I withdraw the suggestion; no change is needed on that basis.
Keeps both main's superuser404notfound#921 keepsBitmapPackets path and this branch's
sequentialSource and plainCues. The secondary sidecar reads its
sequential flag from the selected candidate, as main now reads its
preparation policy.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1622-1623: 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.
Check whole-track completeness before backfilling a nonempty store.
If a fill contains text and image cues, fillHoldsWholeTrack returns false. However, fillStore still marks the text-only store finished. This branch then accepts that store because cueCount > 0, so selection loses the image cues instead of decoding the sidecar.
Require a complete fill outcome for this backfill path. Keep complete empty fills eligible.
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: cb4bf264-ee1b-417c-bf39-c5b2e126ae10
Commits
Reviewing files that changed from the base of the PR and between 725a7d3 and d44dcaa.
Files skipped from review as they are similar to previous changes: 1
CHANGELOG.md
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.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Install the external-store wait before publishing isLoadingSubtitles.
awaitExternalStoreFill publishes isLoadingSubtitles = true before it sets primaryAwaitingExternalStoreFillID. @Published subscribers run during willSet, so a subscriber can select another external track before line 1671 runs. That selection installs its own waiter, and line 1671 then overwrites it. When the other track's fill completes, resumeSelectionAwaitingExternalStoreFill sees a waiter that does not match the active track and does not resume that track. Its loading state can remain set until the user selects a track again.
Set the waiter first. A reentrant selection then replaces it, and the engine does not overwrite it afterward.
The reason will be displayed to describe this comment to others. Learn more.
Not changed. The reentrancy is real only for a subscriber that calls selectSubtitleTrack synchronously from willSet, and the same order shows up in every selection path on main. startSidecarDecode publishes activeSubtitleTrackIndex and then isLoadingSubtitles before it assigns sidecarTask, so the same reentrant selection there leaves an orphaned task. backfillExternalSubtitle also writes several published properties in a row. Moving this one assignment above the published writes only covers a subscriber on isLoadingSubtitles. A subscriber on activeSubtitleTrackIndex or subtitleCues, which are written earlier, still gets its selection overwritten, and then the other track waits instead. Guarding selection against synchronous reentrancy is an engine-wide change and would need its own PR.
The reason will be displayed to describe this comment to others. Learn more.
@Quick104 You’re right. My suggested reorder addresses the waiter overwrite for reentry through isLoadingSubtitles, but it does not make selection reentrancy-safe. Earlier publications and other selection paths can also be reentered.
I accept deferring the broader fix. I’m not marking the finding as addressed.
Learnings added
Learnt from: Quick104
Repo: Silo-Server/AetherEngine PR: 27
File: Sources/AetherEngine/AetherEngine+Subtitles.swift:1670-1671
Timestamp: 2026-11-23T02:20:18.313Z
Learning: Within repository "Silo-Server/AetherEngine", only for files matching one of ["Sources/AetherEngine/AetherEngine+Subtitles.swift"]: When reviewing synchronous Combine @Published reentrancy in Sources/AetherEngine/AetherEngine+Subtitles.swift, do not treat moving primaryAwaitingExternalStoreFillID before isLoadingSubtitles in awaitExternalStoreFill as a complete fix. That reorder addresses the waiter overwrite for reentry through isLoadingSubtitles, but earlier activeSubtitleTrackIndex and subtitleCues publications can also reenter selection. startSidecarDecode also publishes selection state before assigning sidecarTask, so assess the other publication points and selection paths.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
The reason will be displayed to describe this comment to others. Learn more.
I merged current main into this branch: main's superuser404notfound#921 bitmap-sidecar path (keepsBitmapPackets) conflicted with sequentialSource and plainCues, and the merge keeps both. The findings below are on that merged head. Each one is something this PR adds; I've left out what was already on main.
…d open
The single sequential GET has no reconnect. A text demuxer reads the whole
body at open, so a connection that dropped mid-file failed the open with
EIO or ended the read short, depending on where the cut landed: the fill
left the native rendition empty or partial, and the overlay decode, which
retries only a truncation, got no subtitles at all. The ranged reader this
replaced resumed at the frontier. Such a read now reopens once with the
ranged open. A track that names a sourceStreamIndex addresses a container
and keeps the ranged open whatever its hint.
The changelog entry also stops citing .sup, which superuser404notfound#921 made an OCR entry
that never joins the fill, and says the one-request read applies to every
text sidecar decode.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A failed shared pass over a multi-stream container reports the targets
after the first as unfilled before retrying each one alone, so a
selection waiting on a later target decodes on its own instead of
sitting through every earlier whole-file read.
- A complete empty fill backfills only a track that shares the fill, so a
prepared track still runs its policy decode.
- stopInternal drops the fill state: a software reroute or a background
teardown rebuilds without a new fill run, and nothing may wait on or
backfill from the old one.
- A removed track's styled result is evicted, and a late fill caches none
for an id no longer registered.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
File Sources/AetherEngine/Decoder/SubtitleDecoder.swift, line 235:
The ranged retry can discard the first partial subtitle result
Preserve the partial result carried by the first `.truncated` error before retrying. If the ranged decode also fails or returns a worse partial, retain the better result—including an empty first partial—for the caller’s retry-exhaustion handling.
Kody rule violation: [Retain zero\-cue partial results when subtitle retries are exhausted](https://kodus.siloserver.org/settings/code-review/1357310485/kody-rules/d9fb9bc5-4119-4455-9822-7da56b45482e?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)
The reason will be displayed to describe this comment to others. Learn more.
Fixed in ff2a160. When the ranged reopen also fails, decodeBlocking keeps the first attempt's truncated result and throws the reopen's truncation only when it holds more cues, so the fuller partial of the two survives and the error stays retryable as a truncation.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. The described fix addresses the suggestion: it preserves the first partial result, including a zero-cue partial, unless the ranged retry produces a truncation with more cues. It also keeps the error retryable as a truncation.
The reason will be displayed to describe this comment to others. Learn more.
The immediate ranged refetch bypasses the sidecar retry schedule
An immediate ranged refetch adds an uncounted request and bypasses the scheduled retry delays. Route decode(sequential: false) through the sidecar retry policy.
File Sources/AetherEngine/Decoder/SubtitleDecoder.swift, line 235:
The immediate ranged refetch bypasses the sidecar retry schedule
Route this full ranged refetch through the sidecar retry policy instead of starting it immediately inside a single decode attempt. Otherwise a source cut can add an uncounted request with no scheduled delay, exceeding the initial fetch plus five refetches and bypassing the documented 2, 5, 10, 10, and 10 second waits.
Kody rule violation: [Keep subtitle refetch timing, attempt counts, and documentation aligned](https://kodus.siloserver.org/settings/code-review/1357310485/kody-rules/c117e08f-6e7c-4035-b12d-0734cc0414f7?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)
The reason will be displayed to describe this comment to others. Learn more.
Not changed, by design. The ranged reopen isn't a retry. It's the read this sidecar had on main before sequentialSource, done once inside the same attempt when the unranged GET can't finish. The sidecar retry schedule still counts and spaces whole attempts around it, and the ranged open keeps its own reconnect. An attempt sends at most one extra request, and only after the unranged read failed. In the common case it sends one request where main sent two (a tail probe and a ranged body read). The live run on the evidence page shows that.
The reason will be displayed to describe this comment to others. Learn more.
That distinction makes sense: the ranged reopen is an immediate fallback within a scheduled attempt, not an additional scheduled attempt. My suggestion conflated attempt counts with HTTP request counts.
I withdraw the recommendation to route the reopen through the retry schedule. The remaining question is whether the rule’s wording limits requests or attempts: if it promises a maximum number of HTTP requests, the fallback may still conflict with it. Otherwise, the current design is consistent with the explanation.
…d reopen keeps the cut
The ranged open retries a busy origin (429, 503) where the single
sequential GET fails on its first refusal, so a sequential read that an
origin refused with any status but an authentication one, or never
answered, now falls back to the ranged open as a cut one does. When that
reopen fails outright after a cut, the cut is reported, so the fill keeps
its cues and the overlay still retries it as a truncation.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
Cancellation during the ranged reopen is replaced with a truncation
Replacing CancellationError with the first truncation can let fillDecode publish a partial store after cancellation. Propagate cancellation before choosing between the errors.
Prompt for LLM
File Sources/AetherEngine/Decoder/SubtitleDecoder.swift, lines 228-231:
Cancellation during the ranged reopen is replaced with a truncation
If cancellation occurs during the ranged reopen, this handler replaces `CancellationError` with the first truncation, so `fillDecode` can publish a partial store after its task was canceled. Propagate cancellation before choosing between the two errors.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in faedd30. The reopen's catch now checks token.isCancelled first and throws CancellationError before it picks between the two truncations, so a fill cancelled during the reopen never publishes a partial store.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. Checking cancellation before choosing between the truncation errors addresses the reported issue. I haven’t independently verified commit faedd306.
The reason will be displayed to describe this comment to others. Learn more.
Test-origin startup blocks a cooperative-executor thread
Synchronous ProbeHTTPTestOrigin startup can block a cooperative-executor thread during this async test. Start it on a GCD worker and bridge the result back with a checked throwing continuation.
File Tests/AetherEngineTests/SidecarSequentialFetchTests.swift, line 78:
Test-origin startup blocks a cooperative-executor thread
Start the test origin on a GCD worker and bridge its result back with a checked throwing continuation. Its synchronous startup can block a cooperative-executor thread while this async test is running.
Kody rule violation: [Move blocking decodes off Swift's cooperative executor](https://kodus.siloserver.org/settings/code-review/1357310485/kody-rules/6f5a6668-e899-4eea-8cf9-4246cd47a4b8?teamId=ba9922fc-c0ea-4cf8-87bb-9d4f42ffc73e)
The reason will be displayed to describe this comment to others. Learn more.
Not changed, for the reason in the earlier thread on line 26 of this file. ProbeHTTPTestOrigin's init binds a loopback listener and returns without waiting on a client, so it doesn't block the executor. The suggested move to a GCD worker is the DispatchQueue.global().async pattern that the repository's test-hygiene check rejects.
The reason will be displayed to describe this comment to others. Learn more.
Agreed—the suggestion does not establish that this initializer performs a blocking wait, and the proposed GCD pattern conflicts with the repository’s test-hygiene check. I’d withdraw the suggestion; no change is needed on that basis.
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 settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 1 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:
Preserve subtitle segments when applying media relay processing
Reviewed head: faedd3065f71852461ee85b763fa7f418c6125a9 (unchanged since the last review; the branch already contains current main)
Fit: 9/10 · Readiness: 9/10 · ready (assuming CI is green)
Fit: the double fetch happens in the engine, and the repository's rule is that playback bugs get fixed there, not with host-side workarounds. Sharing the load-time fill removes a second whole-source extraction on slow storage, with no new setting or public API. Readiness: every fix below has a test that failed on the head before it, and the main claim now has a live check. With aetherctl play --host-calls nativesubs --sidecar ... --subs de against an origin that logs each request and trickles the body, main served the sidecar body twice (the store fill and the selection's own decode). This head served it once, logged waits for its store fill, and backfilled the same 800 cues from the finished store. That ran on macOS only; no iOS or tvOS device run.
Rerun on the same head
Replied in the six bot threads that had no answer. Four were already fixed by later commits: the empty-store backfill gated on sharesStoreFill (ee4c15e), the fuller partial kept when the reopen also fails (ff2a160), and cancellation during the reopen (faedd30). Two are unchanged and the replies say why: the ranged reopen is the pre-PR read inside one attempt, not an extra retry, and the test origin's init doesn't block.
CodeRabbit's waiter-order finding: not changed. It needs a subscriber that reselects synchronously from willSet, and every selection path on main writes several published properties before its task or waiter is stored, startSidecarDecode included. Moving this one line would only cover a subscriber on isLoadingSubtitles.
This fork's GitHub CI hasn't run on any pull request since 2026-10-09, so it posted no result for this head. The test results below come from the earlier review's local runs on a Mac.
What the earlier review did on this branch
Merged current main. A .sup sidecar is labelled subrip, and keeps every decoded picture superuser404notfound/AetherEngine#921's bitmap-sidecar path (keepsBitmapPackets, bitmapSource) conflicted with sequentialSource and plainCues; the merge keeps both, and the secondary sidecar takes its sequential flag from the selected candidate, as main takes its preparation policy. The branch keeps its merge-commit history; nothing was rebased.
A sequential text read had no reconnect and no retry. A read cut mid-file failed its open with an I/O error (with a Content-Length) or ended short, so the fill left the native rendition empty or partial, and the overlay got no subtitles: its retry loop only retries a truncation. A cut, refused (other than 401/403/407), or unanswered sequential read now falls back once to the ranged open, and a reopen that also fails reports the fuller cut. A track with a sourceStreamIndex keeps the ranged open whatever its hint.
A failed shared pass over a multi-stream container now releases the targets after the first, so their selections don't wait through every per-target retry.
The empty-fill backfill is gated on sharesStoreFill, stopInternal resets the fill state, a removed track's styled result is evicted, and a cancelled reopen reports cancellation.
Kody's .sup empty-fill and container-sharing findings were already fixed by the third and fourth commits; I replied in each thread.
Codex and Kody on styled ASS inside a container: not changed. codecName reports subrip for those streams, and hosts choose libass from TrackInfo.codec, so raw ASS lines would be drawn as text. The cause is codecName, which predates this PR.
Kody's test-executor finding: not changed. The origin's init doesn't block, and the suggested DispatchQueue.global().async is banned by the test-hygiene check.
Left for the maintainers
An authorized sidecar from an origin that refuses an unranged GET but serves byte ranges still fails. The relay ends the source on any refused request, as it already did on main; only that origin shape is new. Silo's server serves both request shapes.
Follow-ups that predate this PR: codecName labels hint-only bitmap codecs (pgssub, hdmv_pgs_subtitle, dvd_subtitle) as subrip, so they miss the OCR path; the nativeRemoteHLS provider's fill isn't shared with selection.
With preserveASSMarkup, the raw decode of every load-declared ASS track stays in memory for the session alongside the plain store. That's bounded and accepted.
Validation
Validated features: none affected. The board check ran, and no passed case shares code with this change. Validation tasks: is now none: silo-apple#313 and superuser404notfound#314 C4 haven't been run, so there's no validated behavior for this PR to change.
User manual: unaffected. siloserver.org describes sidecar files on disk, not how the player fetches them.
Apple and Android: silo-apple needs no code change, only an engine pin bump once this merges. It reads isLoadingSubtitles, subtitleCues and sidecarASSHeader, and always sends a formatHint. Android uses its own player; I didn't check whether it fetches a sidecar twice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingsize/XL500–999 added + deleted lines (all files); change volume, not priority.triagedHigh-confidence review completed; does not mean fixed, validated, or accepted for release.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Selecting a subtitle declared in
LoadOptions.externalSubtitleswhile the engine's native-store fill is still reading that file started a second download of it. A server that extracts an embedded track reads the whole source for each request, so on network storage the viewer waited through two full extractions. The selection now waits for the running fill and takes its result.Related: Silo-Server/silo-apple#600. This fixes its double-fetch point; it doesn't publish cues incrementally, which needs a streaming WebVTT demux, and superuser404notfound#600's other points stay open. It may also bear on Silo-Server/silo-apple#268, which is not confirmed.
Validation tasks: none
What changed
preserveASSMarkup.SubtitleDecodercan return the plain-text reading of the same packets beside the raw ASS lines (alsoPlainText), so the store gets exactly what it got before, and a styled ASS selection fills from the raw decode, also on a later reselect..sup, PGS, VobSub, DVB) never shares the fill, because the store keeps no image cues; any other track does, and a fill that decodes images reports that it doesn't hold the whole track, so that selection still decodes the sidecar itself..srt,.ass,.ssa,.vtt, and nosourceStreamIndex) is read with one unranged request, in the fill and in every selection's own decode. That request has no reconnect or retry, so a read that is cut mid-file, refused with a status other than an authentication one, or unanswered falls back once to the ranged open, which resumes or retries it; a reopen that also fails reports the fuller cut..supnow reportspgssuband is an OCR entry that never joins the fill.silo-apple pins this fork by revision. The pin bump follows once this merges; no silo-apple pull request depends on it.
Test plan
swift testwith Xcode 27.0. No iOS or tvOS device run.APACEncodePipelineTests, which fails the same way on main, and the authorization suites passed. Each review fix has a test that failed on the head before it.aetherctlfrom main and from this head):aetherctl play --host-calls nativesubs --sidecar de=<url> --subs deon a local H.264 clip, with an 800-cue SRT served by an origin that logs each request and trickles the body over 6 s. Main served the sidecar body twice, once for the store fill and once for the selection. This head served it once with one unranged GET, and the selection waited for the fill and backfilled the same 800 cues. The logs are on the evidence page.Checklist
CHANGELOG.mdupdatedfeat(...),fix(...),chore(...))Evidence: https://evidence.siloserver.org/r/aetherengine/pr-27/
Council review
Rounds: 3, last reviewed ad0fd99 (the final commit after it only turns a cancelled reopen into a cancellation)
Fixed: the shared-pass wait, the ungated empty backfill, a container with a text hint reading sequentially, fill state surviving a teardown, styled results kept for removed tracks, a cut, refused or unanswered sequential read losing the track, and a cancelled reopen reporting a cut. Answered: an ASS stream that
codecNamelabels subrip stays plain on backfill because hosts choose the renderer fromTrackInfo.codec; the remote-HLS provider fill andcodecName's bitmap aliases predate this PR and are left to follow-ups; an authorized sidecar from an origin that refuses unranged GETs but serves ranges still fails, because the relay ends the source on a refusal, as it did on main for any refused request.AI disclosure: fully AI-generated with Claude Code in T3 Code (model claude-opus-5-5), using its shell and file tools, the GitHub CLI, and SwiftPM on a Mac build service. A maintainer approved opening it; no human has run it on a device yet. A separate read-only Claude Code session (claude-opus-5-5) reviewed it at high effort for deadlocks, stuck waits, early-ending fills and styled ASS. It found one issue, a complete fill with no cues still refetched, which the second commit fixes. Kody then found that a
.supsidecar could end up with no subtitles through that empty fill, and that the fix for it was too narrow for subtitle containers and extensionless URLs; the third and fourth commits fix both. A later /silo review (Claude Code, claude-opus-5-5) merged main and added the review fixes; see Council review.🤖 Generated with Claude Code
Note
Share load-declared sidecar store fills with track selection and read text sidecars sequentially
plainCues) alongside raw ASS markup, used to fill stores while keeping the styled result for selection.selectExternalSubtitleTrackin AetherEngine+Subtitles.swift.Macroscope summarized faedd30.