Announcements

Help Wizard

Step 1

NEXT STEP

Linux - Multiple instances of Spotify running

Solved!

Linux - Multiple instances of Spotify running

Hi community, currently using "spotify-client, 1:1.0.53.758.gde3fc4b2-33, amd64"

 

For a while now (like a 2 months and more maybe) I observe, that Spotify does not limit itself to one instance, and sometimes it keeps running in the background without any UI, icon in notifications tray, whatsoever, after closing the main window. Closing the main window also does not stop playback, playback continues when the spotify process is running without GUI.

 

These can be also observed in PulseAudio, where two sources of playback with Spotify name/icon are shown, and can be controlled independently.

 

Could you advise please?

Reply

Accepted Solutions
Marked as solution

It is a known bug:

 

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/BUG-Linux-Client-does-not-exit-pro...

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Spotify-keeps-playing-after-closin...

 

Very annoying. I haven't figured out if it is only related to newer versions or maybe some other thing has made this happen much more often. It is the reason why 1.0.53 is still only in testing and has not yet been promoted to stable. I have asked some of the developers that mostly work on desktop for mac/win for some extra help here. It is currently the highest prioritized linux issue.

 

A related bug, but not the cause of this one is that you can start two instances. If you try to start a second instance, it should just move the first instance to the front. That is also not fixed.

 

Not shutting down properly is the more important bug.

View solution in original post

14 Replies
Marked as solution

It is a known bug:

 

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/BUG-Linux-Client-does-not-exit-pro...

https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/Spotify-keeps-playing-after-closin...

 

Very annoying. I haven't figured out if it is only related to newer versions or maybe some other thing has made this happen much more often. It is the reason why 1.0.53 is still only in testing and has not yet been promoted to stable. I have asked some of the developers that mostly work on desktop for mac/win for some extra help here. It is currently the highest prioritized linux issue.

 

A related bug, but not the cause of this one is that you can start two instances. If you try to start a second instance, it should just move the first instance to the front. That is also not fixed.

 

Not shutting down properly is the more important bug.

Thank you, can I help you with the development? I'm willing to participate 🙂

 

 

Hi there

 

I created a small bash script that will check if spotify is running before it starts a new instance. If it finds a running instance it will switch focus to the running window instead of starting a new one. 

 

https://github.com/dahlo/spotify_instance_checker

 

Just edit your shortcut to spotify to run this script instead.

Also, with just upgraded version of spotify-client (1:1.0.55.487.g256699aa-16), it now becomes persistent issue.

 

I launch spotify from the terminal, and after a while (not immediately) i close it with alt+f4 (or cmd+q in my window-manager)

 

What is seen on cmdline, first issue raises right after launch, second when I force kill the spotify with `killall spotify`

 

> spotify 
[0528/121848.447579:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain
[0528/134527.106229:ERROR:zygote_communication_linux.cc(216)] Failed to send Reap message to zygote

Does this help you debug the issue in any way? 

I can also reproduce it consistently. It seems like it always hangs when I close it with alt+f4 in Unity while hovering the mouse pointer over the window. If the mouse pointer is outside window it does not hang.

 

I downgraded to 1.0.53 and could reproduce with that one as well, but about 1 of 5 times it did not hang when hovering the mouse pointer over the window.

 

I also downgraded to 1.0.49 and could not reproduce it as easily, but eventually I did make it hang and that happened when the mouse pointer was hovering over the window.

 

I also saw this happen rarely with 1.0.38. I could never reproduce it. It has definitely become worse.

 

Interestingly, this script does work to stop multiple instances of Spotify from running, but for me, it doesn't focus on the currently open window if one is available. 

 

Though I am very much a linux newb, so it could well be that I'm using it incorrectly 🙂

Hmm, i'm guessing it could be that you are either using a different window manager, or that you don't have wmctrl installed. Try installing it and see if that helps.

 

sudo apt-get install wmctrl

wmctrl is a way to communicate with the window manager and telling it to swich focus to the window that matches the process ID you sent to it.

 

GLHF, and welcome to the Linux world 🙂

This is not my case, I have wmctrl 1.07-7+b1 (debian stretch) installed, and I suffer from this bug. However yes, I have i3wm (i3 window manager) instead of GNOME/KDE/XFCE, if that is what you mean by "different wm"

Oh, that is the reason then. It seems like i3 is not controlled by wmctrl,
it has its own programs for doing the things wmctrl does. I have never used
i3 myself, but it seems easy to get it to focus on the window you want.
Have a look at
https://faq.i3wm.org/question/897/is-it-possible-to-focus-a-window-by-name-id-using-i3-msg/
and hopefully you can get it working on your system.

Just replace the wmctrl command in my script with whatever i3-msg command
that will focus on the Spotify window.

Hmm, which window manager do you use? I'm on XFCE currently. I'll have a go
booting to unity or something and see if I still have issues.

@c0ncept: I'm running linux mint cinnamon which uses Muffin (fork of Mutter) as window manager. No idea why it doesn't work for you using xfce. wmctrl even says that xfce is supposed to be supported: http://tripie.sweb.cz/utils/wmctrl/

 

Try running the rows in the script one by one and see if they do what they are supposed to do. It basically gets the pid of the running spotify instance, if any, and tells wmctrl to switch focus to it (wmctrl -ia <pid>).

 

*edit: pasted the wrong url first

I'll give the line by line a run through tonight. Thanks for your help with
this @dachloo 🙂

Thank you very much for your clever little script, worked perfectly for me, i'm a new linux user running OpenSUSE Leap 42.3 🙂


It is very inspiring and now i want to learn bash 😄

The problem where Spotify keeps playing after shutting down has been fixed in 1.0.64.

 

See https://community.spotify.com/t5/Desktop-Linux-Windows-Web-Player/BUG-Linux-Client-does-not-exit-pro... for more detail.

 

Suggested posts