Repository navigation
Conversation
…rom Application.onCreate
Visual regressionNo visual differences at ios: no capture |
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.
Summary:
On a cold start, the React instance (JS runtime, TurboModules, Fabric, bundle evaluation) is only created once the first Activity starts its surface, so all of it waits for
Activity.onCreate.ReactHost.start()already exists to create the instance earlier, but the generatedloadReactNative(this)entry point that apps call fromApplication.onCreatecannot use it.This adds a
loadReactNative(Context, boolean startReactHost)overload to the generatedReactNativeApplicationEntryPoint. Withtrueit callsReactHost.start()right after loading React Native, so instance creation and bundle evaluation overlap with the Activity being created.loadReactNative(Context)is unchanged. RNTester opts in.Benchmarks (RNTester release, real phones, dex state
verify, cold starts interleaved in blocks between the two builds, 18 launches per arm; TTFD =reportFullyDrawn()on RNTester's first React content, TTID =am start -W; medians, bootstrap 95% CI of the median difference):speed-profile)Warm starts (process alive) are unchanged: A16 −3 ms [−14, +6], moto g57 −4 [−24, +18], Pixel 9a 0 [−4, +6].
Trade-offs:
loadReactNative(this).ReactApplication.getReactHost()must return the host.Changelog:
[ANDROID] [ADDED] -
loadReactNative(context, startReactHost = true)starts the ReactHost fromApplication.onCreateso bridgeless startup overlaps with Activity creationTest Plan:
cd packages/gradle-plugin && ./gradlew :react-native-gradle-plugin:test --tests "*GenerateEntryPointTaskTest*"passes (template and expected output updated).assembleRelease, arm64) built with the generated entry point containing the overload; launched on the five phones above, Components list renders, back + relaunch (warm) works.adb install -r+cmd package compile -m verify -f, launched witham force-stop+am start -W, values read from logcatDisplayed/Fully drawn.🤖 Generated with Claude Code