Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imagePicker Crashing with Expo 31.0.0 Android 8.1 #2925

Closed
nickjuntilla opened this issue Dec 5, 2018 · 30 comments
Closed

imagePicker Crashing with Expo 31.0.0 Android 8.1 #2925

nickjuntilla opened this issue Dec 5, 2018 · 30 comments
Assignees
Labels
Android ImagePicker needs more info To be used when awaiting reporter response stale

Comments

@nickjuntilla
Copy link

nickjuntilla commented Dec 5, 2018

Environment

Expo CLI 2.4.1 environment info:
System:
OS: macOS 10.14.1
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 9.4.0 - ~/.nvm/versions/node/v9.4.0/bin/node
npm: 6.4.1 - ~/.nvm/versions/node/v9.4.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
expo: ^31.0.2 => 31.0.5
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-31.0.0.tar.gz => 0.57.1
react-navigation: 1.5.11 => 1.5.11
npmGlobalPackages:
expo-cli: 2.4.1

The device crashing is a Moto X4 Android 8.1

Steps to Reproduce

You can try the project here: https://expo.io/@receiptcoin/receiptchain

Taking a photo using the camera doesn't crashes the app.

Here is the code I'm using

async componentDidMount() {
    console.log('camera screen mounted');
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    const cameraRollPermission = await Permissions.askAsync(Permissions.CAMERA_ROLL);
    const status_roll = cameraRollPermission.status;
    console.log('status and status camera is ' , status)
    console.log('status and status roll is ' , status_roll)
    if (status !== 'granted') {
      alert('Please grant app access to the camera so you can upload your photo.');
    }
    if (status_roll !== 'granted') {
      alert('Please grant app access to the camera roll so you can upload your photo.');
    }
    //this.takePhoto();
  }

  takePhoto = async () => {
    console.log('take photo called')
    const pickerResult = await ImagePicker.launchCameraAsync({
      allowsEditing: true,
      aspect: [4, 4],
      exif: true,
    });
    console.log('picker result is ' , pickerResult);
    this.handleImagePicked(pickerResult);

Both permissions are granted on the user's moto X4, but the app still crashes upon the ImagePicker.launchCameraAsync call.

@sjchmiela
Copy link
Contributor

Hey, @nickjuntilla!

Could you please check if the following Snack crashes on your Moto X4? https://snack.expo.io/@sjchmiela/lonely-cookies

I tried reproducing your issue with the code you provided and I couldn't make the app crash. 😕

@vknez
Copy link

vknez commented Dec 11, 2018

The same thing happens both in the "lonely-cookies" snack and in my app on Nexus 5X (Android 8.1.0), no matter whether I run my app locally via expo-cli, or publish it to the Expo server. My version of Expo is 31.0.6.

@nickjuntilla
Copy link
Author

Thanks for helping out. Yes, his phone (MotoX4 Android 8.1) does crash on the snack as well. It crashes right after the cropping happens.

  • Open link
  • shows camera
  • take photo
  • shows trash or checkmark icon page, click checkmark
    - App crashes. Opens again white screen then camera
  • Take photo and get trash or checkmark page
  • Click check and opens crop page
  • click crop and shows Hello there page

Both permissions are granted. The code does work for other versions of android, but I haven't tested any other phones with Android 8.1. I don't have access to any.

@JegoYann
Copy link

JegoYann commented Jan 17, 2019

Hello there,
I do reproduce this issue on my app with my Moto G5S plus (Android 8.1.0).
expo version : 31.0.4

Do we have to find a work around ? Is it only on "Moto" device ? Android 8.1 ?

@sjchmiela
Copy link
Contributor

Could you please try reproducing this issue on SDK32? The problem may have been fixed in-between. 🙃

@IntegralTeam
Copy link

We have this problem as well. Any updates?

@schie
Copy link

schie commented Apr 4, 2019

having a similar issue in an application of mine. We recently update to v32 hoping that it would've fixed the issue, but no dice.

We are experiencing the Application crashing / closing when asking for the permissions:

    await Permissions.askAsync(Permissions.CAMERA);
    await Permissions.askAsync(Permissions.CAMERA_ROLL);

Any updates?

@Latgals
Copy link

Latgals commented Apr 10, 2019

Same problem with launchImageLibraryAsync. The test was performed on the LG-H324 with Android 5.0 and Meizu M6 with Android 7.0. The code has not been changed and is taken from https://docs.expo.io/versions/v32.0.0/sdk/imagepicker/ and from https://snack.expo.io/
The application is closed and restarted sometimes after editing and cropping a photo, sometimes immediately after selecting a photo.

@realioseb
Copy link

I've noticed restarting device helps this problem temporarily.
I mean, if app starts crashing on taking picture I restart device and then it works normally for few times

Can It be an insufficient RAM issue?

@avinashlng1080
Copy link

Guys, do we have an update on this ? The problem persists.

@virtualLast
Copy link

virtualLast commented Jul 2, 2019

Still having this issue using Latest version 9 of android SDK on simulator.


const result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: 'All',
      allowsEditing: false,
      base64: true,
      quality: 1,
      exif: false,
    });
    console.log(result);

    if (!result.cancelled) {
      console.log(result);
      await this.setState({ currentImage: result });
      this.handleCallback();
    }

The first console log never outputs anything

@roger-ngx
Copy link

roger-ngx commented Aug 1, 2019

I got this error on SDK 34

import * as ImagePicker from 'expo-image-picker';
ImagePicker.launchImageLibraryAsync-TypeError: undefined is not an object (evaluating 'n.ImagePicker.launchImageLibraryAsync')

@mujtabaaslam93
Copy link

Any update on this issue?

@roger-ngx
Copy link

not sure but after using expo publish my app can work

@oliverkuchies
Copy link

Issue continues to persist for me.

@danghatam
Copy link

I have the same problem on sdk 33 :(

@AhmSaeed
Copy link

I have the same problem on sdk 34 with physical Nokia 3.1 and Android 7.1 Nougat.

@danghatam
Copy link

I don't know reason why, when we use ImagePicker to take a photo, android kills the app for memory issue.
My solution: i only use ImagePicker to pick image, use expo-camera to take picture instead of ImagePicker

@lukmccall
Copy link
Contributor

Hi everyone, could someone check if this happens on SDK 35? Today, I've checked Nokia 5.1 and Nexus 5X. Everything worked fine.

@lukmccall lukmccall added needs more info To be used when awaiting reporter response and removed needs repro labels Oct 14, 2019
@stephenfairchild
Copy link

I was previously on SDK 34 and was experiencing this issue with the Galaxy S9 simulator. I updated to SDK 35 and everything now seems to work.

@anan474
Copy link

anan474 commented Oct 20, 2019

Same problem on Xiaomi Redmi 6A with android 8.1. I'm using SDK 35 and client version 2.13. Sometime i can take and show the picture but mostly being reloaded without giving error. launchImageLibraryAsync does fine tho.
Any update on this?

@isocra
Copy link

isocra commented Oct 30, 2019

I have the same problem in both SDK33 and SDK35 on my test Samsung SM-T725. Most of the time ImagePicker.launchCameraAsync works fine, but 1 time in 10 or so I get a silent crash and the app reloads. I think it's when I press OK to accept the image, but before any of my code is called because I don't get any logging.

I'm trying to write an app we can provide to our clients so I need it to be robust. Is there likely to be a fix or should I look at ejecting it? Or is Expo just not production ready?

@SimenB
Copy link
Contributor

SimenB commented Nov 18, 2019

We have a user experiencing what I think is the same issue, although we've been unable to reproduce using a similar device. For the people able to reproduce this, any chance of hooking up adb and providing the stack trace here? Might help the Expo developers track down the issue even if unable to reproduce it

@lukmccall lukmccall self-assigned this Nov 18, 2019
@isocra
Copy link

isocra commented Nov 18, 2019

@SimenB: after all we think we've tracked it down to being a memory issue. We watched the device logs (using adb logcat and filtering on the process id) and tracked the amount of free memory reported by the garbage collector. We saw we had a memory leak and when the memory was very low, trying to take a photo just seemed to push the system over the edge and our app was being killed (hence no error to catch). We think we've identified the memory leak (in our code) and our app seems much more stable now. Fingers crossed!

@lukmccall
Copy link
Contributor

I've created PR which optimize ImagePicker. However, I doubt that will help in this case.

I'm still struggling with reproducing this bug.
Could someone provide logs from a device? It will help a lot.

To do this:

  • Enable USB debugging in your device.
  • Connect the device to the computer
  • Use these commands:
    • adb devices (to get your device id)
    • adb -s <id> logcat --pid=$(adb shell pidof -s <your package name>)
      (Expo client package name: host.exp.exponent)

@stale
Copy link

stale bot commented Feb 16, 2020

It's been a while since we've had any activity on this issue, and seeing as it needs more info before we can properly address it, we will be closing it in one month. If you've found a fix, please share it! Otherwise, please provide the info we asked for, especially a reproducible example. Thanks!

@stale stale bot added the stale label Feb 16, 2020
@stale
Copy link

stale bot commented Mar 17, 2020

This issue has been automatically closed since there has not been any recent activity after it was marked as stale. Please open a new issue for any related bugs.

@SimenB
Copy link
Contributor

SimenB commented Jun 19, 2020

@lukmccall I've now gotten a log from the user that is experiencing crashes. Do you have an email address I can forward it to?

@gesposito
Copy link

I can attach crash logs as well (see #7946)

@lukmccall
Copy link
Contributor

@SimenB, please post them using gist or something like this ;) And do it under #7946.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android ImagePicker needs more info To be used when awaiting reporter response stale
Projects
None yet
Development

No branches or pull requests