I have some UIKit code that makes use of UIGraphicsImageRenderer to create an image from another image. This code is called from the main thread. When the app is run on iOS, there is no issue. But when the same code is run on macOS (via Mac Catalyst), I get the following purple runtime warning in Xcode:
Hang Risk: [Internal] Thread running at User-interactive quality-of-service class waiting on a lower QoS thread running at Default quality-of-service class. Investigate ways to avoid priority inversions
Interestingly, this also only occurs when the UIImage is loaded from an HEIC image file, not when loaded from a JPEG image file.
The relevant code is:
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:finalSize];
return [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) { // Warning on this line
[image drawInRect:CGRectMake(0, 0, finalSize.width, finalSize.height)];
}];
where finalSize is a CGSize and image is a UIImage. The warning is on the line calling renderer imageWithAction.
For those that prefer Swift the code would be:
let renderer = UIGraphicsImageRenderer(size: finalSize)
return renderer.image { context in // Warning on this line
image.draw(in: CGRect(x: 0, y: 0, width: finalSize.width, height: finalSize.height))
}
Nothing in the call stack that gets to this code is making any use of any kind of threading or grand central dispatch. It's all simple method calls on the main thread.
Is there something wrong with my code or is this an issue with Mac Catalyst? Why is it only an issue with HEIC images? Is there anything I can do to fix this? The app is working but I'm worried this could lead to issues in the future.
I'm using Xcode 16.4 and running the app under macOS 15.4.1.
To replicate the issue, take the following steps:
Create a new iOS app project in Xcode based on Storyboard and Swift (or Objective-C if you want).
Add an HEIC to the project so it ends up in the app's resource bundle. This can be a picture taken from your iPhone and Airdropped to your Mac.
In the simple ViewController.swift file, replace the class with the following:
class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Update this to match the picture you added let url = Bundle.main.url(forResource: "IMG_5149", withExtension: "HEIC")! let image = UIImage(contentsOfFile: url.path())! let thumb = scale(image: image) } func scale(image: UIImage) -> UIImage { let finalSize = CGSize(width: 100, height: 100) let renderer = UIGraphicsImageRenderer(size: finalSize) return renderer.image { context in // runtime warning here image.draw(in: CGRect(x: 0, y: 0, width: finalSize.width, height: finalSize.height)) } } }Add support for Mac Catalyst to the target
Build and run the app on your Mac via Xcode
Note the runtime warning (ignore the compiler warning about an unused variable).
If you run the same app on an iOS device, there is no runtime warning.
If you use a JPEG image instead of HEIC, there is no runtime warning, even on macOS.
-
1I've since submitted this as a bug to Apple.HangarRash– HangarRash2025年06月08日 15:16:05 +00:00Commented Jun 8, 2025 at 15:16
-
Yeah, this behavior does seem to have "bug" written all over it.matt– matt2025年06月08日 15:40:01 +00:00Commented Jun 8, 2025 at 15:40
-
1This is still not resolved in macOS 26.0.HangarRash– HangarRash2025年10月22日 18:32:59 +00:00Commented Oct 22, 2025 at 18:32