2

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:

  1. Create a new iOS app project in Xcode based on Storyboard and Swift (or Objective-C if you want).

  2. 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.

  3. 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))
     }
     }
    }
    
  4. Add support for Mac Catalyst to the target

  5. Build and run the app on your Mac via Xcode

  6. 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.

asked Jun 8, 2025 at 0:16
3
  • 1
    I've since submitted this as a bug to Apple. Commented Jun 8, 2025 at 15:16
  • Yeah, this behavior does seem to have "bug" written all over it. Commented Jun 8, 2025 at 15:40
  • 1
    This is still not resolved in macOS 26.0. Commented Oct 22, 2025 at 18:32

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.