Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat: support react-native-vision-camera v3 #139

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

rkmackinnon
Copy link

react-native-vision-camera is currently undergoing a rewrite to a new major version, v3: mrousavy/react-native-vision-camera#1376. This pull request would update vision-camera-code-scanner to support it. This code was tested against commit af4e366 from March 21, 2023 in the v3 branch of react-native-vision-camera.

@rocket13011
Copy link

Hello,

Be careful a self in an override, I'm not sure swift likes that.

just replace self by the class name ;)

@rkmackinnon
Copy link
Author

Hi @rocket13011, thanks for the tip. I have not done too much Swift programming, so I welcome any advice.

It seems like self in this situation is just specifying that the code calls other methods on the same instance of the VisionCameraCodeScanner class. Is there something more complicated happening there?

React-native-vision-camera v3's approach no longer expects a static callback method in frame processor plugins, so I removed the static keywords from this class. Replacing self by the class name wouldn't seem to work anymore with that change, but if it is more idiomatic Swift to avoid using self unnecessarily then just removing it altogether is an option.

@bglgwyng
Copy link

@rkmackinnon I tried installing this branch and got the following error message.

/asdf/node_modules/@bglgwyng/vision-camera-code-scanner/ios/VisionCameraCodeScanner-Bridging-Header.h:1:9: error: include of non-modular header inside framework module 'VisionCameraCodeScanner.VisionCameraCodeScanner_Bridging_Header': '/asdf/ios/Pods/Headers/Public/VisionCamera/FrameProcessorPlugin.h'
#import <VisionCamera/FrameProcessorPlugin.h>

I published the build of this branch to my private npm registry and installed it from the registry.
I suppose the 'example` in this repo would work, but have you tested it with a new project?

@rkmackinnon
Copy link
Author

@bglgwyng I am not familiar with publishing packages to a private npm registry. For the time being I am using this branch without modification by cloning the repo/branch, running npm pack, and referencing the resultant *.tgz file in my project's package.json like so:

"vision-camera-code-scanner": "file:/./packages/vision-camera-code-scanner.tgz"

I don't get any errors using this method. I would assume this *.tgz file is the same as would be generated and used by the npm publish command. Would you be able to give more detail on the exact steps you took to get that error message?

@bglgwyng
Copy link

bglgwyng commented Apr 24, 2023

@rkmackinnon I found the same error occurs using the local zipped package as you suggested.
I suppose that the error is related to my use of use_frameworks! :linkage => :static in Podfile. The project without that option is built well with this branch. However, the old 'vision-camera-code-scanner' worked fine with use_frameworks! :linkage => :static, so I think we need to figure out which change you made caused this difference.

Do you have any idea?

@rkmackinnon
Copy link
Author

@bglgwyng I suspect you're right. I am using Flipper so I do not have use_frameworks! :linkage => :static in my Podfile. It looks like react-native-skia did not add support for use_frameworks! :linkage => :static until Shopify/react-native-skia@9616857, which the oldest supported release is 0.1.176. I based this pull request off of 0.1.175 due to this other issue which to my knowledge hasn't been fixed yet: mrousavy/react-native-vision-camera#1466 (comment).

Regardless, I tried to bump the version of react-native-skia to the latest on my branch in case it contained the fix, enabled the static frameworks option in the example project and unfortunately ran into a bunch of other compilation errors. Despite ostensibly having the new frameworks compatible version of react-native-skia, I was seeing errors akin to Shopify/react-native-skia#652 (comment), where if I removed the path prefix I could get a bit further along in the compilation. That seems to be the wrong way to go about fixing the problem though.

If you were able to get a message specific to vision-camera-code-scanner, you must be doing something differently since skia doesn't seem to be a problem for you. What customizations did you make to the repo after cloning it to get your error message?

@rocket13011
Copy link

rocket13011 commented Apr 24, 2023

For skia patch :

diff --git a/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/DerivedNodeProp.h b/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/DerivedNodeProp.h
index 64b817e..3a9ecb4 100644
--- a/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/DerivedNodeProp.h
+++ b/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/DerivedNodeProp.h
@@ -72,7 +72,7 @@ public:
    Adds a property to the derived property child props.
    */
   template <class _Tp, class... _Args,
-            class = std::_EnableIf<!std::is_array<_Tp>::value>>
+            class = std::enable_if_t<!std::is_array<_Tp>::value>>
   _Tp *defineProperty(_Args &&...__args) {
     auto prop =
         std::make_shared<_Tp>(std::forward<_Args>(__args)..., _onChange);
diff --git a/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/NodePropsContainer.h b/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/NodePropsContainer.h
index 380764c..10f1ac9 100644
--- a/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/NodePropsContainer.h
+++ b/node_modules/@shopify/react-native-skia/cpp/rnskia/dom/base/NodePropsContainer.h
@@ -106,7 +106,7 @@ public:
    Defines a property that will be added to the container
    */
   template <class _Tp, class... _Args,
-            class = std::_EnableIf<!std::is_array<_Tp>::value>>
+            class = std::enable_if_t<!std::is_array<_Tp>::value>>
   _Tp *defineProperty(_Args &&...__args) {
     // Create property and set onChange callback
     auto prop =

@bglgwyng
Copy link

The patch @rocket13011 provides was already applied to the project. I think that's why I didn't see the error related to react-native-skia.
Here I have made a reproducible scenario. Unfortunately, I am unable to determine why the error message is slightly different, and it appears as follows:

/Users/sojaegyeong/Documents/GitHub/RNVC3Sandbox/node_modules/vision-camera-code-scanner/ios/VisionCameraCodeScanner-Bridging-Header.h:1:9: error: 'VisionCamera/FrameProcessorPlugin.h' file not found
#import <VisionCamera/FrameProcessorPlugin.h>
        ^
<unknown>:0: error: could not build Objective-C module 'VisionCameraCodeScanner'

Regardless, it is still true that the use of use_frameworks! :linkage => :static is the determining factor in the successful build.

@rkmackinnon Could you please test this repo and tell me if you can see the same error message?
I'll let you know as soon as I succeed at reproducing the exact same error message I reported yesterday.

@rkmackinnon
Copy link
Author

Hi @bglgwyng, I can confirm I see the same error message while testing your repo. Thanks for taking the time to put that together. I will have to look at the differences between your repo and the example project in the vision-camera-code-scanner to figure out the skia errors I was getting, but I will move forward with working on the error message in your repo first.

@rkmackinnon
Copy link
Author

Hi again @bglgwyng. I was able to fix the error you were getting. There is a missing dependency on the VisionCamera library in the podspec file for VisionCameraCodeScanner. I will push a new commit to my branch to fix this. Unfortunately, the code still doesn't compile though. Now your project and mine are both experiencing the same errors I was talking about with skia. Maybe you'll have some more luck than I have been having fixing that, but I have not given up on it yet!

Fixes File Not Found errors importing VisionCamera public header files in the VisionCameraCodeScanner bridging header.
@bglgwyng
Copy link

@rkmackinnon, thank you very much for your prompt response! I gave your latest commit a try, and the first time I ran it, I noticed that the error I previously reported was no longer present. However, it was replaced with a new issue related to 'react-native-skia'. Luckily, I was already familiar with how to resolve this type of problem, and I found a solution in this link: Shopify/react-native-skia#652 (comment).

Nevertheless, the strange thing is that even after I applied the fix, I encountered the 'error: could not build Objective-C module 'VisionCameraCodeScanner' again. You can observe this behavior in the following commit: bglgwyng/RNVC3Sandbox@4c65b2f.

@rkmackinnon
Copy link
Author

rkmackinnon commented Apr 26, 2023

@bglgwyng It has been pleasant going back and forth with you on this as well. I believe I have fixed the latest issue you reported. If you pull from my branch again and re-run npm pack the package should be able to be used with use_frameworks! :linkage => :static or without it.

I added a patch to the react-native-vision-camera library that essentially added an empty VisionCamera.h file to satisfy its complaints. I'm not sure if that's the best way to solve the problem, but it works! I tested it in the example project with use_frameworks! :linkage => :static as well as in my private repo that doesn't currently have that option.

@bglgwyng
Copy link

bglgwyng commented Apr 27, 2023

@rkmackinnon, I followed your instructions as directed, but unfortunately, it did not work. Here is the commit. I have included the same patch file for 'react-native-vision-camera'. Can you please tell me what I may have done incorrectly?

Furthermore, it would be nice to report the 'VisionCamera.h' issue on the V3 issue tracker (mrousavy/react-native-vision-camera#1376), since it appears to be a general problem across all frame processor modules.

@rkmackinnon
Copy link
Author

Hi @bglgwyng, I took a look at your patch. I see you have patched the podspec file to include the reference to VisionCamera.h, but it looks like you maybe forgot to create the empty VisionCamera.h file in the patch as well? My patch from https://github.com/rodgomesc/vision-camera-code-scanner/blob/4dcfeabd3cd41564257e3ec1b0824f3a39b15014/.yarn/patches/react-native-vision-camera-https-95cda75d0b.patch also includes this part:

diff --git a/VisionCamera.h b/VisionCamera.h
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391

That is a good suggestion about commenting on the VisionCamera.h file on the V3 issue tracker. There is actually an older issue mrousavy/react-native-vision-camera#1043 about it that I could comment on as well, but I think I should probably do both as that older one might not be actively monitored anymore.

@bglgwyng
Copy link

Your fix works. Thank you!

@AnomalousLLC
Copy link

Register plugin(s) outside of AppDelegate: AnomalousLLC@5d37292

No need to register Swift plugins manually after installation, maintains out of the box Expo support without prebuild/ejecting.

@joacub
Copy link

joacub commented Sep 29, 2023

@joacub

... and frameprocessor works now in android

Are you sure? When I tried it it didn't compile for Android.

Vision camera is working in android and iOS perfectly no problems I have been using since version 3.0 with no issues.

@rkmackinnon
Copy link
Author

rkmackinnon commented Sep 29, 2023

Certainly some frame processors would've worked with version 3.0, but not this one. There was a bug in version 3.0 that caused iOS frame processors not to pass in any of their options (which I included a patch for) and for Android frame processors that had options with array properties to not expose them to native code. In version 3.1 those bugs were fixed, but the new changes to add back in the OpenGL processing pipeline included new bugs that caused all Android frame processors to crash again. In version 3.2 those bugs seem to have been partially fixed.

You are welcome to submit a PR to my repo (the underlying repo that this PR is based on) if I am wrong about this.

@rkmackinnon
Copy link
Author

Please try this out. The example app should be working with both iOS and Android now.

#if defined __has_include && __has_include("VisionCameraCodeScanner-Swift.h")
#import "VisionCameraCodeScanner-Swift.h"
#else
#import <VisionCameraCodeScanner/VisionCameraCodeScanner-Swift.h>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's this -Swift.h file located?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an auto-generated file. The location is slightly different depending on whether the project is built with use_frameworks! :linkage => :static.

image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another thing, i did install this version. but whenever open the camera with frameProcessor, it crashes. any idea?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide any more details of the crash (e.g., logs, exception messages) or your test environment?

Copy link

@mare95 mare95 Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I experienced the same issue. Camera works great but when i attach frameProcessor it crashes the app. This is the log i get from the xCode. Do you know what could be a solution for this issue?

VisionCamera.didSetProps(_:): Updating 16 prop(s)...
VisionCamera.configureCaptureSession(): Configuring Session...
VisionCamera.configureCaptureSession(): Initializing Camera with device com.apple.avfoundation.avcapturedevice.built-in_video:6...
VisionCamera.configureCaptureSession(): Adding Video input...
VisionCamera.configureCaptureSession(): Adding Video Data output...
VisionCamera.invokeOnInitialized(): Camera initialized!
VisionCamera.configureCaptureSession(): Session successfully configured!
VisionCamera.configureFormat(): Configuring Format...
VisionCamera.configureFormat(): Format successfully configured!
VisionCamera.configureDevice(): Configuring Device...
VisionCamera.configureDevice(): Device successfully configured!
VisionCamera.didSetProps(_:): Starting Session...
VisionCamera.didSetProps(_:): Started Session!
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

I'm using these dependencies:
VisionCamera (3.2.2):
RNReanimated (3.5.4):
React (0.72.5)

Btw thanks @rkmackinnon for the effort!

@chernandezq
Copy link

chernandezq commented Oct 2, 2023

How can I test this PR @rkmackinnon ?

@rkmackinnon
Copy link
Author

How can I test this PR @rkmackinnon ?

You can run the example app in the repo this PR is based on: https://github.com/rkmackinnon/vision-camera-code-scanner/tree/react-native-vision-camera-v3

@superR8014
Copy link

Hi @rkmackinnon
I try to Install with your latest commit, but shows below error
`$ bob build
ℹ Building target commonjs
ℹ Cleaning up previous build at lib/commonjs
ℹ Compiling 2 files in src with babel
✔ Wrote files to lib/commonjs
ℹ Building target module
ℹ Cleaning up previous build at lib/module
ℹ Compiling 2 files in src with babel
✔ Wrote files to lib/module
ℹ Building target typescript
ℹ Cleaning up previous build at lib/typescript
ℹ Generating type definitions with tsc
⚠ Failed to locate 'tsc' in the workspace. Falling back to the globally installed version. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.
example/src/Constants.ts:2:34 - error TS2307: Cannot find module 'react-native-static-safe-area-insets' or its corresponding type declarations.

2 import StaticSafeAreaInsets from 'react-native-static-safe-area-insets';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in example/src/Constants.ts:2`

I have already tried to add 'react-native-static-safe-area-insets' this package but not useful.
Is there any suggestions?
Thanks!

@rkmackinnon
Copy link
Author

Hmm, I am using yarn to develop this package so it might be there are some tricky bits with working from source with npm. Try running yarn once you're in the example directory instead.

@superR8014
Copy link

superR8014 commented Oct 3, 2023

Hmm, I am using yarn to develop this package so it might be there are some tricky bits with working from source with npm. Try running yarn once you're in the example directory instead.

Thanks for your reply. Maybe I describe my problem not so clear.

I tried to download the package run in local with your suggestion "run yarn in the example directory" could run the project successfully.

But now I want to use this package to replace the original v0.2.0 vision-camera-code-scanner in my current project. So I just yarn add https://github.com/rkmackinnon/vision-camera-code-scanner.git#react-native-vision-camera-v3 in my project but it gives me below error.
`$ bob build
ℹ Building target commonjs
ℹ Cleaning up previous build at lib/commonjs
ℹ Compiling 2 files in src with babel
✔ Wrote files to lib/commonjs
ℹ Building target module
ℹ Cleaning up previous build at lib/module
ℹ Compiling 2 files in src with babel
✔ Wrote files to lib/module
ℹ Building target typescript
ℹ Cleaning up previous build at lib/typescript
ℹ Generating type definitions with tsc
⚠ Failed to locate 'tsc' in the workspace. Falling back to the globally installed version. Consider adding typescript to your devDependencies or specifying the tsc option for the typescript target.
example/src/Constants.ts:2:34 - error TS2307: Cannot find module 'react-native-static-safe-area-insets' or its corresponding type declarations.

2 import StaticSafeAreaInsets from 'react-native-static-safe-area-insets';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in example/src/Constants.ts:2

`
I currently using react-native 0.72.4. Your help will be greatly appreciated.

@hssrrw
Copy link

hssrrw commented Oct 3, 2023

I'm experiencing the same problem. Somehow a new dependency in the examples (react-native-static-safe-area-insets) requires it to be installed, but we don't use it.

A possible solution would be either (1) somehow ignore the dependencies from examples folder or (2) change the example to avoid the new dependency.

UPD: The error persists even if I add react-native-static-safe-area-insets as a dependency.

@hssrrw
Copy link

hssrrw commented Oct 3, 2023

Locally cloning and switching to this branch gives the same error when trying npm install.
I confirm, yarn works. However, we don't use yarn in our project. Looks like currently there is some incompatibility with npm cli but I am not sure what is it exactly.

@hssrrw
Copy link

hssrrw commented Oct 3, 2023

@rkmackinnon I know, Dimensions API might not be reliable on Android. That's probably why react-native-static-safe-area-insets was added in the first place. However, would that be sufficient to use just Dimensions in the example? Maybe we don't need precise window size for the demo purpose? I tested without this dependency and the package is installed in our project without any problem with npm.

You can check the changes here:
https://github.com/hssrrw/vision-camera-code-scanner/blob/4fb4a66340fdf922d6b859a617d10323fe171aec/example/src/Constants.ts

@mare95
Copy link

mare95 commented Oct 3, 2023

After spending hours on debugging and understanding why my app crashes i figured that it's related to 'react-native-reanimated'.

This is the error:
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

I'm using reanimated package for all different kind of animations and it can't be removed. These packages used to work well in V2.

Example app works but when i install react-native-reanimated: "^3.5.4" and when i add ['react-native-reanimated/plugin'] in babel.config.js => app crashes when there is a frameProcessor attached to the <Camera /> component.

Steps to reproduce this:

  • Clone project
  • Checkout to vision-camera-code-scanner-v3
  • cd into example project
  • Add "react-native-reanimated": "^3.5.4", package
  • open babel.config.js and update it like this
const pak = require('../package.json');

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        extensions: ['.tsx', '.ts', '.js', '.json'],
        alias: {
          [pak.name]: path.join(__dirname, '..', pak.source),
        },
      },
    ],
    ['react-native-worklets-core/plugin'],
    ['react-native-reanimated/plugin'],
  ],
};
  • Install dependencies and pods
  • Open example/ios in xCode (Version 15.0 (15A240d))
  • Build the app
    => When you scan the code app will crash (see attached image)

Do you know what could be the reason and why vision-camera-code-scanner and react-native-vision-camera don't work with react-native-reanimated anymore?

Btw this all worked with v2 but i had to update it for iOS 17 and iPhone 15
Screenshot 2023-10-03 at 17 12 26

@mare95
Copy link

mare95 commented Oct 3, 2023

After spending hours on debugging and understanding why my app crashes i figured that it's related to 'react-native-reanimated'.

This is the error: 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

I'm using reanimated package for all different kind of animations and it can't be removed. These packages used to work well in V2.

Example app works but when i install react-native-reanimated: "^3.5.4" and when i add ['react-native-reanimated/plugin'] in babel.config.js => app crashes when there is a frameProcessor attached to the <Camera /> component.

Steps to reproduce this:

  • Clone project
  • Checkout to vision-camera-code-scanner-v3
  • cd into example project
  • Add "react-native-reanimated": "^3.5.4", package
  • open babel.config.js and update it like this
const pak = require('../package.json');

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        extensions: ['.tsx', '.ts', '.js', '.json'],
        alias: {
          [pak.name]: path.join(__dirname, '..', pak.source),
        },
      },
    ],
    ['react-native-worklets-core/plugin'],
    ['react-native-reanimated/plugin'],
  ],
};
  • Install dependencies and pods
  • Open example/ios in xCode (Version 15.0 (15A240d))
  • Build the app
    => When you scan the code app will crash (see attached image)

Do you know what could be the reason and why vision-camera-code-scanner and react-native-vision-camera don't work with react-native-reanimated anymore?

Btw this all worked with v2 but i had to update it for iOS 17 and iPhone 15 Screenshot 2023-10-03 at 17 12 26

Solution was to bump "react-native-worklets-core": "^0.2.0" to "react-native-worklets-core": "^0.2.1"

@rkmackinnon
Copy link
Author

rkmackinnon commented Oct 3, 2023

@superR8014 @hssrrw I believe this latest commit will fix the issue with react-native-static-safe-area-insets while still allowing it to be used in the example project. Thanks for helping test this.

@rkmackinnon
Copy link
Author

@mare95 Thanks for all your time on this, it is much appreciated. We do not use reanimated so had not run into this incompatibility ourselves. I will bump the react-native-worklets-core version on this branch.

@xhoantran
Copy link

xhoantran commented Oct 4, 2023

Verified this work on iOS. Thanks @rkmackinnon

@superR8014
Copy link

superR8014 commented Oct 4, 2023

@superR8014 @hssrrw I believe this latest commit will fix the issue with react-native-static-safe-area-insets while still allowing it to be used in the example project. Thanks for helping test this.

Thank you so much!
Just test with your latest commit now can yarn install smoothly and build success on xcode 14.3.1.
The build application run perfectly and functioning normally with frame processor enabled On IOS.

But for android there seems have some problem with enabling frame processor.
With enabled frame processor, after turn on the camera the app will crash within 1-2 seconds.
Disable frame processor will not cause the app force quit when turn on the camera but it can't scan any qr code.
Checked Logcat shows below error:

Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x77a01e19f8 in tid 23358 (ionCamera.video), pid 23092

image

I currently using react native 0.72.4, react-native-reanimated 3.5.4, react-native-worklets-core 0.2.1 and react-native-vision-camera 3.2.2

Your help will be greatly appreciated.

@vietdung97
Copy link

vietdung97 commented Oct 4, 2023

@rkmackinnon I faced this crash issue on release build. Do you have any ideas what may cause this?

MY ENV:
"react-native": "0.72.4",
"react-native-reanimated": "^3.4.2",
"react-native-vision-camera": "^3.2.2",
"react-native-worklets-core": "^0.2.1",

ERROR LOGS:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 3

Thread 3 name: Dispatch queue: /VisionCamera.video
Thread 3 Crashed:
0 libsystem_kernel.dylib 0x1e9ac2274 __pthread_kill + 8
1 libsystem_pthread.dylib 0x1f8b1c654 pthread_kill + 208
2 libsystem_c.dylib 0x1b7853e88 abort + 124
3 libc++abi.dylib 0x1f8a54dec abort_message + 128
4 libc++abi.dylib 0x1f8a45644 demangling_terminate_handler() + 276
5 libobjc.A.dylib 0x1a9d6707c _objc_terminate() + 140
6 libc++abi.dylib 0x1f8a54288 std::__terminate(void (
)()) + 16
7 libc++abi.dylib 0x1f8a54230 std::terminate() + 52
8 libdispatch.dylib 0x1b78147dc _dispatch_client_callout + 36
9 libdispatch.dylib 0x1b77b6934 _dispatch_continuation_pop$VARIANT$mp + 444
10 libdispatch.dylib 0x1b77c8988 _dispatch_source_invoke$VARIANT$mp + 1660
11 libdispatch.dylib 0x1b77ba374 _dispatch_lane_serial_drain$VARIANT$mp + 344
12 libdispatch.dylib 0x1b77baf4c _dispatch_lane_invoke$VARIANT$mp + 400
13 libdispatch.dylib 0x1b77c4fa0 _dispatch_workloop_worker_thread + 636
14 libsystem_pthread.dylib 0x1f8b10b50 _pthread_wqthread + 284
15 libsystem_pthread.dylib 0x1f8b1067c start_wqthread + 8

@mare95
Copy link

mare95 commented Oct 4, 2023

Yup, my app works in "dev" environment but as soon as i build it for test it crashes when i open the camera that has frameProcessor attached with this error:

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

Here is the screenshoot from firebase crashlytics as well:
Screenshot 2023-10-04 at 14 50 31

Any ideas why?

@rkmackinnon
Copy link
Author

For anyone seeing these crashes, can you reproduce it in the example app?

@vietdung97
Copy link

vietdung97 commented Oct 5, 2023

For anyone seeing these crashes, can you reproduce it in the example app?

example app run perfectly, but my app still get crash issue.
my package.json:
"react-native-vision-camera": "^3.2.2",
"react-native-worklets-core": "^0.2.1",
"vision-camera-code-scanner": "https://github.com/rkmackinnon/vision-camera-code-scanner.git#react-native-vision-camera-v3",

@xhoantran
Copy link

"react-native-vision-camera" now support code scanner
https://github.com/mrousavy/react-native-vision-camera/releases/tag/v3.3.0

@vietdung97
Copy link

"react-native-vision-camera" now support code scanner https://github.com/mrousavy/react-native-vision-camera/releases/tag/v3.3.0

Thank bro, you save my day

@rkmackinnon
Copy link
Author

"react-native-vision-camera" now support code scanner https://github.com/mrousavy/react-native-vision-camera/releases/tag/v3.3.0

Always great to have another option, especially one tied to a project with a better history of ongoing maintenance/support. I'll definitely be trying that out. At first glance, because it's not a frame processor, it looks like it'll support older devices on the Android side. One advantage of vision-camera-code-scanner is that we expose more of the structured output of MLKit. We also have the option to check inverted colors. It'll be interesting to see if there's enough interest to keep this project going after everyone has the time to make some comparisons and consider what they need.

@zzz08900
Copy link

On iOS side the built-in code scanner of vision camera v3 uses some iOS built-in function to read QR codes and by the result of initial testing I personally prefer the results from MLKit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.