Remove unimodule.json so Expo autolinks onnxruntime-react-native#29005
Draft
danielweinmann wants to merge 1 commit into
Draft
Remove unimodule.json so Expo autolinks onnxruntime-react-native#29005danielweinmann wants to merge 1 commit into
danielweinmann wants to merge 1 commit into
Conversation
expo-modules-autolinking treats the presence of unimodule.json as a marker that the dependency is an Expo module and excludes it from React Native community autolinking, so OnnxruntimePackage never gets registered in PackageList and NativeModules.Onnxruntime is null at runtime. The package already ships a react-native.config.js that tells autolinking how to register it; removing the legacy marker lets that work.
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes
js/react_native/unimodule.jsonand its entry in the npmfileslist.Motivation and Context
Fixes #29004 — in Expo projects, importing
onnxruntime-react-nativecrashes the app at startup with[runtime not ready]: TypeError: Cannot read property 'install' of null.expo-modules-autolinkingtreats the presence ofunimodule.jsonas a marker that the dependency is an Expo module and therefore excludes it from React Native community autolinking (expo-modules-autolinking react-native-config). Since the package isn't actually an Expo module, nothing registers it on the Expo side either:OnnxruntimePackagenever appears in the generatedPackageList.java,NativeModules.Onnxruntimeisnull, and the import-timeModule.install()call inbinding.jsthrows before the app can mount.The package already ships a
react-native.config.jswith the correctpackageImportPath/packageInstance, so React Native autolinking knows exactly how to register it — the legacy marker file is the only thing preventing that in Expo apps. The file was added in #11556 (May 2022) to help Expo's then-current tooling discover the package; today's tooling interprets it in the opposite way. Bare React Native apps ignore the file entirely, so this change is a no-op for them.Verified on Expo SDK 56 / React Native 0.85 / onnxruntime-react-native 1.24.3 (Android), by deleting the file from
node_modulesvia a pnpm patch:npx expo-modules-autolinking react-native-config --jsonomits the package; the generatedPackageList.javahas noOnnxruntimePackage; the app crashes at startuppackageInstance: new OnnxruntimePackage();PackageList.javaregistersai.onnxruntime.reactnative.OnnxruntimePackage; the app boots and on-device inference of a 66M-parameter model runs through the JSI binding — without using theapp.plugin.jsconfig pluginThis is the root cause behind #19510, #26925, and #26796, and it is why the Expo config plugin currently has to inject
OnnxruntimePackageintoMainApplicationby string manipulation — the part of the plugin that keeps breaking with new Expo SDKs (#28657, #28672). With the marker removed, thatMainApplicationpatching becomes unnecessary on Android.Note for maintainers: apps that currently work around the bug via
app.plugin.jsor a manualreact-native.config.jsentry would register the package twice once autolinking starts working. The config plugin should probably drop itsMainApplicationmodification in the same release — happy to extend this PR to do that if you'd like, or keep it minimal as-is.