Skip to content

Replace Jellycompat upstream when the media source changes #750

Description

@Quick104

Problem

The Jellyfin-compatible playback-session reuse path primarily matches the selected play method. When a title has multiple media files, selecting a different media source with the same method can leave the prior upstream session eligible for reuse. That can make a later reconstruction start from the old file even though the requested media source changed.

The stereo-downmix work in #748 validates media-file identity in the persisted recipe and fails closed when it does not match, but the underlying same-method reuse rule applies to playback more broadly.

Acceptance criteria

  • Include media-file identity in every upstream-session reuse and compare-and-swap decision.
  • Close and recreate the upstream when the requested media source differs, even if the play method is unchanged.
  • Preserve the identity through reconstruction and remote-node adoption.
  • Add coverage for direct play, remux, HLS transcode, and concurrent selection of two versions of one item.

Context

Follow-up to #748 and the broader Playback V3 work in #579.

Activity

  1. added
    bug
    triaged
    and removed
    triaged
    on Sep 20, 2026
  2. added theissue type on Sep 20, 2026
  3. removed
    bug
    on Sep 20, 2026
  4. Rhainland commented on Nov 19, 2026

    @Rhainland
    Contributor

    Reproduced on origin/main at bd40bd9 with a local build and a synthetic movie in two versions (1080p, 720p). Under one play, a direct play of the 720p version after the 1080p one streamed the 720p file while the session, Now Playing and the playback log stayed on the 1080p file. The same switch over HLS answered 503 ("transcode recipe does not match the selected media source") and ended the play.

    Cause: ensureUpstreamPlayback reused the play's upstream session whenever the play method matched, without checking which file it streamed.

    Fix in #4572: a request for another version now replaces the upstream session, and only stream-opening requests can do that; child playlists, segments and report revives can't switch a play back. Checked on a local build of the fix with the same steps: the 720p request gets a new session bound to the 720p file, HLS serves 1280x720 segments, and a late 1080p child playlist is refused while the 720p stream keeps playing. Tests cover the switch for direct play, remux and HLS, concurrent starts of two versions, and late playlist and revive requests. Not covered: a switch handled on another API replica still can't stop that replica's copy of the old session until stale cleanup, the same as for play-method switches today.

    AI disclosure: reproduced and fixed by Claude Code (claude-opus-5-5) at the maintainer's direction.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions