kpcyrd / spotify-launcher

Client for spotify's apt repository in Rust for Arch Linux
Other
174 stars 8 forks source link

Mediakeys result in Spotify-launcher crashing spectacularly #36

Closed MediumRar closed 10 months ago

MediumRar commented 11 months ago

Since switching from Debian to Arch I am having issues using the following media keys:

It basically results in Spotify-launcher crashing in such a manner, that I can only get it back to work by rebooting completely. When other programs are running while spotify is crashing, they will also crash (e.g. steam, firefox, but not St (simple terminal)). While I can start the other programs just fine, spotify-launcher needs a reboot of the machine. Just to clarify, no other programs crash when i press the media keys in and of itself, they just seem to get dragged down by spotify, while IT is crashing ...

I don't think it's related to my setup anymore (DWM catching keypress events -> calling custom script -> calling dbus), since I already tried removing those keybinds as well as replacing them. Replacing them with other keys, such as SUPER+F1 works as expected. Calling my custom script, as well as executing all three of its dbus commands works as expected:

c=""

while getopts c: opt; do
    case $opt in
        c) c="${OPTARG}" ;;
        *) echo 'error in command line parsing' >&2
            exit 1
    esac
done
shift "$(( OPTIND - 1 ))"

function gsde_mediactl_playpause {
    dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
}
function gsde_mediactl_previous {
    dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
}
function gsde_mediactl_next {
    dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
}

if [ -n "${c}" ]; then
    if [ "${c}" = "playpause" ]; then
        gsde_mediactl_playpause
    elif [ "${c}" = "previous" ]; then
        gsde_mediactl_previous
    elif [ "${c}" = "next" ]; then
        gsde_mediactl_next
    fi
fi

Since even removing said key events from my WM resulted in the same crash I highly suspect Spotify itself is doing something with them. I don't know how or why though, since "pretty much the same setup" worked perfectly fine on Debian for me.

Following what happens in journalctl:

Oct 15 12:35:32 pthome kernel: Core Thread[14231]: segfault at 7f1e61e00de3 ip 0000000000bd5222 sp 00007f19a67f9f70 error 4 in spotify[b3e000+141e000] likely on CPU 12 (core 12, socket 0)
Oct 15 12:35:32 pthome kernel: Code: 8b 7f 08 4c 8d 4f 28 48 8b 57 28 4c 89 ce 48 85 d2 74 2b 49 8b 40 10 4c 89 ce 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 31 c9 <48> 39 42 20 0f 9c c1 48 0f 4d f2 48 8b 14 ca 48 85 d2 75 ea 4c 39
Oct 15 12:35:32 pthome systemd[1]: run-user-1000-doc.mount: Deactivated successfully.
Oct 15 12:35:32 pthome systemd[1]: Created slice Slice /system/systemd-coredump.
Oct 15 12:35:32 pthome systemd[1]: Started Process Core Dump (PID 17978/UID 0).
Oct 15 12:35:33 pthome (sd-parse-elf)[18014]: Could not parse number of program headers from core file: invalid Elf' handle
Oct 15 12:35:33 pthome systemd-coredump[18003]: [🡕] Process 14172 (spotify) of user 1000 dumped core.

                                                Module /home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify without build-id.
                                                Module /home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify
                                                Stack trace of thread 14231:
                                                #0  0x0000000000bd5222 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d5222)
                                                #1  0x000000000192e81e n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x172e81e)
                                                #2  0x0000000000c6b88a n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xa6b88a)
                                                #3  0x0000000000c6b3b1 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xa6b3b1)
                                                #4  0x000000000192d976 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x172d976)
                                                #5  0x000000000192d886 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x172d886)
                                                #6  0x00007f19eb0469eb n/a (libc.so.6 + 0x8c9eb)
                                                #7  0x00007f19eb0ca7cc n/a (libc.so.6 + 0x1107cc)

                                                Stack trace of thread 14172:
                                                #0  0x0000000001449091 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1249091)
                                                #1  0x0000000001d21a82 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1b21a82)
                                                #2  0x0000000001d28c6f n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1b28c6f)
                                                #3  0x0000000001d28bde n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1b28bde)
                                                #4  0x0000000001448728 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1248728)
                                                #5  0x00000000014487ce n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x12487ce)
                                                #6  0x00000000010fae7e n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xefae7e)
                                                #7  0x000000000109756e n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xe9756e)
                                                #8  0x00000000010a4fda n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xea4fda)
                                                #9  0x00000000010a51ce n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xea51ce)
                                                #10 0x000000000108a514 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xe8a514)
                                                #11 0x000000000108aa32 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0xe8aa32)
                                                #12 0x0000000001cfc630 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1afc630)
                                                #13 0x00000000013c4ab0 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x11c4ab0)
                                                #14 0x0000000001cfc630 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1afc630)
                                                #15 0x0000000001cff70c n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1aff70c)
                                                #16 0x0000000001cfc64b n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x1afc64b)
                                                #17 0x0000000000bd0aca n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0aca)
                                                #18 0x0000000000bd0aa6 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0aa6)
                                                #19 0x0000000000bd0a9a n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0a9a)
                                                #20 0x0000000000bd0a9a n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0a9a)
                                                #21 0x0000000000bd0a9a n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0a9a)
                                                #22 0x0000000000bd0aa6 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0aa6)
                                                #23 0x0000000000bd0aa6 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0aa6)
                                                #24 0x0000000000bd0a5d n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9d0a5d)
                                                #25 0x0000000000bcbb7e n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x9cbb7e)
                                                #26 0x0000000000b3f2e8 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x93f2e8)
                                                #27 0x0000000000b3e999 n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x93e999)
                                                #28 0x00007f19eafe1cd0 n/a (libc.so.6 + 0x27cd0)
                                                #29 0x00007f19eafe1d8a __libc_start_main (libc.so.6 + 0x27d8a)
                                                #30 0x0000000000b3e8ce n/a (/home/fips/.local/share/spotify-launcher/install/usr/share/spotify/spotify + 0x93e8ce)
                                                ELF object binary architecture: AMD x86-64
Oct 15 12:35:33 pthome systemd[1]: systemd-coredump@0-17978-0.service: Deactivated successfully.
Oct 15 12:35:33 pthome systemd[1]: systemd-coredump@0-17978-0.service: Consumed 1.130s CPU time.
MediumRar commented 11 months ago

I am sorry for the weird formatting, I tried to use proper formatting for the codes and logs, but apparently I am too dumb :D

kpcyrd commented 10 months ago

It's very likely related to your setup. :) The way Xorg works, keys are not "caught" by your window manager, they are broadcast events that applications can register listeners for. Spotify itself is setting up listeners for Play/Pause, Next, Previous and doesn't need further configuration. If you configure them in dwm this just means there are now two applications that are going to be notified for the key event (each application doing their own thing with the event).

spotify should usually "just work" and the keys work just fine for me on gnome 45. More relevant than your window manager is your display manager, the window manager is just positioning and decorating windows (and barely matters for the running application), but your display manager is setting up the environment all your applications run in. If you're currently using startx this is likely causing issues.

Since you're saying you're new to Arch Linux, I suggest this (this is also the configuration I use, but with i3 instead of dwm):

sudo pacman -S lightdm-gtk-greeter
sudo systemctl enable lightdm
reboot
MediumRar commented 10 months ago

@kpcyrd You were absolutely right. It was an issue with my setup. To be more specific with my .xinitrc. In case someone runs into the same or a similar issue:

With Debian I had to add the following to my .xinitrc to get dbus to work properly: exec dbus-launch --exit-with-session dwm

But according to the following Top-Answer this is not needed anymore with newer distros (Debian vs. Arch :D), since dbus will launch dbus via systemd: https://unix.stackexchange.com/questions/363910/dbus-launch-and-dbus-daemon-whats-happening

According to the man page this is actually quite a concern (as I have demonstrated) and provides a convenient way around that, by checking the content of the DBUS_SESSION_BUS_ADDRESS environment variable: if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then https://man.archlinux.org/man/dbus-launch.1

I will just implement that in my .xinitrc to catch both cases :)

Thank you very much for your help !!!