UI freezes when MPMusicPlayerController prepares to play

Hi, thanks for MusicKit.

Using the sample app provided at: https://developer.apple.com/musickit/


The UI will freeze when selecting a song. This is linked to MPMusicPlayerController, which sets the queueIDs of the songs. It is particularly noticeable when selecting multiple songs in a tableView or collectionView. If I select a cell in a collectionView that is associated with MPMusicPlayer's prepareToPlay method, and then quickly select another cell, The UI will almost always freeze. This is not a good user experience.


What can we do to improve MPMusicPlayerController? prepareToPlay will download the song to the device, but can this be dispatched to a background thread? My app experience could be extremely improved, even entertaining, if this can be fixed!


Can anyone give some pointers, or discuss MPMusicPlayerController with me?


I would like to continue working and building with MusicKit, it would be excellent if we can move these download tasks to background threads to free up the UI


Thanks

We are also seeing this 5-8 second freeze with our app. We submitted a bug report on November 3rd along with log files and a simple test app. No reply from Apple yet.


I would suggest anyone else experiencing this submit a bug report also.

I'm getting the same issue. Very laggy when playing or skipping songs. I've subbmitted a bug report, but didn't get a response.

I see similar results when trying to play a track from Apple Music when setting a nowPlayingItem or getting currentPlaybackTime on MPMusicPlayerController. I also submitted bug report in September 2017 - just after the public release of iOS 11 with no action since.


I've coded around the bug making my app usable but with a less than stellar user experience. I keep hoping a fix will magically appear in an updated iOS, but at this point, I'm not optimistic.


Has anyone heard anything from Apple on this?

I'm experiencing the UI freezes since iOS 11.2. Before it was mostly okay if Music.app was closed. Now I get 5-6 seconds of unresponsiveness every time I change a song or just hit play.

I'm working on the bug report but I'm stuck at attaching logs etc. which I'm not yet sure how to obtain. I will look into that, but appearently I shouldn't expect a response anyway. I hope this bug gets fixed asap to be honest. Any third-party app using systemMusicPlayer would be unusable.

@wasp898 I hope you'll submit the bug report. Sometimes it seems no one is working on the issue. But I'm sure there are many moving parts, with most outside my field of observation. And even though I don't understand how Santa gets down the chimney with presents, I still write my wish list ;-) So file that bug report and let's keep our hopes high!

Same experience here. The delay is always related to updating the system player's nowplayingitem or accessing the current playback time.

I just submitted the bug report now after your request. I agree with you actually. Let's hope to hear from them!

I use the "old" MediaPlayer framework with the MPMusicPlayerController and also experience three types of problems in iOS 11 (on iPhone 6 plus):

  1. The app as a whole, like many other apps as well, is very often restarted after having used another app. Before you used to be back in my app where/how you left it.
  2. Loading titles (from the local MPMediaLibrary) and saving the playlist now takes much longer than before.
  3. The user interface freezes up to 8 seconds when you press on another song to play or even just pause/play a song.


This corresponds much with what you report with the MusicKit.


A user told me he had exactly these three types of problems on his own iPhone 6 plus, but to a much lesser degree on his new iPhone 8, probably because of the faster processor.

I'm also experiencing this problem with my app (https://itunes.apple.com/us/app/id1104646834). MusicKit devs, please fix it!

Fixed with iOS 11.3.

Hello folks,

The best way to avoid issues with your apps freezing upon preparing for playback is to call the asynchronous variant of this method: prepareToPlay(completionHandler:). You can either call it with a completion handler, or using the new Swift concurrency syntax.

As an alternative, you could consider replacing your usage of MediaPlayer's MPMusicPlayerController with MusicKit's ApplicationMusicPlayer or SystemMusicPlayer.

I hope this helps.

Best regards,

@JoeKun in my experience there is no difference between using new APIs like ApplicationMusicPlayer on iOS 15-17 and MPMusicPlayerController (possibly because it’s just another layer of abstraction), calling prepareToPlay within a Task also causes the UI to slow down and it often fails when trying to schedule playback of large music collections

UI freezes when MPMusicPlayerController prepares to play
 
 
Q