react-native-camera / react-native-camera

A Camera component for React Native. Also supports barcode scanning!

Home Page:https://react-native-camera.github.io/react-native-camera/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onBarCodeRead method is getting triggered without scanning QR code or any type of code

leoamato10 opened this issue · comments

onBarCodeRead method is getting triggered without scanning qr. Its only an android issue.

Im using react-native-qrcode-scanner 1.5.4 and react-native-camera 4.2.1 version. Devices used Samsung s9 and Samsung s21 ultra and s10+.

When the RNCamera component is loaded at random time and with the cellphone pointing to the floor it triggers the onBarCodeRead method (I don't know why). It was difficult for me to reproduce this error because I couldn't find a pattern or specific behavior to make it appear.

This is my RNCamera component code:

 <RNCamera>
        androidCameraPermissionOptions={{
          title: this.props.permissionDialogTitle,
          message: this.props.permissionDialogMessage,
          buttonPositive: this.props.buttonPositive,
        }}
        style={[styles.camera, this.props.cameraStyle]}
        onBarCodeRead={this._handleBarCodeRead.bind(this)}
        barCodeTypes={[Camera.Constants.BarCodeType.qr]}
        type={this.props.cameraType}
        flashMode={this.props.flashMode}
        captureAudio={false}
        {...this.props.cameraProps}
      >
        {this._renderCameraMarker()}
   </RNCamera>

If you have any suggestions or ideas please let me know I will be extremely grateful . Also if you need more information just let me know.

i think its related with #2828

UPDATE: Today I achieved to record the issue and here is the video...
This video was shortened because full version lasts 4 minutes

d891a559-d80f-438b-9347-c7db0ff4730f.MP4

I must say that I have made a new app just for testing running this code:


export default class RNCameraa extends PureComponent {
  _handleBarCodeRead(e) {
    alert(e);
  }

  render() {
    return (
      
        
         {
            this.camera = ref;
          }}
          style={styles.preview}
          type={RNCamera.Constants.Type.back}
          flashMode={RNCamera.Constants.FlashMode.on}
          androidCameraPermissionOptions={{
            title: 'Permission to use camera',
            message: 'We need your permission to use your camera',
            buttonPositive: 'Ok',
            buttonNegative: 'Cancel',
          }}
          androidRecordAudioPermissionOptions={{
            title: 'Permission to use audio recording',
            message: 'We need your permission to use your audio',
            buttonPositive: 'Ok',
            buttonNegative: 'Cancel',
          }}
          onBarCodeRead={this._handleBarCodeRead.bind(this)}
        />
 
      
    );
  }

Another Screenshot with error printed on screen:

WhatsApp Image 2021-12-29 at 12 41 20 PM

Here is another screenshot, it seems to scan any type of code:
WhatsApp Image 2021-12-29 at 12 46 34 PM