rodgomesc / vision-camera-code-scanner

VisionCamera Frame Processor Plugin to read barcodes using MLKit Vision QrCode Scanning
MIT License
336 stars 222 forks source link

App crashes when i use this library without warning or error #141

Open gpoul1806 opened 1 year ago

gpoul1806 commented 1 year ago

I use these modules: "react-native": "0.70.6", "react-native-vision-camera": "^2.15.2", "vision-camera-code-scanner": "^0.2.0"

And the app crashes without a warning or an error on the console! P.S. I have asked for camera permission earlier in the app.

Here is my code :

import { useScanBarcodes, BarcodeFormat } from 'vision-camera-code-scanner'; import TextRecognition from '@react-native-ml-kit/text-recognition';

const App = () => { const devices = useCameraDevices(); const device = devices.back; const camera = useRef(null);

const [frameProcessor, barcodes] = useScanBarcodes([BarcodeFormat.QR_CODE], {
    checkInverted: true,
});

return <Camera style={StyleSheet.absoluteFill} device={device} isActive={true} frameProcessor={frameProcessor} frameProcessorFps={5} /> }

Ho3ein-Boka commented 1 year ago

Same Problem

rdelao commented 1 year ago

I am having the same problem, also react-native version "0.70.6"

ray-holland-es commented 1 year ago

Same, but only on Android. iOS works for me

ray-holland-es commented 1 year ago

Maybe merge this? https://github.com/rodgomesc/vision-camera-code-scanner/pull/138

takeruadelbert commented 1 year ago

any update for this issue? still crashes tho, any help? @rodgomesc @ray-holland-es @gpoul1806

takeruadelbert commented 1 year ago

any update for this issue? still crashes tho, any help? @rodgomesc @ray-holland-es @gpoul1806

after further debugging almost for a week,I got this solved by either upgrading the react-native-reanimated version or added config in android/build.gradle. in my case, the crash happened because of that dependency, not vision-camera-code-scanner.

luatvudinh commented 1 year ago

any update for this issue? still crashes tho, any help? @rodgomesc @ray-holland-es @gpoul1806

after further debugging almost for a week,I got this solved by either upgrading the react-native-reanimated version or added config in android/build.gradle. in my case, the crash happened because of that dependency, not vision-camera-code-scanner.

Can you share your react-native-reanimated version and your "added config in android/build.gradle? I has been encountering this issue. Thank you.

takeruadelbert commented 1 year ago

any update for this issue? still crashes tho, any help? @rodgomesc @ray-holland-es @gpoul1806

after further debugging almost for a week,I got this solved by either upgrading the react-native-reanimated version or added config in android/build.gradle. in my case, the crash happened because of that dependency, not vision-camera-code-scanner.

Can you share your react-native-reanimated version and your "added config in android/build.gradle? I has been encountering this issue. Thank you.

@luatvudinh I was using react-native-reanimated version 2.14.1. in my case either upgrade to 2.14.2 or added this config for still using 2.14.1

project.ext.reanimated = [
    buildFromSource: true
]

you need to see what is the error first by debugging or displaying ADB log

professorkolik commented 1 year ago

Fixed for us by not using the hook useScanBarcodes but second approach instead

// Alternatively you can use the underlying function:
  //
  // const frameProcessor = useFrameProcessor((frame) => {
  //   'worklet';
  //   const detectedBarcodes = scanBarcodes(frame, [BarcodeFormat.QR_CODE], { checkInverted: true });
  //   runOnJS(setBarcodes)(detectedBarcodes);
  // }, []);

most likely the reason is different versions of reanimated, though I don't have any proofs

rznzippy commented 1 year ago

Maybe merge this? #138

This changes work for me. I had to apply them manually via patch-package.