Skip to content

Return only view manager names from bridgeless UIManager.getConstants() - #59173

Open
brownrice777 wants to merge 1 commit into
react:mainfrom
brownrice777:lazy-bridgeless-uimanager-constants
Open

brownrice777 wants to merge 1 commit into
react:mainfrom
brownrice777:lazy-bridgeless-uimanager-constants

Conversation

@brownrice777

Copy link
Copy Markdown

Summary:

In bridgeless mode on Android, UIManager.getConstants() builds the constants of all eager view managers. This step uses reflection on the @ReactProp setters of each view manager. BridgelessUIManager calls getConstants() when the module loads. Thus, each cold start does this work on the JS thread, before the first screen.

Many apps cannot make their view managers lazy, because libraries register them. In the app that I measured, 130 view managers are eager: 98 from expo-modules-core, 19 from react-native-screens and 13 from other libraries. 47 view managers are lazy.

This change makes getConstants() return the same data as the old architecture with lazy view managers (UIManagerModuleConstantsHelper.createConstants(ViewManagerResolver)): the UIManager constants, the names of all view managers, and LazyViewManagersEnabled. When JS needs the constants of one view manager, it calls getConstantsForViewManager(). This function finds eager and lazy view managers.

The JS code does not change:

  • BridgelessUIManager makes a lazy getter for each name. Thus, UIManager.SomeViewManager continues to work (see Preserve lazy ViewManager initialization in UIManager #58097).
  • getViewManagerConfig() gets the constants of a view manager from getConstantsForViewManager() on first use.
  • getNativeComponentAttributes() uses the LazyViewManagersEnabled path, which calls getDefaultEventTypes().

One result is visible: UIManager.getConstants() does not contain the constants of eager view managers, genericBubblingEventTypes or genericDirectEventTypes. This is the same as the old architecture with lazy view managers.

Changelog:

[ANDROID] [CHANGED] - In bridgeless mode, UIManager.getConstants() returns only the view manager names. JS gets the constants of a view manager when it needs them.

Test Plan:

Device: Xiaomi Mi Note 2 (Snapdragon 821, Android 8.0). App: a production Expo app, release build, React Native 0.86, Hermes. Each build was installed new. I did each cold start with am force-stop, then am start -W. The measured point is the first frame with rows in the first list.

I did not build React Native from source. To measure the effect, I replaced the RN$LegacyInterop_UIManager_getConstants binding in JS with a function that returns the result of this change: the names of the 177 view managers of the app and the UIManager constants. I got these values from the real binding on the same device.

Build Cold starts Process start to first list frame (median) JS module load time getConstants() time
Before 6 2826 ms 1098 ms 503–520 ms
After (simulated binding) 9 2387 ms 680 ms names only

The ranges do not overlap: 2762–2879 ms before, 2365–2467 ms after.

I also did these checks on the device with the simulated binding:

  • The app opens a chat. The chat list, a thread, images, reactions, scrolling, settings and the profile screen show correctly.
  • Logcat shows no view config errors.
  • getConstants() occurs one time for each start, and it returns only names.

The Kotlin change uses UIManagerModuleConstantsHelper.createConstants(ViewManagerResolver), which UIManagerModule uses for the old architecture. BridgelessViewManagerResolver is a ViewManagerResolver. CI compiles the change.

In bridgeless mode, UIManager.getConstants() builds the constants of all
eager view managers. This step uses reflection on each view manager.
BridgelessUIManager calls getConstants() when it loads. Thus, each cold
start does this work before the first screen.

This change makes getConstants() return the same data as the old
architecture with lazy view managers: the UIManager constants and the
names of all view managers. When JS needs the constants of one view
manager, it calls getConstantsForViewManager(). This function finds
eager and lazy view managers.

The JS code does not change. BridgelessUIManager makes a lazy getter for
each name. getViewManagerConfig() uses getConstantsForViewManager().
getNativeComponentAttributes() uses getDefaultEventTypes().
@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Hi @brownrice777!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 18, 2026
@meta-cla

meta-cla Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant