Repository navigation
chore(🐙): let a release build of the example run without Metro - #560
Open
YevheniiKotyrlo wants to merge 5 commits into
Open
YevheniiKotyrlo wants to merge 5 commits into
YevheniiKotyrlo wants to merge 5 commits into
Conversation
The Android release build packaged no JavaScript bundle, and the example fetched its images from URLs only Metro serves. `yarn bundle:android` bundles from a fresh transform cache, so that CI and E2E_PORT take the values it runs with, compiles the bundle to Hermes bytecode as React Native's release build does, and writes it where app.json now lists it. An image whose source names an Android resource is read through an android.resource:// URL.
Contributor
Author
|
With
|
…ing nothing useImageData awaited decodeImage in an effect with no rejection handler, so a load that failed left useAssets returning null for good: the app rendered nothing, and a release build logged nothing. The hook now keeps the load's state and throws a failed load while rendering, so it reaches the error screen in development and the crash log in a release build.
This was referenced Oct 16, 2026
YevheniiKotyrlo
marked this pull request as ready for review
October 17, 2026 05:44
This branch has not been deployed
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.
Fixes #196.
An Android release build of the example could not run: its APK carried no JavaScript bundle, and the example fetched its images from URLs only Metro serves.
Problem
react-native-test-app turns off React Native's bundling task and packages the bundles
app.jsonlists underresources, which name one for iOS, macOS and visionOS but none for Android, soassembleReleasepackaged no bundle. A bundle packaged that way also skips the Hermes bytecode compile React Native's release build runs after bundling. With one packaged,useAssetsfetchedImage.resolveAssetSource(mod).uri, which without Metro is the image's drawable resource name with no scheme (src_assets_di3d).fetch()cannot read that, anduseImageDatadropped the rejected load, soApprendered nothing and logged nothing: the screen stayed blank and an e2e run waited out its connection timeout.Solution
yarn bundle:android(fromapps/example/) bundles as React Native's release build does for Hermes (--dev false --minify false, thenhermesc -O), writes the bytecode todist/main.android.jsbundleand the assets intodist/res, andapp.jsonlists the bundle besidedist/res. It bundles with--reset-cache, as CI starts Metro, soCIandE2E_PORTare inlined with the values it runs with.scripts/compile-hermes-bytecode.mjsruns the compiler react-native compiles with: itshermes-compilerdependency, else thehermescin itssdks/hermesc. Another package here installs ahermes-compilerfor Hermes 1.0, and its bytecode makes the app abort withWrong bytecode version. Expected 96 but got 98.resolveImageUrlturns a resource name intoandroid.resource://<application id>/drawable/<name>, which React Native'sfetch()reads through the content resolver; Metro's URLs and iOS's file URLs pass through unchanged.fetchAsset,decodeImageand the Tests screen'sfTextureuse it. The application id isapp.json'sandroid.package, else react-native-test-app's default, as react-native-test-app derives it.useImageDatakeeps each load's state and throws a failed load while rendering, so it reaches the error screen in development and the crash log in a release build.CONTRIBUTING.mddescribes the release build and the e2e run on it. The ThreeJS scenes still load their models from Metro.Verification
yarn lint·yarn tsc·yarn turbo run build --filter='./packages/*'· the Expo template's web build ·yarn test:plugin·yarn check-dawn·yarn build:docs. CI's Android e2e step against a release build instead of Metro (CI=true yarn bundle:android, thenassembleRelease) on an Android 15 emulator (API 35): 42 of 44 suites and 219 of 221 tests passed, the same asmain's debug build with Metro on that emulator image. The two failures in both are YUV external-texture cases (ExternalTextureColorSpace,NativeBufferWrapper), which render on the host's GPU there. Withmain's asset loading, the same release build stays blank and the run ends withNo device connected to the test server. With every image URL broken on purpose, a release build withmain'suseImageDatastays blank with nothing in logcat, and with this change React reportsTypeError: Network request failedwith the component stack. The bytecode script gives byte-identical output on Windows, Linux and macOS, and pickshermes-compiler0.14.1 under react-native 0.83. On devices the whole suite passes, 221 of 221: on a Galaxy S23 (Android 14), and on an iPad Pro 12.9-inch (4th generation, iOS 27.0.1) built and run as CI's iOS job does on a simulator (Debug build, Metro withCI=true).mainpasses 221 of 221 on both.