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.2k stars 44 forks source link

Start playing of a playlist with large number of files is extremely slow #2543

Open de666 opened 3 days ago

de666 commented 3 days ago

What version of Music Assistant has the issue?

2.1.0b6

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

2024.6.2

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

The problem

When a playlist with many songs inside (let's say 500 or many) is played (filesystem provider), it takes minutes to start playing. Also when trying to play such playlist from home assistant browse media interface is not possible because it stucks with the loading symbol. The only one way to start playing (delayed by minutes as said before) is from the MA web UI without going inside the playlist.

How to reproduce

Click play on a playlist which has a couple of hunders of file (500/1000)

Music Providers

File system (local disk)

Player Providers

Chromecast

Full log output

No response

Additional information

I don't know how it works but I assume it should work like this:

also if this can be slow, I think it should start playing the first song and then keep searching/loading the next song info and so on but It seems it has to fetch all the songs information before start playing the first song and again I can't figure out why this operation shuold be so slow (hope it has not to fetch all the covers before start playing...).

What version of Home Assistant Core are your running

2024.6.3

What type of installation are you running?

Home Assistant Container

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

OzGav commented 2 days ago

Speed with large playlists does depend on the resources available on the host that the server is running on

de666 commented 2 days ago

Speed with large playlists does depend on the resources available on the host that the server is running on

I know it but I don't understand:

  1. Why it is so slow on a "standard" mini pc with 4 GB of ram
  2. Why this operation requires so much resources, in my mind is not something CPU intensive
  3. why MA has to fetch all the songs info before start playing and this action can't be done asyncrously while playing is yet started
de666 commented 1 day ago

Just an update: I noticed that the huge playlist is loaded almost instantly after the first play action (which takes minutes before playing) like if there was a sort of cache or whatever which has to be "populated" the first time a playlist is loaded/played. Also after the first play, the same playlist is browsable almost flawlessly from the home assistant media browser. Is it possible to do this sort of "loading" task immediately (and in background) when the new playlist is seen/discovered by the library scanner? This behaviour confirms my idea that this is not stritcly related to the hardware resources but more likely to how the playlists are managed.