tony-xlh / vision-camera-dynamsoft-barcode-reader

React Native Vision Camera Frame Processor Plugin of Dynamsoft Barcode Reader
MIT License
73 stars 15 forks source link

Can't find variable __decode #11

Closed Peege151 closed 1 year ago

Peege151 commented 1 year ago

Hello -- thank you for building this.

The project successfully built, but I get an error every frame of the frame processor. can't find variable __decode

This is the stack as follows:

 ERROR  Frame Processor threw an error: Can't find variable: __decode
In: decode@/Users/patrick/Development/vision-camera-dynamsoft-barcode-reader/src/index.tsx (25:9):1:47
    @[native code]
    _f@/Users/patrick/Development/vision-camera-dynamsoft-barcode-reader/example/src/App.tsx (16:43):1:163
    @[native code]
    _f@/Users/patrick/Development/vision-camera-dynamsoft-barcode-reader/example/node_modules/react-native-vision-camera/src/hooks/useFrameProcessor.ts (28:21):1:425
    @[native code]

I wonder if it something to do with the babel.config?

I did not change the babel from install, it looks like this:

const path = require('path');
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-reanimated/plugin',
      {
        globals: ['__decode'],
      },
    ],
  ],
};
xulihang commented 1 year ago

Try to run the following as discussed in this issue: https://github.com/mrousavy/react-native-vision-camera/issues/970

yarn start --reset-cache
Peege151 commented 1 year ago

Hi, I ran that command, but I am building from XCode 14.1 onto my device, and that did not work.

TBH I'm not too familiar with how globals work in babel, or why this file needs to be listed in global.... can we just require/import it and use it that way or is that not an option? I couldn't even find the __decode function anywhere in the project.

xulihang commented 1 year ago

React Native Vision Camera uses React Native Reanimated's plugin to expose the frame processor in a worklet. This is how it is designed currently. If you have questions, please post them in the Vision Camera's repo as I am not familiar with the ins and outs of Vision Camera.

vision-llz commented 1 year ago

@xulihang react-native-reanimated not __decode

Fabianurrutia commented 1 year ago

i tried a lot of configurations, and the only one that work for me was this:

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      // <-- this
      'react-native-reanimated/plugin',
      {
        globals: ['__decode'],
      },
    ],
  ],
};
tony-xlh commented 1 year ago

It might also be related to this issue using an old version of Vision Camera and Xcode 14: https://github.com/mrousavy/react-native-vision-camera/issues/1244

diegopeixoto commented 11 months ago

Still same error.

RN 0.70 Reanimeted 3.5.4. RN Vision 2.16.2 Dynam 0.6.3