Skip to content

perf(android): Create SDK view managers on demand - #7049

Open
alwx wants to merge 2 commits into
mainfrom
alwx/perf/7032
Open

alwx wants to merge 2 commits into
mainfrom
alwx/perf/7032

Conversation

@alwx

@alwx alwx commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

RNSentryPackage now implements ViewManagerOnDemandReactPackage. React Native gets only the names of the three Sentry view managers at startup. It creates a manager and builds its view config the first time JS uses it. createViewManagers does not change.

💡 Motivation and Context

Closes #7032. With the New Architecture on Android, React Native builds the view configs of all eager packages on the JS thread before the first screen renders. Apps that never render the time-to-display or replay mask views pay this cost too. The gain needs React Native 0.89+, which includes react/react-native@da7c29f.

💚 How did you test it?

I added unit tests for getViewManagerNames and createViewManager in RNSentryAndroidTester. I ran a release build of the RN sample (RN 0.88.1, New Architecture) on an Android 16 emulator. React Native created the three Sentry managers through createViewManager and did not call createViewManagers.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

alwx added 2 commits November 17, 2026 11:53
RNSentryPackage now implements ViewManagerOnDemandReactPackage. With the New Architecture, React Native builds the view configs of every eager package's view managers when JS first reads UIManager, on the JS thread before the first screen renders. On-demand packages only report their names, and React Native creates a view manager and builds its config the first time JS uses it.

Apps that never render RNSentryOnDrawReporter, RNSentryReplayMask or RNSentryReplayUnmask no longer pay for their configs at startup. The gain needs React Native 0.89+, which keeps lazy view manager getters lazy (react/react-native@da7c29f). Older versions still create the managers through the same path.

createViewManagers stays unchanged for setups that load view managers eagerly, such as the old architecture without lazy view managers. getViewManagerNames returns List<String> so it compiles against both the Java (List/Collection) and Kotlin versions of the interface.
Replace the PR_NUMBER placeholder with #7049 now that the PR exists.
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • perf(android): Create SDK view managers on demand by alwx in #7049
  • chore(deps): update Android SDK to v8.65.0 by github-actions in #7058

🤖 This preview updates automatically when you update the PR.

@github-actions

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against d3b820f

@alwx
alwx marked this pull request as ready for review November 17, 2026 13:16
@antonis antonis added ready-to-merge Triggers the full CI test suite and removed ready-to-merge Triggers the full CI test suite labels Nov 18, 2026

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once the tests are 🟢

Tested with the following configurations:

RN version Arch Setup main This PR
0.89.0-rc.1 New Default All 3 created at startup ✅ Created on first render
0.88.1 New Default All 3 created at startup ⚪ No gain (needs react-native#58097, in 0.89), no regressions
0.73.11 Old lazyViewManagersEnabled ❌ Views missing; TTD/Mask do nothing ✅ Created on demand (fixed)
0.71.19 Old Default Eager createViewManagers ✅ Unchanged

@alwx alwx added the ready-to-merge Triggers the full CI test suite label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: build Sentry's view manager configs on demand instead of at startup

2 participants