Skip to content

[0.87] Preserve lazy ViewManager initialization in UIManager - #59812

Open
brunohmagro wants to merge 1 commit into
react:0.87-stablefrom
brunohmagro:codex/backport-uimanager-lazy-0.87
Open

brunohmagro wants to merge 1 commit into
react:0.87-stablefrom
brunohmagro:codex/backport-uimanager-lazy-0.87

Conversation

@brunohmagro

@brunohmagro brunohmagro commented Nov 5, 2026 •

Copy link
Copy Markdown

Summary:

Backport the lazy ViewManager initialization fix from #58097 (commit da7c29f) to 0.87-stable. The original fix by @fairysword has already landed on main; this PR only adapts it to the supported release branch.

UIManager.js spreads UIManagerImpl, which eagerly evaluates its enumerable lazy ViewManager getters. On Android in Bridgeless mode, importing the module can therefore synchronously call getConstantsForViewManager for registered lazy ViewManagers before their configurations are needed. Copying property descriptors preserves lazy initialization and the existing measurement/command overrides.

The upstream commit does not apply cleanly to 0.87-stable: its callback-typing hunks expect untyped errorCallback parameters, whereas 0.87 already annotates them with (error: Object) => void. This backport retains those existing annotations and omits the now-unnecessary UnsafeObject import. The descriptor-composition fix and regression test are copied from upstream, without additional behavior changes.

This is submitted against the stable branch because of that cherry-pick conflict, as permitted by the release pick process. The fix is absent from 0.87-stable at 2a41d8c. No dependency changes or public API changes are included.

Release pick request: reactwg/react-native-releases#1503

Changelog:

[ANDROID] [FIXED] - Avoid unnecessary getConstantsForViewManager calls during UIManager initialization.

Test Plan:

Executed locally on the 0.87 stable checkout using Node 22.14.0 and Yarn 1.22.22:

  • yarn install --frozen-lockfile --non-interactive
  • Before the fix: adding the original upstream regression test and running yarn test packages/react-native/Libraries/ReactNative/__tests__/UIManager-test.js --runInBand fails as expected: getConstantsForViewManager is called once during import, where zero calls are expected.
  • After the fix: yarn test packages/react-native/Libraries/ReactNative --runInBand passes (2 suites, 4 tests). The test verifies no eager call, an own/enumerable property, and one configuration call across repeated accesses.
  • yarn test --maxWorkers=4 passes: 219 suites, 5,662 tests, 1,658 snapshots; 1 test skipped. Jest also reports a worker teardown warning after the passing suites and exits with code 0.
  • yarn flow-check --max-workers 4 passes with 0 errors.
  • yarn lint --quiet passes.
  • yarn format-check passes.
  • yarn build-types --validate passes; the public API snapshot is unchanged.
  • git diff --check passes.

No fresh Android/iOS native build or device performance benchmark was run for this backport. This PR makes no quantified startup-time claim; native/device validation reported in the original PR remains attributed to that PR's contributors.

Backport da7c29f (react#58097),
originally contributed by fairysword, to 0.87-stable.

Keep the existing Object callback annotations when resolving the upstream
typing conflicts. Preserve the original descriptor composition and regression
test without adding behavior changes.
@meta-cla

meta-cla Bot commented Nov 5, 2026

Copy link
Copy Markdown

Hi @brunohmagro!

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 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 Nov 5, 2026
@meta-cla

meta-cla Bot commented Nov 5, 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!

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. Pick Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant