Open JJ-Author opened 11 months ago
I see the same issue. I started playback using the TransferPlayback dbus method and after some time (much less than 8 hours) the log reports a panic, but the process is still alive so it doesn't get restarted. It didn't crash again when doing introspect and TransferPlayback, but as soon as I opened the Spotify app on another machine I got the second panic and the process died.
Here it is with the backtrace enabled
Hmm, I think I see the problem in the current code: When the application is idle, we currently don't refresh the token and as such, the dbus calls make use of an invalid token.
We are seeing the same thing with our recent build, when MPRIS is polled but spotifyd has been idle for awhile.
amplipi authbind[3093]: The application panicked (crashed).
May 06 15:09:59 amplipi authbind[3093]: Message: called `Result::unwrap()` on an `Err` value: PoisonError { .. }
May 06 15:09:59 amplipi authbind[3093]: Location: src/dbus_mpris.rs:84
May 06 15:09:59 amplipi authbind[3093]: Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
May 06 15:09:59 amplipi authbind[3093]: Run with RUST_BACKTRACE=full to include source snippets.
I am experiencing the same problem and I am willing to take a stab at it. @eladyn any pointers on where/how to solve it?
@2opremio I'm definitely not immersed in the issue right now, but if I recall correctly, the problem is that the refresh token is only refreshed when the Player sends out PlayerEvents
. When there is no playback and only mpris calls however, no refreshing takes place... If you need more guidance, I can surely have a look tomorrow or you just join the Matrix room so we can discuss over there.
The workaround for us was to subscribe to the PropertiesChanged
event on the MPRIS
interface instead of just polling on some interval. Honestly this is probably the better way to do it. If I recall how this works is by the time the PropertiesChanged
event is fired the token has already been refreshed. Here's a link to the python we use to interface with MRPIS now: https://github.com/micro-nova/AmpliPi/blob/main/streams/MPRIS_metadata_reader.py
thanks for sharing @linknum23 but I honestly don't understand why this would be a workaround for the issue I described?? The issues does not involve polling and I was not really interested in the changes of properties but I wanted to call DBUS functions and let a simple and custom piece of media-controller software inspect the current MPRIS players, their capabilities and functions available and the identity string that does exist for that client.
As note/ food for thought for you w.r.t. your use case (track metadata?): given the indicator that the issue is rooted in invalid credentials/token fetching the metadata via the API and the exposing it via MPRIS I have doubts that the PropertiesChanged event is being triggered after the cache is invalid because it can not fetch the new metadata from the API and therefore would not know about any changes. I agree with you that once the token is fresh it can detect the changes and likely emit the signal, but the token will not refresh on its own, without further external stimuli (e.g. controlling via spotify connect) - that seems to be the issue. But maybe that external stimulus is inherent to your use case and that could be why it seems to work for you.
Sorry I probably could have given more context on that. You are correct, our use case is tracking the session metadata. For us, using PropertiesChanged
avoids interfacing to the dbus interface when it is in this bad state. A play request from either Spotify connect or through spotifyd provides the external stimulus in our case.
Description the MPRIS interface on systembus becomes unresponsive after some idle time over the night ( the instance is still visible but not introspectable)
busctl introspect org.mpris.MediaPlayer2.spotifyd.instance365 /org/mpris/MediaPlayer2 Failed to introspect object /org/mpris/MediaPlayer2 of service org.mpris.MediaPlayer2.spotifyd.instance365: Connection timed out
there is an error about credential caching in the log which I do not understand
then I tried this
busctl call org.mpris.MediaPlayer2.spotifyd.instance365 /rs/spotifyd/Controls rs.spotifyd.Controls TransferPlayback Call failed: Connection timed out
and then spotifyd crashed and was restarted by my systemd config after that it was working properly againTo Reproduce
Expected behavior mpris should be instrospectable and responsive all the time if there is a spotify api login problem it should try to automatically login again
Logs
Compilation flags
Versions (please complete the following information):