Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPRIS commands are a bit slow #891

Open
Ape opened this issue Feb 5, 2021 · 9 comments · May be fixed by #1317
Open

MPRIS commands are a bit slow #891

Ape opened this issue Feb 5, 2021 · 9 comments · May be fixed by #1317
Labels
blocked by: librespot Issues that are blocked by librespot's upstream bug A functionality or parts of a program that do not work as intended reproducibility: easy An issue that is easily reproduced

Comments

@Ape
Copy link

Ape commented Feb 5, 2021

Description
MPRIS commands to spotifyd usually take aroud half a second, sometimes longer. I'd expect it to react almost instantaneously.

To Reproduce
For example with playerctl status

Versions

  • OS: Arch Linux
  • Spotifyd: 0.3.0-1 from Arch repo
@Ape Ape added the bug A functionality or parts of a program that do not work as intended label Feb 5, 2021
@robinvd robinvd added the reproducibility: easy An issue that is easily reproduced label Feb 8, 2021
@matbme
Copy link

matbme commented Feb 21, 2021

Also worth noting that (at least for me) spotifyd jumps to 100% CPU usage during the delay and then returns to normal usage.

image

@robinvd
Copy link
Contributor

robinvd commented Mar 3, 2021

i think every mpris command does a network request to the spotify api to get the info, so it makes sense it is slow. A better method should be made for this, either caching or preemptively fetch the info on song change.

@matbme Thats weird and definitly a bug!

@robinvd robinvd added help wanted Issues that need help since the assigned person has little to no knowledge about the topic pinned Apply to make stale bot ignore issue/PR. labels Mar 3, 2021
@georgefst
Copy link

georgefst commented Apr 21, 2021

FWIW, it seems not to be all commands. I've found that Play and PlayPause (when it works: see #940) are virtually instant, but I'm seeing the half-second delay for others.

@bbergeron0
Copy link

Turns out playerctl might be at fault here.

MPRIS commands sent with dbus-send are instantaneous, but the same commands sent with playerctl are uncomfortably slow.

playerctl sends a DBus GetAll request before dispatching the actual MPRIS command, which queries all the properties exposed by the DBus interface (In this case, org.mpris.MediaPlayer2.Player), which spotifyd resolves with an obscene amount of HTTP requests.

Maybe spotifyd should implement a workaround for GetAll, maybe playerctl should stop dispatching useless requests, you decide ¯\_(ツ)_/¯.

In the meantime, users can substitute playerctl with dbus-send (Don't forget to replace $PID and $COMMAND):

dbus-send --print-reply --dest="org.mpris.MediaPlayer2.spotifyd.instance$PID" /org/mpris/MediaPlayer2 "org.mpris.MediaPlayer2.Player.$COMMAND"

@eladyn
Copy link
Member

eladyn commented Jan 16, 2023

Thank you for the investigations! I did a small write-up about the current state of things in spotifyd, which might shed some additional light on what is happening behind the scenes here. Nothing that will solve your problems, unfortunately. ;)

@bbergeron0
Copy link

I have to correct myself; playerctl's GetAll requests are actually necessary and serve the purpose of finding which DBUS applications are MediaPlayer2 instances.

@elken
Copy link

elken commented May 29, 2023

In the meantime, users can substitute playerctl with dbus-send (Don't forget to replace $PID and $COMMAND):

dbus-send --print-reply --dest="org.mpris.MediaPlayer2.spotifyd.instance$PID" /org/mpris/MediaPlayer2 "org.mpris.MediaPlayer2.Player.$COMMAND"

I can also confirm this behavior, so for now I've done the same using the below as a template:

dbus-send --print-reply --dest="org.mpris.MediaPlayer2.spotifyd.instance$(pgrep spotifyd)" /org/mpris/MediaPlayer2 "org.mpris.MediaPlayer2.Player.PlayPause"

@DaitiDay
Copy link

DaitiDay commented Oct 31, 2023

I have the same problem, but the delay is around 4s (yes, it's really annoying). Even using dbus-senddo not solve the problem. Any update on this?

Edit: I should have mentioned that I'm on arch and I'm using the spotifydpackage from the extra repository (v 0.3.5)

@eladyn eladyn added blocked by: librespot Issues that are blocked by librespot's upstream and removed help wanted Issues that need help since the assigned person has little to no knowledge about the topic pinned Apply to make stale bot ignore issue/PR. labels Nov 10, 2023
@eladyn
Copy link
Member

eladyn commented Nov 10, 2023

We're mainly waiting for a librespot release here, since then we'll get access to all necessary information to dispatch commands locally.

@eladyn eladyn linked a pull request Dec 27, 2024 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by: librespot Issues that are blocked by librespot's upstream bug A functionality or parts of a program that do not work as intended reproducibility: easy An issue that is easily reproduced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants