Skip to content

Fix stale MPRIS player reference after streaming recovery#356

Merged
LargeModGames merged 2 commits into
LargeModGames:mainfrom
OudDriver:main
Jul 9, 2026
Merged

Fix stale MPRIS player reference after streaming recovery#356
LargeModGames merged 2 commits into
LargeModGames:mainfrom
OudDriver:main

Conversation

@OudDriver

Copy link
Copy Markdown
Contributor

Summary

The MPRIS event handler (handle_mpris_events) captured the streaming_player Arc 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_player on every MPRIS event, so any events can target the current active player instead of the player at startup only.

Testing

  • cargo fmt --all
  • cargo clippy --locked -- -D warnings
  • cargo test --locked

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.

OudDriver and others added 2 commits July 9, 2026 18:36
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 LargeModGames merged commit 7431ded into LargeModGames:main Jul 9, 2026
11 checks passed
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.

2 participants