Skip to content

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

Open
@markholland

Description

@markholland

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions