react-native-vision-camera: πŸ› Error when using frameProcessor on iOS (V3 - RN 0.72.4)

What’s happening?

I want to use the frame processor on iOS, but I get this error

Reproduceable Code

<Camera
          style={{flex: 1}}
          device={device}
          isActive={isFocused}
          onError={onError}
          onInitialized={onInitialized}
          photo={true}
          video={true}
          ref={camera}
          enableZoomGesture={true}
          frameProcessor={frameProcessor}
        />

Relevant log output

libc++abi: terminating with uncaught exception of type facebook::jsi::JSINativeException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29

Camera Device

No response

Device

iPhone X

VisionCamera Version

3.0.0

Can you reproduce this issue in the VisionCamera Example app?

  • I can reproduce the issue in the VisionCamera Example app.

Additional information

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Reactions: 6
  • Comments: 51 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I have seen the log message libc++abi: terminating with uncaught exception of type facebook::jsi::JSINativeException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29 in XCode for React Native 0.72.4 as mentioned. Quite annoying as it prevents custom frame processors.

The error appears to be in the react-native-worklets-core version 0.2.0 package. Seems like properties on the jsi::Function have changed to a double underscore, as observed when outputting each available property from the decorated worklet. Other properties are references correctly, however the PropNameWorkletClosure remained to be _closure and not __closure.

Given that _closure does not exist, we can never retrieve the code that we need. As observed here.

image

Anyway, here is the patch for patch-package to resolve it. It is a renaming of _closure to __closure.

react-native-worklets-core+0.2.0.patch

@fedpre Here is a workaround patch. Not sure of the consequences

Thanks to @SimonJakubowski

index 2c643b3..d8ce821 100644
--- a/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h
+++ b/node_modules/react-native-worklets-core/cpp/WKTJsiWorklet.h
@@ -274,13 +274,13 @@ private:
       jsi::Value locationProp = initDataProp.asObject(runtime).getProperty(
           runtime, PropNameWorkletInitDataLocation);
 
-      if (locationProp.isUndefined() || locationProp.isNull() ||
-          !locationProp.isString()) {
-        return;
-      }
+      // if (locationProp.isUndefined() || locationProp.isNull() ||
+      //     !locationProp.isString()) {
+      //   return;
+      // }
 
-      // Set location
-      _location = locationProp.asString(runtime).utf8(runtime);
+      // // Set location
+      // _location = locationProp.asString(runtime).utf8(runtime);
 
       // Let us try to install the function in the worklet context
       _code = initDataProp.asObject(runtime)

react-native-worklets-core+0.2.1.patch

the issue still exists in release build. Dev build is working!

"react-native": "0.72.5",
"react-native-reanimated": "3.5.4",
"react-native-vision-camera": "3.3.1",
"react-native-worklets-core": "0.2.1",

if hermes is enabled the app crashes with

libc++abi: terminating with uncaught exception of type facebook::jsi::JSINativeException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29

if hermes is disables the app does not crash, but throw the following error when using a frameprocessor

[javascript] Frame Processor threw an error: Unexpected token ')'

In the release build

WKTJsiWorklet.h Line 277

if (locationProp.isUndefined() || locationProp.isNull() ||
          !locationProp.isString()) {
        return;
      }
// Set location
 _location = locationProp.asString(runtime).utf8(runtime);

locationProp is undefined and in the dev build it is defined. I have no idea how to resolve this.

Workaround to get a running release build is to comment out all lines above in WKTJsiWorklet.h

This can happen without reanimated when you forget to add the plugin 'react-native-worklets-core/plugin' to your babel.config.js and tries to use a frameProcessor.

libc++abi: terminating with uncaught exception of type facebook::jsi::JSINativeException: Compiling JS failed: 1:1:invalid empty parentheses '( )' Buffer size 3 starts with: 280a29

Only happens in iOS release build, not debug build for me.

This is related: https://github.com/mrousavy/react-native-vision-camera/issues/1843#issuecomment-1766159431

Here’s a sum up by @bglgwyng:

RNVC 3.2.2 + Reanimated 3.3.0 β†’ Functioning properly RNVC 3.2.2 + Reanimated 3.5.4 β†’ Caused a crash RNVC 3.4.0 + Reanimated 3.3.0 β†’ Caused a crash RNVC 3.4.0 + Reanimated 3.5.4 β†’ Functioning properly

I also see this issue:

libc++abi: terminating due to uncaught exception of type facebook::jsi::JSINativeException: Compiling JS failed: 1:1:invalid empty parentheses β€˜( )’ Buffer size 3 starts with: 280a29

"react-native": "0.72.5",
"react-native-reanimated": "3.4.2",
"react-native-vision-camera": "^3.3.1",
"react-native-worklets-core": "^0.2.2",

Downgrading react-native-reanimated to version ~3.4.2 fixed it for me.

This might be a Reanimated issue. Can you guys reproduce this without reanimated?

react-reanimated 3.4.0 and 3.4.1 have some problems. upgrade react-reanimated

I have the same problem on Android too, but downgrading RN did not work for me πŸ™

@fedpre I ran into the same crash issue downgraded RN to 0.72.3 and worked fine. Used the same versions as vision-camera example app.