Alternative for crashing API MPMediaItemArtwork

When setting the now playing info for playing media in MPNowPlayingInfoCenter we can set artwork. But it seems the Apple API for creating the artwork is crashing on iOS 18 (FB15145734). On iOS 17 this gave the warning that the completion handler was not run on the main thread.

I've tried to seek help here: https://stackoverflow.com/questions/78989543/swift-data-race-with-appkit-mpmediaitemartwork-function/78990231?noredirect=1#comment139277425_78990231 but it seems that it's not possible to override the completion handler and therefor it's up to Apple to fix this issue.

.task {
    await MainActor.run {
        let nowPlayingInfoCenter = MPNowPlayingInfoCenter.default()
        var nowPlayingInfo = [String: Any]()
        let image = NSImage(named: "image")!
        // warning: data race detected: @MainActor function at MPMediaItemArtwork/ContentView.swift:22 was not called on the main thread
        nowPlayingInfo[MPMediaItemPropertyArtwork] = MPMediaItemArtwork(boundsSize: image.size, requestHandler: { _ in
            // Not on main thread here!
            return image
        })
        
        nowPlayingInfoCenter.nowPlayingInfo = nowPlayingInfo
    }
}

I'm wondering if there is an alternative method to set the now playing artwork?

Hello @dazboj, thank you for submitting a bug report. If possible, please capture a sysdiagnose and attach it to your bug report. There is no alternative method to set the artwork image in MPNowPlayingInfoCenter.

I have attached a sysdiagnose from my iPhone after the crash.

Alternative for crashing API MPMediaItemArtwork
 
 
Q