microsoft / microsoft/onnxruntime
[Mobile] onnxruntime-react-native fails to load bundled ONNX assets in Expo standalone iOS
Open
Nobody has claimed this yet.
platform:mobile
platform:web
- Dominant language
- C++
- Stars
- 21.9k
- Forks
- 4.2k
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 184
Description
Describe the issue
Environment
- React Native / Expo (standalone iOS build)
onnxruntime-react-native(version: 1.23.2)- Hermes
- Models bundled via Metro using
expo-asset
Problem
In the Expo dev client, loading a bundled model via
Asset.fromModule(...).localUri works.
In the standalone iOS build,
InferenceSession.create(localUri) fails when the model stays in the app bundle.
- The
localUriis afile://path inside the app bundle. - The session init fails with a generic “failed to load model” error.
- No model bytes are read unless we first copy the file out of the bundle.
Observed Behavior
InferenceSession.createrejects whenuripoints to the bundled file
(file://...in the app sandbox).- No clear error about:
- Path scheme
- Bundle accessibility
Workaround Applied
Copy the bundled model to a writable path before loading:
const dest =
FileSystem.documentDirectory + basename(asset.localUri);
await FileSystem.copyAsync({
from: asset.localUri,
to: dest,
});
To reproduce
In an expo project with onnxruntime-react-native installed:
- Bundle a model (e.g.,
silero_vad_v5.onnx) viarequire(...). - Resolve with:
const asset = Asset.fromModule(mod);await asset.downloadAsync();const uri = asset.localUri;
- Call
InferenceSession.create(uri)(or the equivalent load API). - Observe failure in a standalone iOS build; the same code works in the Expo dev client.
Urgency
Not urgent, since workaround found.
Platform
iOS
OS Version
26
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.23.2
ONNX Runtime API
Other / Unknown
Architecture
Other / Unknown
Execution Provider
Other / Unknown
Execution Provider Library Version
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.