Closed bgalbs closed 8 months ago
I should have mentioned: I’m using the Mantis 2.18.0 package.
@bgalbs Thanks for the report! Can you help to answer the questions below? Did it only happen on iOS 17.3.1? Have tested on previous iOS version too? Did it happen to any images on iOS 17.3.1?
@bgalbs Would it be OK for you to post some sample images here which caused the assertionFailure? Thank you!
Sure! Here’s one image. IMG_2203.HEIC.zip
And, forgive me, the iPhone 15 Pro simulator is running iOS 17.2, and the physical iPhone 15 Pro I’m testing on is running iOS 17.3.1. I’ll try it on an iOS 16.4 simulator and see what happens. Thanks!
https://github.com/guoyingtao/Mantis/assets/26723384/9f21ced6-b146-4cde-85b3-fd1ba7105510
Just tested the image from you on my iPhone(iOS 17.3.1) it worked fine. But I don't have iPhone 15 Pro in hand. My iPhone is an old one.
Oh, interesting. I’ll either use the sample code to crop the image, or write a simple test harness just for this use case, and see if it works for me. Thank you!
Here’s a sample project I made that demonstrates the error. My guess is that this snippet here is the culprit:
let renderer = ImageRenderer(content: profileImage)
if let image = renderer.uiImage {
self.image = renderer.uiImage
self.showCropper = true
}
This is where I convert the SwiftUI Image into a uiImage for use with Mantis. I have a feeling this is not what I should be doing.
Ok, I figured out my problem. I was using SwiftUI’s PhotosPicker to load an image into the SwiftUI Image format, and then using ImageRenderer to convert the SwiftUI Image to a UIImage.
Ignoring the inefficiency of this approach, there was something about the UIImage that was causing this error. When I use UIImagePickerController and receive a UIImage back from the photo picker, Mantis crops it no problem.
So I’ll either update my code to have PhotosPicker return the image data I can use to create a UIImage directly, or I’ll update my project to use UIImagePickerController.
Thanks again for the quick response.
Discussed in https://github.com/guoyingtao/Mantis/discussions/373