Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fresh react native install (18.2.0 / 0.74.3) and tfjs 4.20 issue #8344

Closed
philippogol opened this issue Jul 29, 2024 · 8 comments
Closed

fresh react native install (18.2.0 / 0.74.3) and tfjs 4.20 issue #8344

philippogol opened this issue Jul 29, 2024 · 8 comments

Comments

@philippogol
Copy link

I'm encountering a constant error while fresh starting a new project. These are the dependencies:

"dependencies": {
"@react-native-async-storage/async-storage": "^1.24.0",
"@tensorflow/tfjs": "^4.20.0",
"@tensorflow/tfjs-react-native": "^1.0.0",
"react": "18.2.0",
"react-native": "0.74.3"
}

Making a simple addition using or just loading the package library throws the error "Cannot read property 'isTypedArray' of undefined. I tried different things and is not working, has someone experienced something like this or has a solution? Thanks.

@gaikwadrahul8
Copy link
Contributor

Hi, @philippogol

I apologize for the delay in my response and if possible could you please give it try with mentioned package dependancies here and see is it resolving your issue or not ?

If issue still persists please help us with complete error log and steps with your Github repo to replicate the same behavior from our end to investigate this issue further.

Thank you for your cooperation and patience.

@philippogol
Copy link
Author

hey @gaikwadrahul8 thanks for the coming back, its actually pretty forward and i think it should an easy fix. here are the steps and code im using for a simple tensorflow loading model (im avoiding expo since it should be possible to use tensorflow without any expo package)

  1. npx react-native init tensorflowApp
  2. npm install @react-native-async-storage/async-storage @tensorflow/tfjs @tensorflow/tfjs-react-native
  3. cd ios/ & pod install
  4. all code in App.tsx (starting tensorflow and loading model, see in repo)

In get the error: "Console Warning Possible unhandled promise rejection (id: 0): TypeError: Cannot read property 'fetch' of undefined" (see attachment).
IMG_3944

repo: https://github.com/philippogol/reactnative-tensorflow

@shmishra99
Copy link
Contributor

hey @gaikwadrahul8 thanks for the coming back, its actually pretty forward and i think it should an easy fix. here are the steps and code im using for a simple tensorflow loading model (im avoiding expo since it should be possible to use tensorflow without any expo package)

  1. npx react-native init tensorflowApp
  2. npm install @react-native-async-storage/async-storage @tensorflow/tfjs @tensorflow/tfjs-react-native
  3. cd ios/ & pod install
  4. all code in App.tsx (starting tensorflow and loading model, see in repo)

In get the error: "Console Warning Possible unhandled promise rejection (id: 0): TypeError: Cannot read property 'fetch' of undefined" (see attachment). IMG_3944

repo: https://github.com/philippogol/reactnative-tensorflow

Hi @philippogol ,

Apologies for the delayed response. I am unable to replicate the issue on my system, i'm encountering a different error.

The warning message Console Warning Possible unhandled promise rejection (id: 0): suggests that the promise from await tf.ready() might be rejected, which indicates that TensorFlow.js was not successfully initialized. This failure could be causing the error TypeError: Cannot read property 'fetch' of undefined.

You could use following set of code to check what exactly casuing the error.

  tf.ready().then(async  ()=>{
    setIsTfReady(true);
    // Load the MobileNet model
    const model = await tf.loadLayersModel('https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json');
    setModel(model);
  }).catch(e=> console.log('Error while loading the tf dependencies.',e));

Let me know if it helps. Thank You!!!

Copy link

github-actions bot commented Sep 6, 2024

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Sep 6, 2024
Copy link

This issue was closed due to lack of activity after being marked stale for past 7 days.

Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@lucksp
Copy link

lucksp commented Nov 1, 2024

@philippogol @gaikwadrahul8 I am having similar issues, as logged in #8429

Could you please give it try with mentioned package dependancies here and see is it resolving your issue or not ?

I cannot downgrade my current environment, so it leads me to believe that there is some incompatibility with new versions of React Native

@haelsisy
Copy link

I have the same issue with "react-native": "0.76.1" "Cannot read property 'isTypedArray' of undefined

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

No branches or pull requests

5 participants