[GH-ISSUE #79] Integrated device not shown up "fast enough" on startup #961

Closed
opened 2026-03-14 12:42:11 +03:00 by kerem · 14 comments
Owner

Originally created by @alosarjos on GitHub (Sep 11, 2022).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/79

Lately I've noticed that spotify-player is starting without picking the default device (Which is itself). In the config file is like this:

default_device = "artorias"

[device]
name = "artorias"
device_type = "computer"
volume = 100
bitrate = 320
audio_cache = false

So whenever I open the player, I have to choose a device manually (There it's listed) and then I can play music. Is there some kind of race condition or something for picking the default device maybe?

Originally created by @alosarjos on GitHub (Sep 11, 2022). Original GitHub issue: https://github.com/aome510/spotify-player/issues/79 Lately I've noticed that spotify-player is starting without picking the default device (Which is itself). In the config file is like this: ``` default_device = "artorias" [device] name = "artorias" device_type = "computer" volume = 100 bitrate = 320 audio_cache = false ``` So whenever I open the player, I have to choose a device manually (There it's listed) and then I can play music. Is there some kind of race condition or something for picking the default device maybe?
kerem 2026-03-14 12:42:11 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@aome510 commented on GitHub (Sep 11, 2022):

Lately I've noticed that spotify-player is starting without picking the default device (Which is itself)

@alosarjos can you share one example log of such case?

So whenever I open the player, I have to choose a device manually (There it's listed) and then I can play music.

Does the app display something like "No playback found. Please make sure there is a running Spotify client and try to connect to it using the SwitchDevice command."?

<!-- gh-comment-id:1243010551 --> @aome510 commented on GitHub (Sep 11, 2022): > Lately I've noticed that spotify-player is starting without picking the default device (Which is itself) @alosarjos can you share one example log of such case? > So whenever I open the player, I have to choose a device manually (There it's listed) and then I can play music. Does the app display something like *"No playback found. Please make sure there is a running Spotify client and try to connect to it using the `SwitchDevice` command."*?
Author
Owner

@alosarjos commented on GitHub (Sep 11, 2022):

Sure, I remove some keys/ids I saw since I wasn't sure those should be "public" just in case

And yes, that is exactly the message it says.

spotify-player-22-09-11-19:59.log

<!-- gh-comment-id:1243013321 --> @alosarjos commented on GitHub (Sep 11, 2022): Sure, I remove some keys/ids I saw since I wasn't sure those should be "public" just in case And yes, that is exactly the message it says. [spotify-player-22-09-11-19:59.log](https://github.com/aome510/spotify-player/files/9543220/spotify-player-22-09-11-19.59.log)
Author
Owner

@alosarjos commented on GitHub (Sep 11, 2022):

I'm assuming the issue comes from this info lines:

2022-09-11T17:59:51.802311Z  INFO spotify_player: No playing device found on startup, trying to connect to an available device
2022-09-11T17:59:52.105250Z  INFO spotify_player::client: Available devices: []

Where, for some reason the device is not showing up fast enough?

<!-- gh-comment-id:1243013572 --> @alosarjos commented on GitHub (Sep 11, 2022): I'm assuming the issue comes from this info lines: ``` 2022-09-11T17:59:51.802311Z INFO spotify_player: No playing device found on startup, trying to connect to an available device 2022-09-11T17:59:52.105250Z INFO spotify_player::client: Available devices: [] ``` Where, for some reason the device is not showing up fast enough?
Author
Owner

@alosarjos commented on GitHub (Sep 11, 2022):

The device is correctly initialized, it shows up if I open de device selector and it's also available on the phone app.

<!-- gh-comment-id:1243014468 --> @alosarjos commented on GitHub (Sep 11, 2022): The device is correctly initialized, it shows up if I open de device selector and it's also available on the phone app.
Author
Owner

@aome510 commented on GitHub (Sep 11, 2022):

Thanks for the log and further investigation. Look like a known issue to me.

Where, for some reason the device is not showing up fast enough?

Yes, the reason is the new device is not shown up fast enough when calling get_device API for available devices, at least based on my understanding. I've encountered this issue a few times before. I also made some changes to make it happen less frequently, but I guess they're not enough.

Related discussion: https://github.com/aome510/spotify-player/issues/69#issuecomment-1211556708.

I'll change the title to better reflect the issue. In the meantime, I'll think more about ways to improve this startup process.

<!-- gh-comment-id:1243015568 --> @aome510 commented on GitHub (Sep 11, 2022): Thanks for the log and further investigation. Look like a known issue to me. > Where, for some reason the device is not showing up fast enough? Yes, the reason is the new device is not shown up fast enough when calling `get_device` API for available devices, at least based on my understanding. I've encountered this issue a few times before. I also made some changes to make it happen less frequently, but I guess they're not enough. Related discussion: https://github.com/aome510/spotify-player/issues/69#issuecomment-1211556708. I'll change the title to better reflect the issue. In the meantime, I'll think more about ways to improve this startup process.
Author
Owner

@elkrien commented on GitHub (Sep 16, 2022):

Have the same problem with new version. I had this problem in the past where there was no option for default device. Then after implementing this option it was ok, now after update player acts like it is not reading my config for this option.
When I open player it starts playing on first device on the list (in my situation is Sony TV). It's very frustrating because it turns on tv every time I start player, then I need to change device manually and go downstairs to turn off tv ;)

<!-- gh-comment-id:1249322717 --> @elkrien commented on GitHub (Sep 16, 2022): Have the same problem with new version. I had this problem in the past where there was no option for default device. Then after implementing this option it was ok, now after update player acts like it is not reading my config for this option. When I open player it starts playing on first device on the list (in my situation is Sony TV). It's very frustrating because it turns on tv every time I start player, then I need to change device manually and go downstairs to turn off tv ;)
Author
Owner

@aome510 commented on GitHub (Sep 16, 2022):

It's very frustrating because it turns on tv every time I start player, then I need to change device manually and go downstairs to turn off tv ;)

That's unfortunate it happens again. I'm currently implementing a proper fix (hope so) for this issue. Will ping you guys once it's ready

<!-- gh-comment-id:1249337345 --> @aome510 commented on GitHub (Sep 16, 2022): > It's very frustrating because it turns on tv every time I start player, then I need to change device manually and go downstairs to turn off tv ;) That's unfortunate it happens again. I'm currently implementing a proper fix (hope so) for this issue. Will ping you guys once it's ready
Author
Owner

@alosarjos commented on GitHub (Sep 16, 2022):

@aome510 Sure thing. If you ping me with a branch or a commit I can give it a try before tagging the release if you need it. ;)

<!-- gh-comment-id:1249479479 --> @alosarjos commented on GitHub (Sep 16, 2022): @aome510 Sure thing. If you ping me with a branch or a commit I can give it a try before tagging the release if you need it. ;)
Author
Owner

@aome510 commented on GitHub (Sep 16, 2022):

@alosarjos @elkrien implemented the fix in https://github.com/aome510/spotify-player/pull/81. Can you check it out and try if the new changes fix this issue?

Basically, what I did is to add retries when connecting to the integrated device. That means it ensures that the integrated device is picked on startup but with delay (~ the time it took for the integrated device to be fully initialized).

Regarding the issue after update, I don't particularly know why the integrated device registration is slower now (maybe because of third-party library changes). Let's leave that to a separated issue and do further investigation if the new fix is not enough.

<!-- gh-comment-id:1249916762 --> @aome510 commented on GitHub (Sep 16, 2022): @alosarjos @elkrien implemented the fix in https://github.com/aome510/spotify-player/pull/81. Can you check it out and try if the new changes fix this issue? Basically, what I did is to add retries when connecting to the integrated device. That means it ensures that the integrated device is picked on startup but with delay (~ the time it took for the integrated device to be fully initialized). Regarding the issue after update, I don't particularly know why the integrated device registration is slower now (maybe because of third-party library changes). Let's leave that to a separated issue and do further investigation if the new fix is not enough.
Author
Owner

@alosarjos commented on GitHub (Sep 17, 2022):

@aome510 For my is having a strange behaviour, I keep opening and closing the app and I've seen 3 things happening in all those tries:

  1. Takes a bit of time, but finds the device
  2. Keeps failing when looking for the device
  3. Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found.
<!-- gh-comment-id:1250004097 --> @alosarjos commented on GitHub (Sep 17, 2022): @aome510 For my is having a strange behaviour, I keep opening and closing the app and I've seen 3 things happening in all those tries: 1. Takes a bit of time, but finds the device 2. Keeps failing when looking for the device 3. Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found.
Author
Owner

@elkrien commented on GitHub (Sep 17, 2022):

@aome510 It starts a lot slower now but works fine - no more turning on my TV :)

<!-- gh-comment-id:1250027910 --> @elkrien commented on GitHub (Sep 17, 2022): @aome510 It starts a lot slower now but works fine - no more turning on my TV :)
Author
Owner

@aome510 commented on GitHub (Sep 17, 2022):

  1. Keeps failing when looking for the device
  2. Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found.

Interesting. Will take a look 👀

<!-- gh-comment-id:1250086527 --> @aome510 commented on GitHub (Sep 17, 2022): > 2. Keeps failing when looking for the device > 3. Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found. Interesting. Will take a look 👀
Author
Owner

@aome510 commented on GitHub (Sep 18, 2022):

Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found.

I also experience the same thing occasionally. Looking into the log in that case, it seems that the app displays the playback from the previous run, whose device is shut down but not updated in the Spotify server. Because there is already a running playback at startup, it doesn't try to connect to one. Then, when the shutdown event is known, the playback becomes empty.

Keeps failing when looking for the device

I think this is also because of the same thing as above. The app knows there is one running on startup, so it doesn't look for one.

<!-- gh-comment-id:1250164798 --> @aome510 commented on GitHub (Sep 18, 2022): > Sometimes the playback info is shown (So, device is found) for a split second and then goes back to No playback found. I also experience the same thing occasionally. Looking into the log in that case, it seems that the app displays the playback from the previous run, whose device is shut down but not updated in the Spotify server. Because there is already a running playback at startup, it doesn't try to connect to one. Then, when the shutdown event is known, the playback becomes empty. > Keeps failing when looking for the device I think this is also because of the same thing as above. The app knows there is one running on startup, so it doesn't look for one.
Author
Owner

@aome510 commented on GitHub (Sep 21, 2022):

Should be fixed by #81. I'll close this for now. Feel free to re-open it if encounter any related issues.

<!-- gh-comment-id:1253991028 --> @aome510 commented on GitHub (Sep 21, 2022): Should be fixed by #81. I'll close this for now. Feel free to re-open it if encounter any related issues.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#961
No description provided.