Skip to content

media: let Spotify and Music take the notch back from a paused app - #16

Merged
Vallykrie merged 1 commit into
mainfrom
fix/media-handoff-stuck-poll
Oct 18, 2026
Merged

Vallykrie merged 1 commit into
mainfrom
fix/media-handoff-stuck-poll

Conversation

@Vallykrie

Copy link
Copy Markdown
Owner

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 defer only cleared refreshTask if its generation was still current, and the takeover had bumped it). requestRefresh then 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

  • Builds (xcodebuild … CODE_SIGNING_ALLOWED=NO build)
  • Relevant test scripts pass (tools/media-tests/run.sh)
  • --media-diagnostics repro (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.md updated

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.
@Vallykrie
Vallykrie merged commit cb35a87 into main Oct 18, 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.

1 participant