music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.21k stars 44 forks source link

Deezer - Infinite loading of playlists (no local songs) #2366

Closed brian-maher closed 3 weeks ago

brian-maher commented 1 month ago

What version of Music Assistant has the issue?

2.1.0b1

What version of the Home Assistant Integration have you got installed?

2024.5.1

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

The problem

When browsing/playing certain playlists on Deezer, Music Assistant infinitely loads songs from the playlist. In the UI this manifests as an infinitely scrolling looped list of songs. When trying to play such a playlist, no music plays - instead mass appears to get stuck loading songs, with constant elevated CPU usage and increasing memory usage until it runs out of RAM.

Some playlists are affected, some aren't. It does seem to primarily affect Deezer curated playlists - but I haven't been able to narrow it down further than that.

Logs appear to show nothing beyond DEBUG (MainThread) [music_assistant.music.playlist] Fetching all tracks for playlist Metal Essentials

How to reproduce

  1. Clear the queue and select a player
  2. Load this playlist /#/playlists/deezer/1367442165
  3. Attempt to play the playlist

Music Providers

Deezer

Player Providers

Airplay/Sonos

Full log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2024.5.4

What type of installation are you running?

Home Assistant Container

On what type of hardware are you running?

Alternative

OzGav commented 1 month ago

@arctixdev

brian-maher commented 1 month ago

Have done some digging - the common factor is that these playlists all have a multiple of 50 songs.

https://github.com/music-assistant/server/blob/0dcbe7ea29684063f1a5cf3b85581568a7c829da/music_assistant/server/controllers/media/playlists.py#L301

The playlist above has exactly 50 songs, so the above logic fails. Bodging a quick fix by swapping the While True: on L292 for a hacky page counter/limit works for the player, but not the UI - so I presume there's similar logic in the UI.

arctixdev commented 1 month ago

Ah cool you found the issue! Sorry I haven't looked at it myself.. This should be fixed relatively quickly now then :+1:

marcelveldt commented 3 weeks ago

This one should be fixed in the next (patch) release

OzGav commented 3 weeks ago

@brian-maher Please confirm if this has been fixed

brian-maher commented 3 weeks ago

Thanks @OzGav

It still seems to be present using ghcr.io/music-assistant/server:2.1.0b3, and the looping behavior seems to be present on all playlists now, regardless of length (almost as if the Deezer API isn't returning an empty page as expected by the updated logic?).

OzGav commented 3 weeks ago

Thanks. Can you confirm if playlists other than Deezer are working ok for you?

brian-maher commented 3 weeks ago

Built in playlists are fine - seems to be limited to Deezer!

OzGav commented 3 weeks ago

And still only with a multiple of 50 songs?

brian-maher commented 3 weeks ago

Nope, latest change has regressed the issue to all Deezer playlists.

marcelveldt commented 3 weeks ago

Reproduced and fixed. Fix is available in next (patch) release (2.0.5 / 2.1.0b4)

OzGav commented 3 weeks ago

@brian-maher 2.1.0b4 is released please confirm this is fixed.

brian-maher commented 3 weeks ago

LGTM - Confirmed fixed, all working :)