Skip to content

feat(iOS): allow eager initialization of RCTRootViewFactory#49986

Closed
mdjastrzebski wants to merge 5 commits into
facebook:mainfrom
mdjastrzebski:feat/root-view-factory-eager-init
Closed

feat(iOS): allow eager initialization of RCTRootViewFactory#49986
mdjastrzebski wants to merge 5 commits into
facebook:mainfrom
mdjastrzebski:feat/root-view-factory-eager-init

Conversation

@mdjastrzebski
Copy link
Copy Markdown
Contributor

@mdjastrzebski mdjastrzebski commented Mar 12, 2025

Summary:

Expose eager initialization method on RCTRootViewFactory (iOS) so that application can prepare ReactHost/Bridge before actually creating a root view. Then creating a root view is significantly faster.

Changelog:

[IOS] [ADDED] - allow eager initialization of RCTRootViewFactory

Test Plan:

Invoke initializeReactHostWithLaunchOptions: before calling viewWithModuleName: and measure the time difference vs not using eager initilization:

Before

  • calling viewWithModuleName:: 63.39ms, 47.91 ms, 60.18ms

After:

  • calling initializeReactHostWithLaunchOptions: 52.41 ms, 81.03 ms, 60.52 ms
  • calling viewWithModuleName: 0.49 ms, 0.63 ms, 0.47 ms

Test run 3 times on iPhone simulator on M1 mac.

@facebook-github-bot facebook-github-bot added 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. labels Mar 12, 2025
Comment on lines +137 to +147
if (_configuration.bridgelessEnabled) {
// Enable TurboModule interop by default in Bridgeless mode
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);

[self createReactHostIfNeeded:launchOptions];
}

[self createBridgeIfNeeded:launchOptions];
[self createBridgeAdapterIfNeeded];
}
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.

is almost identical to the code in the viewWithModuleName:initialProperties:launchOptions:. Can we avoid code duplication and find a way to reuse it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

@okwasniewski okwasniewski left a comment

Choose a reason for hiding this comment

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

Looks good to me ✅

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 20, 2025
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cipolleschi merged this pull request in ddbb5fd.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @mdjastrzebski in ddbb5fd

When will my fix make it into a release? | How to file a pick request?

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. Merged This PR has been merged. 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.

5 participants