TechStark / opencv-js

OpenCV JavaScript version for node.js or browser
https://npmjs.com/@techstark/opencv-js
Apache License 2.0
410 stars 36 forks source link

unable to implement in react native 0.67 #18

Open gowthambalashanmugam opened 2 years ago

gowthambalashanmugam commented 2 years ago

Facing below error when i tried to implement it, Can anyone help us to sort it out?

error: RangeError: Maximum call stack size exceeded at RegExp.exec () at tokenize (/Users/comp/work/mobile-app/react-mob-app/node_modules/@babel/highlight/lib/index.js:67:38) at tokenize.next () at highlightTokens (/Users/comp/work/mobile-app/react-mob-app/node_modules/@babel/highlight/lib/index.js:84:3) at highlight (/Users/comp/work/mobile-app/react-mob-app/node_modules/@babel/highlight/lib/index.js:112:12) at codeFrameColumns (/Users/comp/work/mobile-app/react-mob-app/node_modules/@babel/code-frame/lib/index.js:103:65) at UnableToResolveError.buildCodeFrameMessage (/Users/comp/work/mobile-app/react-mob-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:264:12) at new UnableToResolveError (/Users/comp/work/mobile-app/react-mob-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:223:35) at ModuleResolver.resolveDependency (/Users/comp/work/mobile-app/react-mob-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:129:15) at DependencyGraph.resolveDependency (/Users/comp/work/mobile-app/react-mob-app/node_modules/@react-native-community/cli-plugin-metro/node_modules/metro/src/node-haste/DependencyGraph.js:288:43)

EddieCanales commented 2 years ago

I get the same error. I've attempted a few things: none of which have helped.

  1. switched from trying it in an Expo-based project to a normal ReactNative project.
  2. Tried only importing the methods I need (starting with import {imread} from '@techstark/opencv-js';) and even just including that single function causes the same problem.

For added context, this error occurs after (or perhaps right at the end) of bundling. react-native start react-native (or npm start) works without errors. Then run-android (or npm run android) seems to work fine up until 100% when it launches the app on your phone/emulator. Once that happens, you see the error above in the console and in the error dialog within the app.

gowthambalashanmugam commented 1 year ago

I couldn't resolve that, else we can integrate OpenCV 3.4.1 as a native plugin which causes more weightage of the app but no option.

pepperav commented 1 year ago

error: RangeError: Maximum call stack size exceeded

I get this error too on react-native 0.71.8 and expo ~48.0.15.

Any solutions?

thanhnv2303 commented 1 year ago

I have the same issue

gameveloster commented 2 months ago
RangeError: Maximum call stack size exceeded

Anyone solved after 2 years? Getting the same error using

el-fuego commented 2 months ago

If you will comment babel error code highlighting - you will see the original error about the missed fs module.

Currently searching for the workaround:

// package.json
  "browser": {
    "fs": false,
    "path": false,
    "crypto": false
  },

and

// babel.config.js
  plugins: [
    [
      'module-resolver',
      {
        alias: {
          fs: false,
          path: false,
          os: false,
        },
      },
    ],
  ],

do not work for me '((

Then tried:

// metro.config.js
const config = {
  resolver: {
    extraNodeModules: {
      fs: require.resolve('./empty-module'),
      path: require.resolve('./empty-module'),
      os: require.resolve('./empty-module'),
    },
  },
};

with

// empty-module.js
module.exports = {};

-- this solves the modules issue, but the library uses document.createElement("canvas"), document.getElementById(imageSource)}..., which is not present in RN.

It looks like the single solution is to use native modules https://brainhub.eu/library/opencv-react-native-image-processing