react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

[iOS] Blank image returned when compress size above certain value

Open markholland opened this issue 1 year ago • 1 comments

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.41.2
  • react-native v0.73.9

Platform

Tell us to which platform this issue is related

  • iOS physical device (iPhone 15 Pro tested)

Expected behaviour

Picking an image with options:

{
  compressImageMaxHeight: 2049,
  compressImageMaxWidth: 2049
}

To return the resized image.

Actual behaviour

Returns a blank image

Steps to reproduce

Call ImagePicker.openPicker() with options:

{
  compressImageMaxHeight: 2049,
  compressImageMaxWidth: 2049
}

Select an image with the picker

Open image referenced by result.path. It will be blank instead of resized original image.

Description

We encountered an issue after upgrading to versions >= 0.41.0.

We are setting compressImageMaxHeight and compressImageMaxWidth, the issue is that the resized image would be blank.

We narrowed it down to this commit. On the surface it looked like an important change but definitely was the cause of our issue.

After further debugging we discovered that the issue would only occur for values of compressImageMaxHeight/compressImageMaxWidth >= 2049 on iPhone 15 Pro

At which point we noticed a log in the debugger 8196 by 6147 iosurface is too large for GPU

This lead us to issues such as https://stackoverflow.com/questions/61263161/why-use-a-lot-of-memory-when-drawing-image-with-uigraphicsimagerenderer and https://stackoverflow.com/questions/77150918/how-do-i-prevent-uigraphicsimagerenderer-image-from-crashing-when-using-uiimag

Applying the fix found there resolved the issue for us.

Example app can be found here. Image will be blank unless compress size is reduced.

PR with fix here

markholland avatar Jul 19 '24 12:07 markholland

I confirm that issue exists. Tested on physical iPhone 14 iOS 17. Small images are okay, larger ones appear to be blank. Using library version 0.40.3 it still works okay with the same files. Using v. 0.41.2 images appear to be blank after resizing.

compressImageMaxHeight and compressImageMaxWidth are set to 3000 in my case.

wrldh avatar Oct 10 '24 16:10 wrldh