Repository navigation
media: let Spotify and Music take the notch back from a paused app - #16
Merged
Merged
Conversation
When a browser or other app took over from MediaRemote while a Spotify/Music poll was inside osascript, the takeover bumped the refresh generation and cancelled the poll. The poll's defer only cleared refreshTask when its generation was still current, so the handle was never released and requestRefresh refused every later poll. Once that app paused and Spotify started, the hand-off back to AppleScript polled nothing and the paused item stayed on screen. Each poll now records the generation it started with and clears its own handle whatever the current generation is. The empty MediaRemote line before a new item starts a poll about 100 ms before the item arrives, so this hit on almost every takeover. --media-diagnostics, Spotify paused -> VLC plays -> VLC paused -> Spotify plays: before, VLC stayed shown in 3 of 3 runs; after, Spotify took over within 0.5 s.
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.
What changed
A Spotify/Music AppleScript poll that was in flight when a browser or other app took over the notch never released its task handle (the poll's
deferonly clearedrefreshTaskif its generation was still current, and the takeover had bumped it).requestRefreshthen refused every later poll, so after that app paused and Spotify started playing, the notch kept showing the paused item.Each poll now records the generation it started with and clears its own handle regardless of the current generation.
How I tested it
xcodebuild … CODE_SIGNING_ALLOWED=NO build)tools/media-tests/run.sh)--media-diagnosticsrepro (Spotify paused → VLC plays → VLC paused → Spotify plays): before the fix, VLC stayed shown in 3 of 3 runs; after, Spotify took over within 0.5 s in both runs that reached that state. Also checked by hand in the running Debug build.docs/ROADMAP.mdupdated