MPMusicPlayerController: after calling prepareToPlay any subsequent call to nowPlayingItem will hang the app

Originator:cljoseph
Number:rdar://33818106 Date Originated:August 9 2017
Status:Fixed Resolved:
Product:iOS SDK Product Version:11 beta 5
Classification:Bug Reproducible:Always
 
I’ve found a really bad regression with MPMusicPlayerController in iOS 11 beta 3 and onward: after calling prepareToPlay the next call to get the nowPlayingItem will hang indefinitely and cause my app (Picky — https://itunes.apple.com/us/app/picky-filter-browse-play-your/id497110916?mt=8) to be terminated by the system. I just tested a build that comments out the prepareToPlay call and the hang went away. I imagine this is related to the known issue that’s been listed in the last few betas: (setting the nowPlayerItem property of MPMusicPlayerController does not work (32258814)). Taking out my prepareToPlay call isn’t ideal because I need that to ensure the nowPlayingItem remains present if the media player has been suspended for an extended period.

Steps to Reproduce:
* Call MPMediaPlayer.systemMusicPlayer.prepareToPlay()
* Do something with MPMediaPlayer.systemMusicPlayer.nowPlayingItem

Expected Results:
* The nowPlayingItem call returns

Observed Results:
* The nowPlayingItem call never returns and the app is terminated

Version:
iOS 11 beta 5

Configuration:
I tested this with an iPhone 7 Plus

Here’s the stack trace for the main thread while it’s hung:

#0	0x0000000180b69bc4 in mach_msg_trap ()
#1	0x0000000180b69a3c in mach_msg ()
#2	0x00000001835a5eb8 in CPDMTwoWayMessage ()
#3	0x00000001835a42c0 in -[CPDistributedMessagingCenter _sendMessage:userInfoData:oolKey:oolData:makeServer:receiveReply:nonBlocking:error:] ()
#4	0x00000001835a3d98 in -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:nonBlocking:] ()
#5	0x00000001835a3ab0 in -[CPDistributedMessagingCenter _sendMessage:userInfo:receiveReply:error:toTarget:selector:context:] ()
#6	0x00000001835a3970 in -[CPDistributedMessagingCenter sendMessageAndReceiveReplyName:userInfo:error:] ()
#7	0x0000000191f4ee28 in -[MPServerObjectProxy _performRemoteSelectorAndReceiveReply:userInfo:timeout:] ()
#8	0x0000000191f4e980 in -[MPServerObjectProxy forwardInvocation:] ()
#9	0x0000000181076414 in ___forwarding___ ()
#10	0x0000000180f5c35c in _CF_forwarding_prep_0 ()
#11	0x0000000191f23da8 in -[MPMusicPlayerController nowPlayingItem] ()

Comments

iOS 11 Beta 6 says it fixes this problem but [[MPMusicPlayerController systemMusicPlayer] nowPlayingItem] still returns nil for me in iOS 11, works fine on iOS 10.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!