Skip to content

playback: support instant external text subtitle switching without eager mounting #689

Open

Description

@Quick104

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

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

Activity

  1. added
    triaged
    and removed
    triaged
    on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions