-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Mobile] Creating InferenceSession from Uint8Array gives an assertion error on the native side #17732
Comments
thanks for the information and report. Since this works with onnxruntime-react-native 1.15.0 and also infer from your error log, it might be related to the new JSI blob support we introduced (to replace the slow base64 encode/decode part) (#16094) @jhen0409 with the new blob support, do you know at the user level, do they now need to provide a blob type instead of a base64 encoded Uint8array for the input of loading inference session? I thought the changes are internal to react native backend though. |
It may be broken. I think using
|
thanks for the suggestion. Tested locally in my expo react native project. It works at loading model now. We will add e2e test to cover this to avoid future breakage. @l3utterfly see if this fixes your crash. And FYI, we have a patch release 1.16.1 coming. Hopefully this will be included in the patch release version. |
Slightly confused as to how this wasn't uncovered from current unit tests or the perf testing associated with the original PR given it looks like it should always fail. What is different about the broken usage vs. how that testing was done? |
It looks like the current E2E tests should only use file path instead of use an array, my personal use case too. |
@jhen0409 is a potential workaround here to simply pass in a path instead of the user code doing a readFileAssets/readFile + base64.toByteArray or would that approach not handle platform specific differences? |
On android if you want to read a model bundled as part of the app assets (not downloaded separately or copied into your tmp folder before reading), you can't get a valid path into the asset bundle. So the only work around is to read the file contents and initialise an InferenceSession using the model contents. |
### Description <!-- Describe your changes. --> Use `.buffer` of Uint8Array to get ArrayBuffer. TODO: Add E2E React Native test case to cover JS level testing to avoid future breakage. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> #17732 Co-authored-by: rachguo <[email protected]>
### Description <!-- Describe your changes. --> Use `.buffer` of Uint8Array to get ArrayBuffer. TODO: Add E2E React Native test case to cover JS level testing to avoid future breakage. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> #17732 Co-authored-by: rachguo <[email protected]>
Hi @YUNQIUGUO, could you please add e2e code for React Native CLI project, for users not use Expo |
Yes, this fixes my issue. However, note that I had to go into the source code of onnxruntime to add the Simply adding |
yes. Once the onnxruntime-react-native 1.16.1 patch release package is out, you should be able to run your code as it is without any changes in source code. We've added the |
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details. |
### Description <!-- Describe your changes. --> Use `.buffer` of Uint8Array to get ArrayBuffer. TODO: Add E2E React Native test case to cover JS level testing to avoid future breakage. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> microsoft#17732 Co-authored-by: rachguo <[email protected]>
### Description <!-- Describe your changes. --> Use `.buffer` of Uint8Array to get ArrayBuffer. TODO: Add E2E React Native test case to cover JS level testing to avoid future breakage. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> microsoft#17732 Co-authored-by: rachguo <[email protected]>
Describe the issue
I have my model included as an asset in my React Native project. I am loading it into a base64 string, then encoding it as a byte array like so:
The error on the native side is:
Error: node_modules/react-native/ReactCommon/jsi\jsi/jsi-inl.h:154: facebook::jsi::ArrayBuffer facebook::jsi::Object::getArrayBuffer(facebook::jsi::Runtime &) &&: assertion "runtime.isArrayBuffer(*this)" failed
Note: this code was working with onnxruntime react native 1.15
To reproduce
InferenceSession.create
Urgency
Show stopping issue as it stops ONNX being used at all in our project
Platform
React Native
OS Version
0.72.4
ONNX Runtime Installation
Released Package
Compiler Version (if 'Built from Source')
No response
Package Name (if 'Released Package')
onnxruntime-react-native
ONNX Runtime Version or Commit ID
1.16.0
ONNX Runtime API
JavaScript
Architecture
ARM64
Execution Provider
Default CPU
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: