Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mdjastrzebski
Copy link
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
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
Contributor Author

Choose a reason for hiding this comment

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

done

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.

3 participants