vision-camera-code-scanner icon indicating copy to clipboard operation
vision-camera-code-scanner copied to clipboard

Getting A signal 11 (SIGSEGV), code 2 (SEGV_ACCERR) when camera captures a QR code

Open yousrasd opened this issue 2 years ago • 11 comments

What were you trying to do?

We are using react-native-vision-camera with vision-camera-code-scanner to capture QR codes.

We use the useScanBarcodes hook to detect QR codes. When testing our application, the app crashes whenever it tries to capture a QR code. When it captures normal text (containing no QR code), the camera continues working. However, whenever it finds a QR code in its viewport, it abruptly crashes. You can view this behaviour bellow:

https://user-images.githubusercontent.com/63681471/214335505-f713cd70-05c8-46f2-bc58-5dfc5ac65fbc.mp4

iPhone devices are working fine. They are able to capture the QR code.

We are using ReactNative version 0.70.6 (we are not using the new architecture).

Reproducible Code

import React, {useEffect, useRef, useState } from 'react';
import { Linking, StyleSheet, View } from 'react-native';
  import {
  Camera,
 } from 'react-native-vision-camera';
import { BarcodeFormat, useScanBarcodes } from 'vision-camera-code-scanner';

const VisionCamera = ({ onRead, isCameraActive, externalStyle = {} }) => {
  const camera = useRef(null);
  const [backCamera, setBackCamera] = useState(undefined);
  const [qrCode, setQrCode] = useState(null);

  const [frameProcessor, barcodes] = useScanBarcodes([
    BarcodeFormat.QR_CODE,  
  ]);
 

  useEffect(() => {
    const getDevices = async () => {
      try {
        const devices = await Camera.getAvailableCameraDevices();
        setBackCamera(devices[0]);
        return devices;
      } catch (err) {
      }
    };
    getDevices();
  }, []);
 
  const onError =  (error) => {
    if (__DEV__) {
      console.log('Camera run time error', error);
    }
  };

  return (
    backCamera && isCameraActive && (
      <>
        <Camera
          photo={false}
          enableHighQualityPhotos={false}
          ref={camera}
          style={[styles.camera, styles.cameraStyle]}
          isActive={true}
          orientation="portrait"
          device={backCamera}
           frameProcessor={frameProcessor}
          frameProcessorFps={1}
          audio={false}
          onError={onError}
        />
      </>
    )
  );
};

What happened instead?

Whenever the camera detects a QR code, it crashes. I found the following stacktrace in Android Studio related to this crash.

A signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x78b8f02c18 2023-01-23 18:01:54.123 22757-22757 DEBUG crash_dump64 A x0 00000078b8f02c18 x1 0000000000000000 x2 b4000079fbfd8770 x3 0000000000000000 2023-01-23 18:01:54.123 22757-22757 DEBUG crash_dump64 A x4 0000000000000008 x5 0000006f3ad39170 x6 00000000ebad808a x7 00000000ebad808b 2023-01-23 18:01:54.123 22757-22757 DEBUG crash_dump64 A x8 434c4e47432b2b00 x9 0000006f3ad38d70 x10 0000006f3ad38d70 x11 0000000000000000 2023-01-23 18:01:54.123 22757-22757 DEBUG crash_dump64 A x12 0000006f3ad370f8 x13 0000000000000000 x14 0000000000000008 x15 0000000000000008 2023-01-23 18:01:54.124 22757-22757 DEBUG crash_dump64 A x16 0000000000000020 x17 0000000000000020 x18 0000006f0a7c2000 x19 0000006f3ad38850 2023-01-23 18:01:54.124 22757-22757 DEBUG crash_dump64 A x20 b4000079fbfd8770 x21 0000000000000002 x22 00000078b8e77048 x23 b40000799c002530 2023-01-23 18:01:54.124 22757-22757 DEBUG crash_dump64 A x24 00000078ad390260 x25 b40000797c0627d0 x26 0000006f3ad39170 x27 0000000000000000 2023-01-23 18:01:54.124 22757-22757 DEBUG crash_dump64 A x28 0000006f3ad3d000 x29 0000006f3ad38760 2023-01-23 18:01:54.124 22757-22757 DEBUG crash_dump64 A lr 00000078cdac8c90 sp 0000006f3ad38760 pc 00000078cdaccbdc pst 0000000060000000

Device

Motorola G Stylus (Android 12)

Lib Version

0.2.0

yousrasd avatar Jan 24 '23 15:01 yousrasd

Did you find any solution how to fix it? The same issue with:

  • "react-native": "0.70.6",
  • "react-native-vision-camera": "^2.15.2",
  • "vision-camera-code-scanner": "^0.2.0",
  • "react-native-reanimated": "^2.14.4",

vrakovs-abc avatar Jan 30 '23 14:01 vrakovs-abc

@vrakovs-abc No, still havent found one

yousrasd avatar Jan 30 '23 14:01 yousrasd

This fork: https://github.com/jorgebrunetto/vision-camera-code-scanner fixed my issue.

vrakovs-abc avatar Feb 01 '23 07:02 vrakovs-abc

@vrakovs-abc oh thats nice, will take a look

yousrasd avatar Feb 01 '23 14:02 yousrasd

also got a similar error but only in production build Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 14227 (pool-46-thread-)

alex-vasylchenko avatar Mar 15 '23 15:03 alex-vasylchenko

This fork: https://github.com/jorgebrunetto/vision-camera-code-scanner fixed my issue.

still the same error

alex-vasylchenko avatar Mar 15 '23 17:03 alex-vasylchenko

@yousrasd did you manage to fix this problem?

alex-vasylchenko avatar Mar 15 '23 17:03 alex-vasylchenko

@alex-vasylchenko unfortunately no

yousrasd avatar Mar 15 '23 18:03 yousrasd

@yousrasd did you start using something else or are you still trying to fix this problem?

alex-vasylchenko avatar Mar 15 '23 18:03 alex-vasylchenko

@alex-vasylchenko yes, started looking into https://github.com/teslamotors/react-native-camera-kit (instead of react-native-vision-camera)

yousrasd avatar Mar 15 '23 18:03 yousrasd