callstack / react-native-image-editor

A library providing an API for cropping images from the web and the local file system.
MIT License
383 stars 118 forks source link

getting error in some android devices when cropping the images #148

Open vivek-oyela opened 8 months ago

vivek-oyela commented 8 months ago

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',
    },
  ],
}
retyui commented 8 months ago

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

retyui commented 8 months ago

@vivek-oyela ping

vivek-oyela commented 8 months ago

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,
        });
      }
vivek-oyela commented 8 months ago

This error is mostly on Samsung and Xiaomi devices.