tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

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

Open philippogol opened this issue 1 year ago • 2 comments

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.

philippogol avatar Jul 29 '24 18:07 philippogol

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.

gaikwadrahul8 avatar Aug 01 '24 11:08 gaikwadrahul8

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

philippogol avatar Aug 02 '24 22:08 philippogol

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!!!

shmishra99 avatar Aug 29 '24 03:08 shmishra99

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[bot] avatar Sep 06 '24 01:09 github-actions[bot]

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

github-actions[bot] avatar Sep 13 '24 01:09 github-actions[bot]

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

google-ml-butler[bot] avatar Sep 13 '24 01:09 google-ml-butler[bot]

@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

lucksp avatar Nov 01 '24 23:11 lucksp

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

haelsisy avatar Nov 12 '24 21:11 haelsisy

Hi, in latest versions of react native and expo 53, while using, const TensorCamera = cameraWithTensors(CameraView); facing the error for CameraView. Want a solution please

Image

khalid999devs avatar Jul 08 '25 12:07 khalid999devs