[MPMediaLibrary defaultMediaLibrary] addItemWithProductID: freezing in iOS 14.0.1

I use addItemWithProductID: in the code below to add an Apple Music track to the user's library. This is mature code that's worked fine previously. But now in iOS 14.0.1 it causes the app to freeze. I can trace when running from Xcode or the released app version from App Store and the app freezes after the line:
NSLog(@"just before addItemWithProductID %@", productID);

The ">>>added..." line is never called.

Any idea as to how to remedy?

Code Block
-(void) addAppleMusicTrackWithProductID: (NSString *) productID
{
        NSLog(@" addApplemUsic has been called for productID: %@", productID);
        SKCloudServiceController *cloudServiceController;
        cloudServiceController = [[SKCloudServiceController alloc] init];
        [cloudServiceController requestCapabilitiesWithCompletionHandler:^(SKCloudServiceCapability capabilities, NSError * _Nullable error){
            NSLog(@"capabilities: %lu error:%@", (unsigned long)capabilities, error);
            if (capabilities >= SKCloudServiceCapabilityAddToCloudMusicLibrary)
            {
                NSLog(@"just before addItemWithProductID %@", productID);
                [[MPMediaLibrary defaultMediaLibrary] addItemWithProductID:productID completionHandler:^(NSArray<__kindof MPMediaEntity *> * _Nonnull entities, NSError * _Nullable error) {
                    NSLog(@">>>added %@ with %i entities: %@ and  error %@",productID, (int) entities.count, entities, error);
                    NSArray *tracksToPlay = [NSArray arrayWithObject:productID];
                    [musicPlayer setQueueWithStoreIDs:tracksToPlay];
                    [musicPlayer play];
                    NSLog(@">>>>now playing AM title:%@ | artist:%@", musicPlayer.nowPlayingItem.title, musicPlayer.nowPlayingItem.artist);
                    
                }];
            }
        }];
}


Replies

I've submitted this via feedback assistant (FB8820341) and used a trouble ticket from my dev account (FYI - they charge you for the incident even if it's a bug and there is no resolution) and it's still an issue in the first iOS 14.3.
I've received no info from Apple on when/if/how this can be fixed.
Hate to be the bearer of bad news but if you're having the same issue, at least you know you're not alone.

Sad to hear there's no fix in 14.3. You're not the only one with this issue, I'll write here if I find any solution. You getting the following errors too?

Code Block language
[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
[iTunesCloud] ACAccountStore 0x282436920 - Error retrieving iTunesStore accounts. err=Error Domain=com.apple.accounts Code=9 "(null)"
[iTunesCloud] ACAccountStore 0x282436920 - Error retrieving local store account. err=Error Domain=com.apple.accounts Code=9 "(null)"
[iTunesCloud] [ICUserIdentityStore] Failed to fetch local store account with error: Error Domain=com.apple.accounts Code=9 "(null)".

@RobertManea Yes, I see those lines in the console for the device, but never get anything in the Xcode console after it hangs.
Thanks for chiming in to let me know I'm not the only one.
BTW - there is another post from a few years ago when a similar (or the same?) bug was present - that post said you could create a playlist, wait a few seconds, then addItemWithProductID would work. But my testing this time around shows that the solution doesn't work ;-(


@davenorfleet Hadn't tried that solution, but good to know it doesn't work lol. Here's another thread I started 2-3 months ago on which I see multiple people are active:

https://developer.apple.com/forums/thread/658557

With a little luck, maybe someone will give us some news there when they find anything.
I just installed iOS 14.3 RC and this bug is still there. Very frustrating that this bug has been in the public iOS and known to Apple for more than 3 months!
Hello @davenorfleet, 

Thank you very much for reporting this issue.

As @RobertManea stated in his response, this is indeed the same issue as the one reported in this other post.

We will investigate this regression.

Thanks again for your feedback.

Best regards, 
Still a bug in iOS 14.4 Beta 2 - 1/13/2021 - 4 months and (painfully) counting....

Same problem here. Commenting so I can follow along.