Fix stale MPRIS player reference after streaming recovery#356
Merged
Conversation
A clone of `streaming_player` was passed directly to the MPRIS event handler during startup. This could lead to MPRIS targeting a stale player instance if the player was recreated (such as during native streaming recovery). This change resolves the issue by: - Removing the static `streaming_player` parameter from `handle_mpris_events`. - Dynamically retrieving the current active player from the `app` state inside the event loop for each incoming event.
LargeModGames
approved these changes
Jul 9, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The MPRIS event handler (
handle_mpris_events) captured thestreaming_playerArc only once at spawn time and held that single reference for the lifetime of the event loop. If the streaming player gets recreated later (e.g. when a streaming recovery happens), the handler kept dispatching media-key commands to the stale player instead of the current one.This is fixed by fetching the fresh
streaming_playeron every MPRIS event, so any events can target the current active player instead of the player at startup only.Testing
I did my own testing for ~24 hours, including multiple sleep/wake cycles of the PC. MPRIS commands still worked.
Additional notes
There's a small theoretical window between fetching current_player and acting on it where the player could be swapped again, but given how infrequent both MPRIS events and recovery events are, and that acting on a soon-to-be-replaced player is a harmless no-op rather than unsafe, this scenario is left unhandled for simplicity.