Cache UIManager constants in bridgeless new architecture on Android (Improve app start on low end/mid android by 150-300ms#56078
Open
Szymon20000 wants to merge 1 commit intofacebook:mainfrom
Conversation
Member
|
Would it make sense to cache this in JS instead? We’d also want to have a feature flag for this. |
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:
Motivation: startup in bridgeless + new architecture was spending significant time in UIManager host functions (
getConstants/getConstantsForViewManager) even on repeated launches.This PR adds Android-side caching for UIManager constants and lazy view manager constants, preloads them early on app startup, and reuses them from
UIConstantsProviderBindingto avoid recomputing on subsequent runs.It also adds cache identity validation so stale cache is not reused after app/bundle changes (including OTA/file-bundle changes). Cache is only used when identity matches; otherwise it safely falls back to normal computation and refreshes cache.
Changelog:
[ANDROID] [CHANGED] - Cache and preload UIManager constants in bridgeless new architecture and invalidate cache when app/bundle identity changes.
Test Plan:
Build/install RNTester release on device:
./gradlew :packages:rn-tester:android:app:installReleaseBUILD SUCCESSFULandInstalled on 1 device.Capture Hermes sampling profiles on release (two sequential launches, 10s window via
react-native-release-profiler):yarn workspace @react-native/tester react-native-release-profiler --fromDownload --raw --appId com.facebook.react.uiapp/Users/szymonkapala/work/react-native/.tmp/rntester-profiler-verify-20260312-214548/run1.cpuprofile.txt/Users/szymonkapala/work/react-native/.tmp/rntester-profiler-verify-20260312-214548/run2.cpuprofile.txtProfile comparison (sample-based):
getConstantsForViewManagerpresent (41samples),getConstantspresent (1sample).getConstantsForViewManager0samples,getConstants0samples.This verifies first-run population + second-run reuse behavior with the new cache identity checks.