dopamine icon indicating copy to clipboard operation
dopamine copied to clipboard

[BUG] MacOS Focus Lost After Manually Skipping Songs in Gapless Playback

Open fr-eed opened this issue 1 year ago • 12 comments

When the "Gapless playback" feature is enabled, Dopamine loses media focus after manually skipping a few songs using the "Now Playing" feature in macOS Control Center or multimedia keys. Once Dopamine loses focus, pressing the multimedia keys (play/pause, next/previous) defaults to controlling Apple Music instead of Dopamine.

Steps to Reproduce:

Enable "Gapless playback" in Dopamine.
Restart the app.
Play any song.
Skip a song using multimedia keys or via the macOS Control Center.
Unfocus or close the Dopamine main window.
Skip a song again using multimedia keys or Control Center.
Observe that media focus is lost, and multimedia keys no longer control Dopamine.
Press multimedia keys again, and Apple Music takes over media control.

MacOS version: macOS 15.0.1 Dopamine: 3.0.0-preview.36

fr-eed avatar Oct 22 '24 14:10 fr-eed

@fr-eed Thank you for the bug report. I'll investigate this.

digimezzo avatar Oct 22 '24 18:10 digimezzo

Also to note. Currently Dopamine works weirdly with the Control Center Now Playing widget, after switching a song it disappears for a moment and then appears

fr-eed avatar Oct 22 '24 19:10 fr-eed

@fr-eed Does this also happen when gapless playback is disabled?

digimezzo avatar Oct 22 '24 19:10 digimezzo

@fr-eed Does this also happen when gapless playback is disabled?

Yes

https://github.com/user-attachments/assets/2541e789-8e7b-4b08-861e-0048bbde4fdb

fr-eed avatar Oct 22 '24 19:10 fr-eed

@fr-eed Keep an eye in this build: https://github.com/digimezzo/dopamine/actions/runs/11468241556

It's currently building. As soon as it has artifacts, could you try it out? I tried to fix the problem in it. Thanks!

digimezzo avatar Oct 22 '24 20:10 digimezzo

@fr-eed Keep an eye in this build: https://github.com/digimezzo/dopamine/actions/runs/11468241556

It's currently building. As soon as it has artifacts, could you try it out? I tried to fix the problem in it. Thanks!

So, gapless playback doesn't cause initial bug but now:

  • After selecting any song/skipping, it starts playing for 200 ms and then restarts from the beginning causing it to repeat a sequence.
  • Sometimes previews fail to load in Playing Now widget.

Behavior shown in my video still persists

Maybe MacOS doesn't need the gapless feature at all?

fr-eed avatar Oct 22 '24 21:10 fr-eed

@fr-eed Thanks for the info. This seems more complicated than I thought. I'll test it out here on a macOS Virtual Machine.

digimezzo avatar Oct 23 '24 04:10 digimezzo

@digimezzo Expected behavior for reference

https://github.com/user-attachments/assets/ac123faa-23a9-46bd-9980-6cbc7e5632a4

fr-eed avatar Oct 23 '24 09:10 fr-eed

@fr-eed Could you try out this build? https://github.com/digimezzo/dopamine/actions/runs/11548036703 Thank you.

digimezzo avatar Oct 27 '24 06:10 digimezzo

@fr-eed Could you try out this build? https://github.com/digimezzo/dopamine/actions/runs/11548036703 Thank you.

Works good without gapless playback. Now Playing widget integration works as intended but sometimes author gets updated slower than the music title

With gapless playback original bug still exists but not as consistent. I need to use app for some time for it to appear. It's easier to trigger if you have second player running in the background

Also that still exists with gapless playback on:

After selecting any song/skipping, it starts playing for 200 ms and then restarts from the beginning causing it to repeat a sequence.

fr-eed avatar Oct 28 '24 12:10 fr-eed

@fr-eed Thanks for testing out. Is it possible to make a video of the 200ms problem? I'm not sure how I should reproduce that. Thanks

digimezzo avatar Oct 28 '24 13:10 digimezzo

@fr-eed Thanks for testing out. Is it possible to make a video of the 200ms problem? I'm not sure how I should reproduce that. Thanks

It's an audio issue. I can share a recording later.

After some more testing I've found out that this bug occurs only with wireless headphones. Most likely system wants to sync it with wireless delay and your app overrides it

fr-eed avatar Oct 28 '24 13:10 fr-eed

https://github.com/user-attachments/assets/a606ab76-4894-436c-8331-b7313a239f48

It sounds like this with gapeless playback on with bluetooth headphones connected as main audio output.

Tested on this build: https://github.com/digimezzo/dopamine/actions/runs/11619031390

fr-eed avatar Nov 11 '24 21:11 fr-eed