Skip to content

[0.87] Preserve lazy ViewManager initialization in UIManager #1503

Open

Description

@brunohmagro

Target Branch

0.87

Link to commit or PR to be picked

Adapted backport PR against 0.87-stable: react/react-native#59812

Original landed commit: react/react-native@da7c29f

Original PR: react/react-native#58097

Description

Please consider this Android startup performance fix for the next 0.87 patch release, under the support policy's performance improvements criterion.

The 0.87 series is in active support. At 0.87-stable commit 2a41d8cb82636b914ea84251b2d53e1a9c5b96ed, UIManager.js still spreads UIManagerImpl. In Bridgeless mode, that evaluates enumerable lazy ViewManager getters when the module is imported, synchronously loading configurations that have not been requested. The upstream fix preserves property descriptors so those configurations remain lazy.

The original PR is closed because Meta's sync process landed it on main; it is not an unmerged proposal. A direct application to 0.87 conflicts on the callback-typing hunks. PR #59812 resolves that mismatch by keeping 0.87's existing (error: Object) => void annotations and omitting the unnecessary UnsafeObject import. It carries the original descriptor-composition fix and the original regression test. No dependency or public API changes are included.

We use React Native 0.87.1 with a local fix for this same eager-getter issue. This request uses the reviewed upstream implementation and does not claim a quantified startup improvement from our app's combined optimizations.

Validation on the adapted 0.87 checkout:

  • The upstream regression test fails before the fix because importing UIManager calls getConstantsForViewManager once instead of zero times.
  • It passes after the fix, including the assertions for an own/enumerable property and one configuration call across repeated accesses.
  • Full JavaScript suite: 219 suites, 5,662 tests and 1,658 snapshots passed; 1 test skipped. Jest reports a worker teardown warning, with exit code 0.
  • Flow: 0 errors.
  • Full lint and formatting checks passed.
  • yarn build-types --validate passed: public API snapshot unchanged.
  • No fresh native build or device benchmark was run for this backport; that limitation is recorded in the PR.

The change is limited to UIManager.js and the original regression test. Existing measurement and command overrides are preserved. Please evaluate inclusion according to the release crew's risk assessment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions