launchCameraAsync crashed with no error

#1

I’m trying to use the launchcamerasync sdk and got the following codes from some website. I can use launchImageLibraryAsync with no problem, but not ImagePicker.launchCameraAsync..

It has no error return on console. The Camera opens for a split of a second…and then it just crashes and expo freeze. And nothing happens…

 _pickCamera = async () => {
    const permissions = Permissions.CAMERA;
    const { status } = await Permissions.askAsync(permissions);

   console.log('Permission =>', permissions);
   console.log('Status => ', status);
   console.log(`[ pickFromCamera ] ${permissions} access: ${status}`);
    if (status !== 'granted') {
      Sentry.captureException(new Error(`[ pickFromCamera ] ${permissions} access: ${status}`));
    } else {
      let image = await ImagePicker.launchCameraAsync().catch(error => console.log({ error }));
      console.log(image);
}
}

The above code returns the following in console.log and nothing else. Camera crash. Expo freeze.

10:39:46: Permission => camera
10:39:46: Status => granted
10:39:46: [ pickFromCamera ] camera access: granted

CAMERA_ROLL access was already granted before.

Environment:
OS: macOS High Sierra 10.13.4
Node: 8.11.1
Yarn: 1.6.0
npm: 6.0.1
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: 2.3 AI-162.3764568

Packages: (wanted => installed)
expo: ^27.0.1 => 27.0.2
react: 16.3.1 => 16.3.1
react-native: ~0.55.2 => 0.55.4

#2

Hi-

What phone are you using for this?

Would it be possible to post a whole Snack demonstrating this crash so we can try it on a couple different devices?

Charlie

#3

I’m sorry, after creating the snack and realise it works, i went through more trouble shooting and realise it was because one of the setState was closing the component that was calling the method. This caused the camera to close and the expo app crashed

https://snack.expo.io/rkBaUYzJQ

A silly mistake that wasted my whole day away.

1 Like
closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.