1

Are there any guidelines, benchmarks or similar on what you can expect in terms of loading times, when you're loading a number of tracks (using SPAsyncLoading waitUntilLoaded:timeout:then)?

The reason for me asking is that I've tried loading ~20 tracks in a batch, since the track metadata's going to be used throughout a flow in my client (which is split up in steps, in between which I'd rather not have any loading times aside from an initial delay, which is more acceptable to the user in this case).

I.e. how many tracks are reasonable to attempt loading at once and how long it "should" take? Is loading 20 tracks "a lot"? Does loading a single track itself trigger a number of new request to pull in the metadata, making it a very bad idea trying to load more than a handful at once? And is there any way of finding out why loading of a track failed, aside from it just timing out?

Rather often (maybe 1 out of 10), loading fails after the default 20 s timeout (and I've tried with longer timeouts, without big differences). Sometimes all 20 tracks have failed to load, sometimes only a single track. I daresay that my internet connection stays the same (as much as it could, anyway) in between these attempts (in between which it can be a minute or two).

I realize that there's a lot of fuzzy input here on what's normal and what's not etc. And this obviously depends on a number of factors such as your internet connection, the status of the Spotify servers and such, but maybe it's possible to give some kind of hint on what to expect and if there are any do's and don't specific to the Spotify API.

Kristofer Sommestad
  • 3,061
  • 27
  • 39

1 Answers1

1

Generally, the rule is: only load tracks whose metadata you need to display to the user right now, and perhaps pre-load track that'll be displayed next.

In addition, since CocoaLibSpotify uses a queue, the more load you place on the library, the more overhead you'll have. For example, if you separately SPAsyncLoading a bunch of stuff they'll all be separately queued, but their timers will start instantly. If you enqueue enough stuff, they might not even start loading by the time their timeout fires.

However, since a bunch of queueing goes on internally, this also happens if you throw a ton of stuff into a single SPAsyncLoading call.

To keep things fast, keep it light and try to follow the guideline in the first sentence. In addition, try and keep things efficient:

  • SPAlbumBrowse will load that album's track metadata in one hit, reducing backend load and queueing time.

  • Same for SPArtistBrowse.

  • Same for SPPlaylist, I believe.

iKenndac
  • 18,730
  • 3
  • 35
  • 51