mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.65k stars 1.11k forks source link

ERROR ReferenceError: Property '_setGlobalConsole' doesn't exist #1514

Closed xts-bit closed 1 year ago

xts-bit commented 1 year ago

Question

I am facing a error that error says ERROR ReferenceError: Property '_setGlobalConsole' doesn't exist any idea how can i fix this issue with react-native-vision-camera?

What I tried

 "dependencies": {
    "@react-native-async-storage/async-storage": "^1.17.11",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "firebase": "^9.17.2",
    "react": "18.2.0",
    "react-native": "0.71.3",
    "react-native-gesture-handler": "^2.9.0",
    "react-native-image-crop-picker": "^0.39.0",
    "react-native-onboarding-swiper": "^1.2.0",
    "react-native-reanimated": "^3.0.1",
    "react-native-safe-area-context": "^4.5.0",
    "react-native-screens": "^3.20.0",
    "react-native-vector-icons": "^9.2.0",
    "react-native-vision-camera": "^2.15.4",
    "vision-camera-face-detector": "^0.1.8"
  },

VisionCamera Version

2.15.4

Additional information

linhvovan29546 commented 1 year ago

same issue

GaylordP commented 1 year ago

Same problem for a week :( Did you manage to solve the problem @syblus446 ?

xts-bit commented 1 year ago

@GaylordP import 'react-native-reanimated' to the top of the file when using useFrameProcessor. Fixed my issue

GaylordP commented 1 year ago

Thank you for your answer, the error is still there for me after this addition :/

juliusz-hbhit-dev commented 1 year ago

For me this also does not fix the error.

Related issue in react-native-reanimated: https://github.com/software-mansion/react-native-reanimated/pull/3853

socrates93 commented 1 year ago

I have the same situation. Is there another version which does not have this bug? I've tested this library 2 weeks ago but didn't have this issue. My mistake removing that test project :(

I mean, maybe is something with react-native-reanimated latest version (3.0.2) released 3 days ago...

Taraslysak commented 1 year ago

From our investigation, useFrameProcessor hook uses _setGlobalConsole global method from react-native-reanimated library, but it was removed in the latest version (3.0.2) of react-native-reanimated.

xts-bit commented 1 year ago

using react-native-reanimated version 2.14.4 fixed my issue

niubiletei commented 1 year ago

@mrousavy I have the same situation,and I got a location on the relevant file:node_modules\react-native-vision-camera\src\hooks\useFrameProcessor.ts
image but when I comment out this line of code,the program will throw an error and crashes
image I don't know how to solve it

socrates93 commented 1 year ago

using react-native-reanimated version 2.14.4 fixed my issue

Thanks, @syblus446 - I can confirm that it is working with react-native-reanimated@2.14.4.

rizkhal commented 1 year ago

I'm trying to downgrade using react-native-reanimated@2.14.4 but my app crashes

Btw i use:

"react-native": "0.71.4",
"react": "18.2.0",
socrates93 commented 1 year ago

I'm trying to downgrade using react-native-reanimated@2.14.4 but my app crashes

Btw i use:

"react-native": "0.71.4",
"react": "18.2.0",

Try running react-native start --reset-cache and clean other cache on android/ios folders. I use the following settings, consider a downgrade to this:

    "react": "18.1.0",
    "react-native": "0.70.6",
rizkhal commented 1 year ago

I'm trying to downgrade using react-native-reanimated@2.14.4 but my app crashes Btw i use:

"react-native": "0.71.4",
"react": "18.2.0",

Try running react-native start --reset-cache and clean other cache on android/ios folders. I use the following settings, consider a downgrade to this:

    "react": "18.1.0",
    "react-native": "0.70.6",

I have a lot of error after trying to downgrade react & react native like your suggestion

socrates93 commented 1 year ago

I'm trying to downgrade using react-native-reanimated@2.14.4 but my app crashes Btw i use:

"react-native": "0.71.4",
"react": "18.2.0",

Try running react-native start --reset-cache and clean other cache on android/ios folders. I use the following settings, consider a downgrade to this:

    "react": "18.1.0",
    "react-native": "0.70.6",

I have a lot of error after trying to downgrade react & react native like your suggestion

Ugh. Sorry. Did you clean your cache? Try this:

 watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* &&
 rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean --force &&
 npm install && npm start -- --reset-cache
R4tch3t commented 1 year ago

https://github.com/mrousavy/react-native-vision-camera/pull/1466

ivaldo commented 1 year ago

using react-native-reanimated version 2.14.4 fixed my issue

Thanks, @syblus446 - I can confirm that it is working with react-native-reanimated@2.14.4.

It's work for me after 'npx react-native start --reset-cache'

    "react": "17.0.2",
    "react-native": "0.68.2",
    "react-native-reanimated": "2.14.4",
    "react-native-vision-camera": "2.15.4",
    "vision-camera-code-scanner": "0.2.0"
Guilherme03 commented 1 year ago

Thanks a lot. Everything ok.

ustuncem commented 1 year ago

This issue still persists. I am using reanimated v3.0.2 . It appears that reanimated team has removed _setGlobalConsole. https://github.com/software-mansion/react-native-reanimated/pull/3853/files

GSFZamai commented 1 year ago

@mrousavy I have the same situation,and I got a location on the relevant file:node_modules\react-native-vision-camera\src\hooks\useFrameProcessor.ts image but when I comment out this line of code,the program will throw an error and crashes image I don't know how to solve it

Apparently they (reanimated) changed _setGlobalConsole to global.console. I've assigned console reference to global.console: image And get the same error as you.

GSFZamai commented 1 year ago

https://github.com/mrousavy/react-native-vision-camera/issues/1210#issuecomment-1457776475

vision-camera V2 only works with reanimated v2. On vision-camera v3 it will not use reanimated anymore and the incompatibility will be resolved. So until the release we should use reanimated v2

Tarkeshwar108 commented 1 year ago

I was also facing this issue but it resolved with below step: step1: I downgraded "react-native-reanimated": "^3.1.0" to "react-native-reanimated": "2.14.4". step2: Added import 'react-native-reanimated' in index.js which is our entry file. step3: yarn start --reset-cache After above step run your project. It should run without any issue. My packages details: "react": "18.2.0", "react-native": "0.71.3", "react-native-reanimated": "2.14.4", "react-native-vision-camera": "2.15.4", "vision-camera-code-scanner": "0.2.0"

maksym-bezditko commented 1 year ago

Tarkeshwar108

Thanks, that worked for me with "react": "17.0.2", "react-native": "0.68.0", but I noticed a significant bug in react-native-vision-camera of > 2.13.0 version. If I go to the next screen which uses Camera component from react-native-vision-camera, the component displays a part of previous screen for a second (when it is mounting as far as I understand). Same when that next screen goes out of focus. With react-native-vision-camera 2.13.0 nothing of that kind was observed. Any ideas how to workaround it?

maksym-bezditko commented 1 year ago

And can't build with react-native-animated version you mentioned and react-native-vision-camera >= 2.15.0. Maybe you know react-native-reanimated version that is compatible with react-native-vision-camera 2.13.0. Thank you in advance!

myselfuser1 commented 1 year ago

Try this https://www.youtube.com/playlist?list=PLQhQEGkwKZUrempLnmxjt7ZCZJu1W3p2i

hernanif1 commented 1 year ago

trying to downgrade reanimated gives me this error: Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

elibroftw commented 1 year ago

When I set the version of reanimated to 2.14.4, I get the issue

eerror Failed to install the app. Command failed with exit code 1: gradlew.bat tasks FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\maste\Documents\GitHub\SplitTheTank\node_modules\react-native-reanimated\android\build.gradle' line: 292 * What went wrong: A problem occurred evaluating project ':react-native-reanimated'. > Could not get unknown property 'minor' for project ':react-native-reanimated' of type org.gradle.api.Project

2.17.0 seems to build further:

Execution failed for task ':react-native-vision-camera:extractJNIFiles'. > Cannot expand ZIP 'C:\Users\maste\Documents\GitHub\SplitTheTank\node_modules\react-native-reanimated\android\react-native-reanimated-72-hermes.aar

To fix this, I removed node_modules/react-native-reanimated and ran yarn again to reinstall the package.

Now I get error: index.js: Cannot find module 'react-native-reanimated/plugin'

Then I did yarn add react-native-reanimated@2.17.0

THen I got the same build errors.

Execution failed for task ':react-native-vision-camera:extractJNIFiles'.

Cannot expand ZIP 'C:\Users\maste\Documents\GitHub\SplitTheTank\node_modules\react-native-reanimated\android\react-native-reanimated-72-hermes.aar' as it does not exist.

Mynameisjohndev commented 1 year ago

I have the same situation in my application

lib versions

    "expo": "~49.0.5",
    "react": "18.2.0",
    "react-native": "0.72.3",
    "vision-camera-code-scanner": "^0.2.0",
    "react-native-vision-camera": "^2.15.4",
    "react-native-reanimated": "^2.17.0"

i remove this part image

add this image

upgrade gradle.properties to image

these were the things i did and i got the same error, in case anyone knows how to fix

umusicanumothu commented 1 year ago

On react native v0.72, the downgrade to 2.14.4, is not working. :( For a quick fix, I have made a change in node_module react -native-vision-camera the below changes.

  1. go to node_modules->react-native-vision-camera->src->hooks->useFrameProcessor.ts
  2. comment the code _setGlobalConsole(console);
  3. restart the metro with reset cache. react-native start --reset-cache

Its just a quick fix. Everytime run yarn command, it will be replaced. For persistant change, please apply patch-package https://www.npmjs.com/package/patch-package

Mynameisjohndev commented 1 year ago

If I install the patch-package, I make the change inside the library installed in my application, I run the command npx patch-package react-native-vision-camera? @umusicanumothu

truongto commented 1 year ago

On react native v0.72, the downgrade to 2.14.4, is not working. :( For a quick fix, I have made a change in node_module react -native-vision-camera the below changes.

  1. go to node_modules->react-native-vision-camera->src->hooks->useFrameProcessor.ts
  2. comment the code _setGlobalConsole(console);
  3. restart the metro with reset cache. react-native start --reset-cache

Its just a quick fix. Everytime run yarn command, it will be replaced. For persistant change, please apply patch-package https://www.npmjs.com/package/patch-package

I got an error : ERROR frame-processor/unavailable: Frame Processors are not enabled. See https://react-native-vision-camera.com/docs/guides/troubleshooting, js engine: hermes

Mynameisjohndev commented 1 year ago

I still haven't tested this way as he said, I used expo's own library to expo-barcode-scanner to solve the temporary problem, probably in the future in version 3 of this library that will no longer use react-native-reanimated I'll come back to use her @truongto

VivekCEpic commented 1 year ago

@mrousavy I have the same issue with my project.

Please anyone help with this? Thank you in advance.

"react": "18.2.0", "react-native": "0.72.3", "react-native-reanimated": "3.0.2" "react-native-vision-camera": "^2.15.4",

Dhiraj-j commented 1 year ago

Anyone able to solve the issues

"react": "18.2.0", "react-native": "0.72.3", "react-native-vision-camera": "^2.15.4", "react-native-reanimated": "3.3.0", "vision-camera-code-scanner": "^0.2.0"

GaylordP commented 1 year ago

A PR is underway on this subject :

https://github.com/mrousavy/react-native-vision-camera/pull/1623

(But no release date :/ )

Antsthebul commented 1 year ago

FWIW, downgrading worked for me. I was using react-native 72 but it wasnt working. Aside from the warnings I get, it seems to work. I had to install the package that Creating a new application says to remove...

react 18.2 react-native 71.3 react native renimated 2.14.4 react-native-community/cli-platform-ios 11.3.7 react-native-vision-camera 2.15.4

Also, if your downgrading react-native version like me the Podfile needs require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' at the top.

itzFaiz commented 1 year ago

Did anyone figure out how to solve the issue. I tried downgrading as per above suggestions but getting too many errors. please help i have been stuck on it from 2 weeks. i am working on android project.

pavalappdev commented 1 year ago

// _setGlobalConsole(console); //comment global.didSetConsole = false; //make false

abdymm commented 1 year ago

still having this issue, are you guys able to resolve this?

mrousavy commented 1 year ago

Closing as this is a stale issue - this might have been fixed with the full rewrite in VisionCamera V3 (🥳) - if not, please create a new issue.

If your issue has been fixed, consider sponsoring me on GitHub to say thanks 💖