All right! I seem to have fixed it with your help!
I had an async function to get image artwork to display in table view cells. Each cell would start a Task to call this function.
The function would first attempt to get the media item's embedded artwork as UIImage by calling MPMediaItemArtwork.image(at:). If this returned nil for some reason, it would then attempt to fetch it via MusicKit using a MusicCatalogResourceRequest. This is why the function is async and why the cell makes the call in a Task.
I split this function in two, one for the embedded artwork (sync) and one for MusicKit artwork (async). The cell calls the first one and only if that fails uses a Task to call the other one.
Now it works and when I pause the app I find no 'com.apple.root.user-initiated-qos.cooperative' threads.
I guess the takeaway is that that API is not thread safe but maybe you can provide some other insight given the above backtrace? Thank you!!
Topic:
Programming Languages
SubTopic:
Swift
Tags: