React-native-image-picker: App randomly restart after opening camera

Created on 17 Sep 2019  路  4Comments  路  Source: react-native-image-picker/react-native-image-picker

Bug

Randomly only in one cellphone (Motorola g7) of my client, the app restarts after i try to launch camera, sometimes it works, sometimes it just restarts and today for the first time i got an error screen.

image

It says Network error for somereason, but it is happenning while we try to capture photos from the camera.

Environment info

Library version: "^1.1.0"

React native info output:

React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 1.38 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.12.0 - /usr/local/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 6.10.3 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
      Android SDK:
        API Levels: 28
        Build Tools: 28.0.3, 29.0.2
        System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5692245
      Xcode: 10.3/10G8 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 
    npmGlobalPackages:
      react-native-cli: 2.0.

Steps To Reproduce

handleChoosePhoto = type => {
    const options = {
      title: "Selecione uma Foto",
      chooseFromLibraryButtonTitle: "Escolha de galeria",
      takePhotoButtonTitle: "Tire uma foto",
      noData: true
    };
    ImagePicker.showImagePicker(options, response => {
      if (response.uri) {
        uri =
          Platform.OS === "android"
            ? response.uri
            : response.uri.replace("file://", "");
        this.setState({ [type]: uri });
      }
    });
  };

when this function is evoked trying to open camera it happens when the user taked tge photo, and when he is going to click on the check to save the photo, app restarts/

It should just open the camera normally

Reproducible sample code

class Files extends Component {
  state = {
    file: null,
  };

  handleChoosePhoto = type => {
    const options = {
      title: "Selecione uma Foto",
      chooseFromLibraryButtonTitle: "Escolha de galeria",
      takePhotoButtonTitle: "Tire uma foto",
      noData: true
    };
    ImagePicker.showImagePicker(options, response => {
      if (response.uri) {
        uri =
          Platform.OS === "android"
            ? response.uri
            : response.uri.replace("file://", "");
        this.setState({ [type]: uri });
      }
    });
  };

  render() {
    return (
      <ScrollView>
        <View>
          <TouchableOpacity
            style={{ flex: 1 }}
            onPress={() => this.handleChoosePhoto("file")}
          >
            <Image
              resizeMode="cover"
              source={
                this.state.file
                  ? { uri: this.state.file }
                  : null
              }
            />
            <View>
              <Text>
                File
              </Text>
            </View>
          </TouchableOpacity>
       </ScrollView>
    </View>
   }
}
stale

Most helpful comment

Still experiencing this in production in a few motorola phones, app restarts after selecting a photo from the gallery. Sometimes it works sometimes it resets

All 4 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

any update?

Still experiencing this in production in a few motorola phones, app restarts after selecting a photo from the gallery. Sometimes it works sometimes it resets

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Saad-Bashar picture Saad-Bashar  路  3Comments

OritKedem picture OritKedem  路  4Comments

akishek22 picture akishek22  路  3Comments

dlochynski picture dlochynski  路  4Comments

ozergul picture ozergul  路  3Comments