Description
Describe the issue
This is an issue that occurs when using the debugger during React Native development.
When in debug mode, there is code inserted at the following link indicating that synchronous methods are not supported: (https://github.com/facebook/react-native/blob/817fedb0e7a5276d86431c65cc886062ed8fe220/packages/react-native/Libraries/BatchedBridge/MessageQueue.js#L175)
Upon my investigation, I have confirmed that the issue arises from the following code:
OnnxruntimeJSIHelper.install();
When this code is used, an error occurs, stating calling synchronous methods on native modules is not supported in chrome.
I have also observed that the install
method is implemented as follows:
It seems that it should be implemented as an asynchronous method to be compatible with the React Native debugger.
To reproduce
The code I used for reproduce is as follows:
import * as ort from 'onnxruntime-react-native';
...
static async init(onnx) {
try {
const asset = ReactNativeBlobUtil.fs.asset(path.resolve('custom', onnx));
const cache = path.resolve(ReactNativeBlobUtil.fs.dirs.CacheDir, onnx);
await ReactNativeBlobUtil.fs.cp(asset, cache);
const session = await ort.InferenceSession.create('file://' + cache);
return new this(session);
} catch (error) {
console.error(error);
throw error;
}
}
When executing the line const session = await ort.InferenceSession.create('file://' + cache);
in the code, the error message mentioned earlier, calling synchronous methods on native modules is not supported in chrome
is displayed.
This error appears to occur in accordance with the description provided above.
It is essential to be using the Remote debugger for reproducing the issue. The problem does not manifest when the Remote debugger is not in use.
Urgency
No response
Platform
React Native
OS Version
android version 13
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.1
ONNX Runtime API
JavaScript
Architecture
X64
Execution Provider
Other / Unknown
Execution Provider Library Version
No response