React-native-image-crop-picker: App reload when take photo from camera

Created on 20 Sep 2018  路  10Comments  路  Source: ivpusic/react-native-image-crop-picker

I have a problem with take photo from camera. App will reload then click tick button

  • react-native-image-crop-picker v0.21.2
  • react-native v0.57.0

My code:
ImagePicker.openCamera({ width: 640, height: 640, compressImageMaxWidth: 640, compressImageMaxHeight: 640, compressImageQuality: 0.75, cropping: true })

Added to AndroidManifest.xml:
android:largeHeap="true"

Android default config:
multiDexEnabled true
vectorDrawables.useSupportLibrary = true

Any idea?

Love react-native-image-crop-picker? Please consider supporting our collective:
馃憠 https://opencollective.com/react-native-image-crop-picker/donate

Most helpful comment

I think this happens when mainActivity becomes closed (by system) while camera (or gallery) activity is opened.
As mentioned here #505 you can debug this with the option: Settings->Developer options->Apps->Don't keep activities

For me:

  • this happens 1% cases (option off) when I have lack of RAM
  • this happens 100% cases (option on)

I'm not sure that it is possible to completely fix this issue at react-native app.
This need to be investigated by someone with good understanding of android app lifecycle methods and react-native internals.

Keywords for further investigation: onActivityResult, Don't keep activities

If someone will have a solution, please right back a comment.

All 10 comments

+1

  • react-native-image-crop-picker v0.20.3
  • react-native v0.56.0

+1 this happens sometimes for me as well

  • react-native-image-crop-picker v0.20.3

+1 for me as well
some android phones always have that problem, and for others it happens sometimes

+1 :/

  • react-native-image-crop-picker v0.21.3
  • react-native v0.57.5

I think this happens when mainActivity becomes closed (by system) while camera (or gallery) activity is opened.
As mentioned here #505 you can debug this with the option: Settings->Developer options->Apps->Don't keep activities

For me:

  • this happens 1% cases (option off) when I have lack of RAM
  • this happens 100% cases (option on)

I'm not sure that it is possible to completely fix this issue at react-native app.
This need to be investigated by someone with good understanding of android app lifecycle methods and react-native internals.

Keywords for further investigation: onActivityResult, Don't keep activities

If someone will have a solution, please right back a comment.

Any update?

any update?

Any update?

This is not working on devices that have 1gb of RAM. I tested in my phone S7, it's working perfectly but in my old tablet (Samsung Tab E) sometimes works sometimes not.

Any solution?

the company suggests that you need to save the state at the time of onStop, and restore it on onCreate. in MainActivity, but I don't have the code. for those who do not know what to do, there is a solution without using this library. You can output a stream from the camera directly to the react-native app using react-native-camera. And to get photos from the library and crop them, use this library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tximpa91 picture tximpa91  路  3Comments

sergiulucaci picture sergiulucaci  路  3Comments

Phenek picture Phenek  路  3Comments

xuchao321 picture xuchao321  路  3Comments

DISKONEKTeD picture DISKONEKTeD  路  3Comments