Tensorflow AsyncstorageIO not working on Samsung Devices.
We have an application in which we are utilizing the model in offline mode. AsyncstorageIO working fine on all devices except Samsung devices.
Below are some necessary details like library version, code snippets.
- Mobile device in which error occurs: Samsung Device(Android).
- Tensorflow JS library Version: @tensorflow/tfjs-react-native: 0.8.0 and @tensorflow/tfjs: 3.15.0
- Library installed using Yarn package manager
Current Behaviour: AsyncstorageIO working fine and working in offline mode but when we use the same functionality on Samsung Devices it breaks.
Expected Behaviour: It should work on samsung devices as it is working on other devices like Redmi, Realme and so on.
Code snippet:-
tf.loadGraphModel(asyncStorageIO('modelName')).then((res)=>{ console.log("Model loaded successfully"); // Devices apart from Samsung loads the model successfully. }).catch(()=>{ console.log("Error while loading model"); // In Samsung device it breaks and throw error. })
Error Log:- {[Error: In local storage, the binary weight values of model 'modelName' are missing.] line: 844, column:3002, sourceURL: 'index.android.bundle'}
Could you please check related issue here https://github.com/tensorflow/tfjs/issues/3504 ?
@rthadur I have already tried the above approach but still not working on Samsung Devices. In our case, the model is saved successfully but it is not loaded in Samsung devices and we are unable to use it from async storage.
@ermanish7991 is it possible to share the model and Samsung device type ?
@rthadur Sorry I can't share the model file but yes I can mention the Samsung device types in which we are facing issues.
Below are the devices name:-
- Samsung S10+
- Samsung S20
- Samsung S21
- Samsung S22
Just to inform you again that the model is saving successfully only the issue is when we try to load the model from asyncStorageIO. it is not loading.
Hi @ermanish7991, i have dug around some source code meanwhile investigating how react native goes about storing data in "Local Storage" and have realized that android operating systems are handled a little differently.
I'm sure you have done your own research regarding this problem however it would be helpful to see the output in certain areas of your code. Primarily;
- The output of your AsyncStorage before you save the model.
- The output of your AsyncStorage after you save the model. (Because TF is throwing a weightData error, which happens when a key related to weightData is missing in the "Local Storage" REF: https://github.com/tensorflow/tfjs-core/blob/master/tfjs-react-native/src/async_storage_io.ts)
- The output of your AsyncStorage before you load a model.
Although i have no precise information on the topic, it is also a worthy thing to consider if there are any size limitations to the database your android devices use (Android devices usually use RocksDB or Sqlite).
I have made an alternative storage for tf.js on RN that can bypass issues with AsyncStorageIO: tfjs-react-native-mmkv-storage.
It is based on react-native-mmkv, which does not depend on SQLite on Android.
It also has no limitations on DB size, whereas AsyncStorageIO has a 6MB limit by default, which is hard to override with Expo managed workflow.
I have also opened a feature request issue on tfjs to merge this into the tfjs repo: #6813
Hi, @ermanish7991
Thank you for opening this issue. Since this issue has been open for a long time, the code/debug information for this issue may not be relevant with the current state of the code base.
The TFJs team is constantly improving the framework by fixing bugs and adding new features. We suggest you try the latest TFJs version with the latest compatible hardware configuration which could potentially resolve the issue. If you are still facing the issue, please create a new GitHub issue with your latest findings, with all the debugging information which could help us investigate.
Please follow the release notes to stay up to date with the latest developments which are happening in the Tensorflow.js space.
Thank you for your support and cooperation.
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.
This issue was closed due to lack of activity after being marked stale for past 7 days.