MPMusicPlayerController, set ShuffleMode, App freezes

Hello guys I am currently working on an iOS App that lets you Listen to Music and I am using the

MPMusicPlayerController
for playback!

When setting up the Music Player I also set the shuffleMode but sometimes setting it fails:

[SDKPlayback] Failed validators: {(
        setShuffleMode
    )}


Now I would not really have a problem with the failure since I can try it again later tough a big problem is that when this error occurs the whole App freezes.


Since I can/ should call functions of the MPMusicPlayerController only on the Main Thread I don't know how to prevent this from happening.


Is there some check I can make before trying to set ShuffleMode or any other ways you can think of, preventing the App from Freezing?


Thanks a lot for your help

Could you submit a bug report — ideally with a small sample project that demonstrates the problem — and post the bug number here? That would be a big help in trying to get this narrowed down.

I have the same issue with setting shuffleMode, also with setting repeatMode.


The iOS Music app and MPMusicPlayerController seem to share state under the hood. I've discoverd that the UI freeze/delay is repeatable by: [open the Music app, play a song (briefly), stop play, exit the Music app, kill the music app]. This seems to reset the state of the shared player to an uninitialized state. If you now attempt to set shuffleMode or repeatMode in your app you get a UI freeze while the shared player initializes.


OTOH, if you [open the Music app, play a song, stop play], this seems to initialize the state of the shared player so you get no UI freeze when you set repeat or shuffle mode from your app.


Unfortunately, I haven't yet come up with a workaround based on this undeerstanding...

I was checking the shuffle mode on a background thread, then setting it to the inverse on the main thread, and I was seeing the problem you've described.


I removed the async closures and the error and freezing have gone away.

This issue always happens after a system update or factory reset. The Apple Music Player is not initialized in this case so accessing the below properties will block the main thread. IMHO this is an apple bug and should be fixed.

  _player = [MPMusicPlayerController systemMusicPlayer];
  _shuffleMode = _player.shuffleMode;
  _repeatMode = _player.repeatMode;

Hello @Chrylo,

Thank you very much for the feedback.

Would you mind filing a ticket on Feedback Assistant describing this issue?

Best regards,

Short update: I just updated to the final release of iOS 15 and at least I can't reproduce it anymore. However it was still reproducible with the beta versions...

Hi again @Chrylo,

Thank you very much for taking the time to file this ticket. We'll investigate this issue.

Best regards,

MPMusicPlayerController, set ShuffleMode, App freezes
 
 
Q