Skip to content

connect: preserve continuation on same-context refresh - #1749

Open
paintarm287 wants to merge 2 commits into
librespot-org:devfrom
paintarm287:airpi2/spotify-same-context-preserve-current-dev-20260823
Open

connect: preserve continuation on same-context refresh#1749
paintarm287 wants to merge 2 commits into
librespot-org:devfrom
paintarm287:airpi2/spotify-same-context-preserve-current-dev-20260823

Conversation

@paintarm287

@paintarm287 paintarm287 commented Aug 23, 2026

Copy link
Copy Markdown

Summary

Preserve the existing live next_tracks continuation when Spotify sends an UpdateContext for the same context and the current playback position can still be mapped successfully.

Previously, the current position was mapped correctly but next_tracks was then cleared and rebuilt. This could replace the established continuation with earlier tracks from the same playlist and replay tracks that had already been traversed.

Reproduction

Tested against dev at:

1599145bf2c98660d35b17817b3386767a7e4b42

With shuffle and repeat disabled:

  • next_tracks decreased normally to 61.

  • Spotify sent UpdateContext for the same 97-track playlist.

  • next_tracks jumped from 61 to 79.

  • The following skip decreased it to 78 and replayed a track already traversed earlier in the session.

Fix

For a same-context refresh where the current playback position maps successfully, retain the established live continuation instead of clearing and rebuilding next_tracks.

Genuine context changes continue to use the existing reset/rebuild path.

Validation

With the patch, same-context refreshes preserved the existing continuation:

  • 77 -> 77

  • 75 -> 75

  • 74 -> 74

A subsequent manual skip test continued monotonically from 73 down through 45 with no upward queue reset and no unexpected replay.

The final qualification was also performed with the external replay-protection workaround disabled (SPOTIFY_REPLAY_GUARD=no), confirming that the corrected behaviour came from librespot itself.

Checks

  • cargo fmt --all -- --check

  • git diff --check

  • live A/B reproduction against unmodified and patched dev

@paintarm287

Copy link
Copy Markdown
Author

The failing Clippy check appears unrelated to this PR. CI is running Rust 1.98.0 and fails on clippy::needless_late_init in src/main.rs:1625, which is unchanged by this PR. The remaining CI checks, including builds and cross-compiles, pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant