Spotifyd / spotifyd

A spotify daemon
https://spotifyd.rs
GNU General Public License v3.0
9.86k stars 453 forks source link

MPRIS takes a very long time to respond back to, or is not done internally #1163

Closed apprehensions closed 1 year ago

apprehensions commented 1 year ago

Description D-Bus MPRIS of spotifyd, when requested information by clients, will take a very long time to respond back to.

from the looks of it, spotifyd is CONSTANTLY sending spotify API calls. which i find weird as they can be done internally..

for example, i have a little dockapp called wmusic that retrieves this data. when used along with the official Spotify client it works flawlessly. however, when used with spotifyd, it becomes extremely slow. this is also apparent when attempting to fetch metadata with playerctl; which takes 5 seconds, when using the official Spotify client, it takes 100ms.

Why is spotifyd constantly sending requests to the Spotify API instead of just retrieving the current playing song name internally via some arbitrary struct?

Compilation flags

Versions (please complete the following information):

eladyn commented 1 year ago

Thank you for the report. I assume this is a duplicate of https://github.com/spotifyd/spotifyd/issues/891?

To answer your question, though: In the used version of librespot, unfortunately, nearly none of the metadata that is in theory available to librespot is passed down to spotifyd or accessible in any reasonable way. So we don't really have a different option than sending out those API requests. As such, we have to send some requests, but (depending on the MPRIS clients) most of them are indeed still unnecessary. Some examples:

While I'm aware of all these issues and sort of know how to fix them, I haven't got around to doing it. I'm also currently not sure, if it might be worth doing that with an upcoming major port to librespot 0.5.0 as soon as it's released. There is going to be quite some great stuff coming with this release that will solve almost all our problems and might almost entirely replace the Web API. So I'm not sure if it's better to rewrite the D-Bus module now, considering that we might have to rewrite it completely anyway for the librespot upgrade.

All that is completely hypothetical, though, since I won't have the time in the next month or so to tackle any bigger tasks. If someone else would like to step forward and take care of it, that would of course be great as well!