gev2002 / react-native-vision-camera-text-recognition

https://www.npmjs.com/package/react-native-vision-camera-text-recognition
MIT License
49 stars 9 forks source link

[IOS Error in useFrameProcessor/useSkiaFrameProcessor]: Frame Processor Error: Property '_WORKLET' doesn't exist, js engine: VisionCamera #14

Closed s-mikulich closed 3 months ago

s-mikulich commented 3 months ago

When I try to send a data from useFrameProcessor (or useSkiaFrameProcessor) I have gotten the error "Frame Processor Error: Property '_WORKLET' doesn't exist, js engine: VisionCamera".

I thought that runOnJS should work, but it doesn't. I have gotten the scanned text, but I couldn't use it outside the useFrameProcessor. Do we have an ability to set the data outside the processor?

"react-native-reanimated": "^3.12.1", "react-native-vision-camera-text-recognition": "^3.1.1", "react-native": "0.74.2", "@shopify/react-native-skia": "^1.3.6"

import { runOnJS, runOnUI } from 'react-native-reanimated'
....

const [value, setValue] = useState()

const frameProcessor = useFrameProcessor((frame) => {
    'worklet'
    const data = scanText(frame)

   runOnJS(setValue)(data)
  }, [])
gev2002 commented 3 months ago

You should use useRunOnJS function from worklets for accessing data or you can import Camera and acces data from callback function.

s-mikulich commented 3 months ago

Thank you very much! It so easy, I don't know why I started to use runOnJS for this purpose.