react-native-vision-camera: App Crashes when frameProcessor prop used🐛

What’s happening?

android app crashes then i try to use frameProcessor.it works fine when I comment out the frameprocessor prop.i have pasted the logs please look into it

"react-native": "^0.72.3",
"react-native-vision-camera": "^3.6.8",
"react-native-worklets-core": "^0.2.4"

Reproduceable Code

function App(): JSX.Element {
  const { hasPermission, requestPermission } = useCameraPermission();
  const device = useCameraDevice('front');
  const frameProcessor = useFrameProcessor(() => {
    'worklet'
 /*    const faces = scanFaces(frame)
    console.log(`Faces in Frame: ${faces}`) */
    console.log("Frame Processor");
  }, [])

  useEffect(() => {
    if(!hasPermission)
    {
      requestPermission().then((res) => {
        console.log(res);
      }).catch((e) => {
        console.log(e);
      })
    }
  })

  return (
    hasPermission?
     <View style={{
      flex:1,
     }}>
      <Camera 
      device={device}
      isActive={true}
      style={{
        flex:1,
      }}
      frameProcessor={frameProcessor}      //app don't crash when i remove the frameProcessor
      />
     </View>:
     <View style={{
      flex:1,
      justifyContent:"center",
      alignItems:"center"
     }}>
     <Text>
     Permission Denied
     </Text>
     </View>
  );
}

Relevant log output

2023-11-22 15:36:10.095 22446-22577 AndroidRuntime          com.test2                            E  FATAL EXCEPTION: mrousavy/VisionCamera.video
                                                                                                    Process: com.test2, PID: 22446
                                                                                                    com.facebook.jni.CppException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29
                                                                                                    	at com.mrousavy.camera.frameprocessor.FrameProcessor.call(Native Method)
                                                                                                    	at com.mrousavy.camera.core.VideoPipeline._init_$lambda$0(VideoPipeline.kt:115)
                                                                                                    	at com.mrousavy.camera.core.VideoPipeline.$r8$lambda$EMriwS_FKhtjTFtppM84Z5V8tiI(Unknown Source:0)
                                                                                                    	at com.mrousavy.camera.core.VideoPipeline$$ExternalSyntheticLambda0.onImageAvailable(Unknown Source:2)
                                                                                                    	at android.media.ImageReader$1.run(ImageReader.java:837)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:938)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:241)
                                                                                                    	at android.os.Looper.loop(Looper.java:342)
                                                                                                    	at android.os.HandlerThread.run(HandlerThread.java:67)
2023-11-22 15:36:10.095 22446-22577 ExceptionHandle         com.test2                            I  at com.mrousavy.camera.frameprocessor.FrameProcessor.call(Native Method)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at com.mrousavy.camera.core.VideoPipeline._init_$lambda$0(VideoPipeline.kt:115)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at com.mrousavy.camera.core.VideoPipeline.$r8$lambda$EMriwS_FKhtjTFtppM84Z5V8tiI(Unknown Source:0)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at com.mrousavy.camera.core.VideoPipeline$$ExternalSyntheticLambda0.onImageAvailable(Unknown Source:2)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at android.media.ImageReader$1.run(ImageReader.java:837)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at android.os.Handler.handleCallback(Handler.java:938)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at android.os.Handler.dispatchMessage(Handler.java:99)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at android.os.Looper.loopOnce(Looper.java:241)
2023-11-22 15:36:10.096 22446-22577 ExceptionHandle         com.test2                            I  at android.os.Looper.loop(Looper.java:342)
2023-11-22 15:36:10.097 22446-22577 ExceptionHandle         com.test2                            I  at android.os.HandlerThread.run(HandlerThread.java:67)

Camera Device

{
  "sensorOrientation": "landscape-left",
  "hardwareLevel": "full",
  "maxZoom": 4,
  "minZoom": 1,
  "supportsLowLightBoost": false,
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "supportsFocus": true,
  "supportsRawCapture": false,
  "isMultiCam": false,
  "name": "FRONT (1)",
  "hasFlash": true,
  "hasTorch": true,
  "position": "front",
  "id": "1"
}

Device

Infinix X669C

VisionCamera Version

3.6.8

Can you reproduce this issue in the VisionCamera Example app?

I didn’t try (⚠️ your issue might get ignored & closed if you don’t try this)

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 2
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Thanks to @canibal1 my project works right now.

"react-native": "0.72.3",
"react-native-worklets-core": "^0.2.4",
"react-native-vision-camera": "^3.6.8",
"react-native-reanimated": "^3.5.4",

is the working combination.

Thanks to @whiletruefranz and @canibal1 , I was stuck at this issue for past 2 days, and trying your versions, I was able to make frameprocessors work in my app.

Thanks to @canibal1 my project works right now.

"react-native": "0.72.3",
"react-native-worklets-core": "^0.2.4",
"react-native-vision-camera": "^3.6.8",
"react-native-reanimated": "^3.5.4",

is the working combination.

I didnt get the same error after updating my packages

yarn start --reset cache solved it for me