ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.1k stars 1.55k forks source link

When openCropper called, app unmounts #1435

Open hackrx opened 3 years ago

hackrx commented 3 years ago

Version

-"react-native-image-crop-picker": "^0.35.1",

Platform

Tell us to which platform this issue is related

Expected behaviour

When openCropper called app should not unmount because openCropper is not returning the image path in then()

Actual behaviour

After cropping image, app restarts and navigate to Home screen (Default ) , while I was on Upload screen.

Steps to reproduce

  1. 
    cropReceivedImage = async () => {
    let widthOfImage = 300;
    let heightOfImage = 400;
    console.log('Ca;ling cropper for path', this.state.filePath);
    await ImagePicker.openCropper({
      path: this.state.filePath,
      width: widthOfImage,
      height: heightOfImage,
    })
      .then((image) => {
        console.log('Got cropped image ', image);
        if (this.mount) {
          this.setState({
            filePath: this.props.sharedImages.value,
          });
        }
    
        // also set this filePath to redux
        this.props.setImageInfo(this.props.sharedImages.value);
      })
      .catch((err) => {
        console.log('Got error in cropping', err);
      });
    
    };

2.

componentDidMount(){ this.mount = true; this.cropReceivedImage(); }



### Attachments
When openCropper called, app state is `background`
![image](https://user-images.githubusercontent.com/54453778/95854305-64984400-0d74-11eb-9d2f-9224c0779226.png)
After cropping done
![image](https://user-images.githubusercontent.com/54453778/95854387-8396d600-0d74-11eb-9c4b-a339eb8d1afb.png)
Image argument was expected but it just again mounting the complete app.

// stacktrace or any other useful debug info

Love react-native-image-crop-picker? Please consider supporting our collective:
👉  https://opencollective.com/react-native-image-crop-picker/donate
tobikl1 commented 3 years ago

I had some similar behavior with my app unmounting immediately when putting it into the background and also when opening the cropper from this lib. after hours of research with no results i endet up on this article:

https://medium.com/mindorks/hey-android-please-keep-my-activities-7bf96ccc0a38

turns out, i had activated the option "Don’t Keep Activities" in the developer options of my phone which causes the MainActivity with rn app to be destroyed once you start another activity (like imagecropper)

howg0924 commented 3 years ago

@tobikl1 Maybe you will still experience this issue even you disabled "Don’t Keep Activities" due to #955 ?