callstack/react-native-image-editor

getting error in some android devices when cropping the images

Opened this issue · 4 comments

Environment

React native - 0.72.6
react-native-image-editor - 4.0.0

Description

Getting an error in crashlytics when trying to crop the image in Android. This issue is coming in some Samsung and xiaomi devices.

{
  nativeStackAndroid: [
    {
      lineNumber: 574,
      file: 'IoBridge.java',
      methodName: 'open',
      class: 'libcore.io.IoBridge',
    },
    {
      lineNumber: 160,
      file: 'FileInputStream.java',
      methodName: '<init>',
      class: 'java.io.FileInputStream',
    },
    {
      lineNumber: 115,
      file: 'FileInputStream.java',
      methodName: '<init>',
      class: 'java.io.FileInputStream',
    },
    {
      lineNumber: 1523,
      file: 'ContentResolver.java',
      methodName: 'openInputStream',
      class: 'android.content.ContentResolver',
    },
    {
      lineNumber: 326,
      file: 'ImageEditorModuleImpl.kt',
      methodName: 'openBitmapInputStream',
      class: 'com.reactnativecommunity.imageeditor.ImageEditorModuleImpl',
    },
    {
      lineNumber: 194,
      file: 'ImageEditorModuleImpl.kt',
      methodName: 'cropTask',
      class: 'com.reactnativecommunity.imageeditor.ImageEditorModuleImpl',
    },
    {
      lineNumber: 53,
      file: 'ImageEditorModuleImpl.kt',
      methodName: 'access$cropTask',
      class: 'com.reactnativecommunity.imageeditor.ImageEditorModuleImpl',
    },
    {
      lineNumber: 158,
      file: 'ImageEditorModuleImpl.kt',
      methodName: 'invokeSuspend',
      class: 'com.reactnativecommunity.imag',
    },
  ],
}

@vivek-oyela Could you please provide the next things:

  • Error message
  • Android version
  • Simple repo/example to reproduce this bug

I am getting that error in Firebase Crashlytics. It's just that object.
Android versions are 11, 13, and 14.

I am using this way

     for (let i = 0; i < rawImages.length; i++) {
        let cropRatio: any = {};
        if (rawImages[i]?.hasOwnProperty('cropData')) {
          cropRatio = rawImages[i]?.cropData;
        } else {
          cropRatio = calculateImgOffsetAndSize({
            imgHeight: rawImages[i]?.height,
            imgWidth: rawImages[i]?.width,
            rHeight: imageCropperProps.height,
            rWidth: imageCropperProps.width,
          });
        }
        const {uri} = await ImageEditor.cropImage(rawImages[i]?.uri, {
          ...cropRatio,
        });
        newImages.push({
          ...rawImages[i],
          cropData: cropRatio,
          croppedUri: uri,
        });
      }

This error is mostly on Samsung and Xiaomi devices.