-
Notifications
You must be signed in to change notification settings - Fork 2k
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
tfjs-react-native bundleResourceIo function Require Cycle yellowbox, -> TypeError: Network request failed. #2177
Comments
@gitathrun is it same with latest tfjs version as well ? |
@gitathrun I'll take a look, two questions, could you check that the values for Also just confirming that you modified your metro config to allow the resolver to resolve .bin files |
@rthadur I did not test with the latest tfjs version, because I try to keep the same dependencies version with the tfjs-react-native demo. |
@tafsiri I have update the code in App.js listed below, and the console result, All the key, value in modelJson can be fetched correctly, and the modelWeights is a Number with 1. App.js
The metro config is exactly the same as Step 3, here is mine:
|
@tafsiri Hello, any progress on this topic? |
@tafsiri Hello, I have tried with the same configuration but react-native version 0.60. |
Hi @gitathrun sorry for the delay in looking into this. I tried to reproduce this but was unable to do so exactly. In debug mode, I don't get the require cycle warning related to To help debug I created a branch https://github.com/tensorflow/tfjs/tree/2177-bundleResourceIO where the integration app has a new diagnostic test that loads a graphModel from the bundle. With a release build I do have an issue, but that may have more to do with the android build settings, i'm going to continue to look into this but I'm not sure if it's the same as your issue. To narrow this down:
|
Hi, @tafsiri , thanks for the reply. To your questions: Is it possible that you have another dependency loading a fetch library/polyfill? Could you post your package.json? My package.json
Might be the Are you running into this with a debug or release build? (given the messages above I assumed debug mode). Firstly, I do try to get it working in debug mode, not working, then I try to build a release apk, but with another problem, which is
This the error shows in rn 60 version, but this error also shows up in rn 59 version. Are you able to run the integration_rn59 from the branch linked above app locally, do you get a similar result? I've included a screenshot below of what I am getting when i click the 'show diagnostic screen' button. I will get the result back to you asap. |
hi, @tafsiri negative, I cant get the demo running, I got issues in bundle process: |
Thanks for the info, i've dug into this a bit more and was able to reproduce some of your errors.
If that does not work
This should get things running in debug mode. However through this I have discovered an issue when running this in release mode which will take a new release in order to fix. I'll post an update here when I work out a fix. If you still have have issues in debug mode, let me know. |
Hi, @tafsiri
3, It only works in debug mode as you indicates. I have successfully create the bundle for Release, signed, install it on devices, checked in Android Studio make sure all files (the model files as well) included, but the "Network fetch error" still ocurred. So the app could not load model from a relased apk. This applies to both rn 0.59 and 0.60. I am wandering is it the "paths" parameters in model.json is not compat with bundled model weight file, because the .bin file name is changed during the bundle process?
PS: is it possible to use tf.loadLayersModel() with an URL links to fetch the model from a cloud ? (Azure blob, for example) in tfjs-react-native? It seems from the mobilenet package code that the model from Google's open storage is fetched by using loadGraphModel() from tf.converter, not from tf. Many thanks. |
I have the same issue and keep track of discussion! |
|
That is great, mobilenet code, although it is loadGraphModel, but I think it can be changed to loadLayersModel. |
Updates how files are resolved by the bundle resource loader in prod builds. Addresses #2177 INTERNAL BUG
@gitathrun Just did a new release that should fix this issue. Try https://www.npmjs.com/package/@tensorflow/tfjs-react-native/v/0.1.0-alpha.3 and let me know if it solves the problem. |
This version does need the latest version (1.3.x) of tfjs. |
Hi, @tafsiri
I have a feeling that this is caused by the incompentency between react-native 0.60 and newly utilised react-native-fs, because when I am trying to configure the react-native-fs in rn 0.60 environment, it throws a lot of error such as fs error, and react-native-fs documentation is conflect about whether use auto or manul "react-native link" cmd if rn version is higher than 0.60. Use "react-native link react-native-fs" is obsolutely fine in rn 0.59, but it does not work in 0.60, for some of the configurations does not show in the build.gradle and MainApplication.java. Many thanks. |
@gitathrun from your error log it looks like the problem is with accessing a microphone (maybe a permissions error)? If you fix that do you get any other errors? It also sounds like you weren't able to get react-native-fs set up where you using RN 0.60 or a version |
@tafsiri Here is the weired part. I have never try to setup the microphone permission or usage in this simple demo, the code is identical with version 0.59. But the rn 60 asks for this permission? This is the part I am not certain about. The second odd thing is, according to react-native-fs doc,
But with this version 2.13.x, the android build failed as this indicates, update solved this problem in build, bundle process, but encountered the flash-crash problem. May be it has to be react-native 0.61, I am not sure, but my current project are based on 0.60. I will test this against 0.61, to see if it is the solution. |
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks! |
@tafsiri @gitathrun I have run into this same issue trying to use this library's custom |
@dkoo are you getting the same error (a microphone exception?) Feel free to make a new issue with your setup and I can take a look. The main issue is that I haven't been able to reproduce this. |
@tafsiri In my case it's not due to a microphone exception (I'm not even using the microphone, I'm just trying to capture a still photo from React Native Camera or select one from the photo library). It seems related to the use of
This works as expected on iOS, but the XHR request fails on Android. It also fails when trying to fetch a .jpg file from the device's disk, not just when fetching a base64 data URI. I thought it might have been related to this issue: facebook/react-native#23986 but that didn't seem to fix the problem. Debugging the custom
This seems to work on both iOS and Android. Still, it's more of a workaround than addressing the actual issue with the |
@dkoo thanks for the updated info. Could you also let me know what versions of tfjs and tfjs-react-native you are using? Also is this just in the simulator or also on device? |
@tafsiri Sorry for the delayed response. Versions I'm using:
And this was in the Android Emulator. |
Thanks, any chance you could try this on a physical device? |
Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks! |
@tafsiri This problem only exists on an Android Emulator for me. On a physical device (Android/IOS) it works. |
To get help from the community, we encourage using Stack Overflow and the
tensorflow.js
tag.TensorFlow.js version
Browser version
react-native app
Describe the problem or feature request
When I am trying to use the "bundleResourceio" function to load mdoel from local mobile device, Yellowbox occurs with following mention:

It is triggered by click on the buttom.
In the console, it shows:

From my understanding it is probably some require cycle between tfjs-react-native customised fetch and react-native fetch functions which causes the undefined fetch function?
But it is hard to debug and where to modified, I even tried use the demo ts file here, still got this error...
Any ideas?
Code to reproduce the bug / link to feature request
The react-native app consists:
If you would like to get help from the community, we encourage using Stack Overflow and the
tensorflow.js
tag.GitHub issues for this repository are tracked in the tfjs union repository.
Please file your issue there, following the guidance in that issue template.
The text was updated successfully, but these errors were encountered: