Repository navigation
Description
Summary
Allow a playing client to switch between external SRT/WebVTT tracks without replacing the playback session, replanning the stream, or visibly rebuffering, while ensuring that unselected subtitle files can never delay primary video startup.
This carries forward the product goal from #532 against the platform-neutral protocol-v3 contract established by #567. It does not carry forward #532's parallel subtitle.sidecars response shape.
Current behavior
Protocol v3 exposes the authoritative subtitle inventory in playback_plan.subtitle.inventory. A client can discover external text tracks there, but the safe Media3 path mounts only the selected external artifact: Media3 may eagerly open every mounted sidecar, so mounting the full inventory allows one slow, missing, or duplicate subtitle request to block primary video preparation.
Consequently, changing to another external text track can still require a playback replan and media-item remount, producing a visible interruption.
PR #532 explored advertising and mounting every external text sidecar. That implementation is no longer mergeable against the current playback contract and also synchronously read every eligible SRT/VTT file in full during playback start and replan merely to establish readability/non-emptiness. With no size/count bound or request cancellation, that approach could make subtitle discovery delay playback or consume unbounded memory.
Desired behavior
- Initial video preparation does not wait for any unselected subtitle artifact.
- Once playback has started, selecting another eligible external SRT/VTT track does not create a new playback session, replace the primary media item, or visibly rebuffer.
- The server-owned protocol-v3 subtitle inventory remains the single authoritative list.
- Existing selected-artifact, burn-in, and unnegotiated-client behavior remains compatible.
Acceptance criteria
- Use
playback_plan.subtitle.inventory; do not add a second parallel sidecar inventory or platform-specific wire shape. - Playback plan construction is metadata-only for unselected sidecars. It must not read complete subtitle files or perform unbounded filesystem I/O.
- A slow, missing, empty, oversized, unreadable, or unusually numerous set of unselected sidecars cannot delay or fail primary video startup.
- External subtitle loading is on demand or uses explicitly bounded prefetch/cache behavior with cancellation, timeouts, memory/disk limits, and session authorization preserved.
- Switching external text track A → B → Off → A does not replace the playback session or primary media item and does not visibly rebuffer on capable clients.
- Failed subtitle loading leaves video and the previously working subtitle state usable and allows a retry.
- Reconnect, persisted-attempt replay, and playback replan preserve stable inventory identity without eagerly reopening every sidecar.
- Older/unnegotiated clients retain the current selected-artifact fallback; burn-in routes remain unchanged.
- Focused server tests cover many/large/missing/slow sidecars, cancellation, retry, and session authorization.
- Behavioral validation on the target client records primary-video startup plus repeated external-track switches, including one deliberately slow or failing alternative.
Related work
- feat(playback): enable instant external text subtitle switching #532 — superseded implementation of the same product goal
- feat(playback): finalize platform-neutral protocol v3 #567 — platform-neutral protocol-v3 subtitle inventory
- Subtitle enable mid-playback is slow: on-demand ffmpeg extraction with no caching; compat endpoint buffers whole file #296 — embedded-subtitle extraction latency and caching (related, but a different path)
- Protocol v3 subtitle sidecars are always served by the API node #625 — multi-node subtitle sidecar routing (related transport concern)
The web app does not currently negotiate or use the superseded #532 sidecar feature, so no web UI work is expected unless the eventual server contract changes shared behavior.
AI Disclosure
- Tool(s): OpenAI Codex
- Model(s):
gpt-5.6-sol - Involvement: defect-first source review, contract/history comparison, and issue drafting
- Adversarial review: The proposal was checked against the superseded feat(playback): enable instant external text subtitle switching #532 implementation, the merged neutral-v3 inventory contract, current Media3 mounting behavior, slow/missing/large sidecar failure modes, cancellation and resource bounds, compatibility, retry/reconnect behavior, and adjacent issues Subtitle enable mid-playback is slow: on-demand ffmpeg extraction with no caching; compat endpoint buffers whole file #296 and Protocol v3 subtitle sidecars are always served by the API node #625. The untrusted feat(playback): enable instant external text subtitle switching #532 fork head was not executed.
Activity