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

[iOS] RNTester enable concurrent root when using Fabric #41166

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@
* By default, it assigns the rootView to the view property of the rootViewController
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
* For example: UISplitViewController requires `setViewController(_:for:)`
*
* @return: void
*/
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;

Expand Down
31 changes: 19 additions & 12 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ @interface RCTAppDelegate () <

#endif

static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabricEnabled)
{
#ifdef RCT_NEW_ARCH_ENABLED
NSMutableDictionary *mutableProps = [initialProps mutableCopy] ?: [NSMutableDictionary new];
// Hardcoding the Concurrent Root as it it not recommended to
// have the concurrentRoot turned off when Fabric is enabled.
mutableProps[kRNConcurrentRoot] = @(isFabricEnabled);
return mutableProps;
#else
return initialProps;
#endif
}

@interface RCTAppDelegate () <RCTCxxBridgeDelegate> {
std::shared_ptr<facebook::react::RuntimeScheduler> _runtimeScheduler;
}
Expand Down Expand Up @@ -80,18 +93,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
BOOL enableTM = NO;
BOOL enableBridgeless = NO;
BOOL fabricEnabled = NO;
#if RCT_NEW_ARCH_ENABLED
enableTM = self.turboModuleEnabled;
enableBridgeless = self.bridgelessEnabled;
fabricEnabled = [self fabricEnabled];
#endif
NSDictionary *initProps = updateInitialProps([self prepareInitialProps], fabricEnabled);

RCTAppSetupPrepareApp(application, enableTM);

UIView *rootView;
if (enableBridgeless) {
#if RCT_NEW_ARCH_ENABLED
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
RCTSetUseNativeViewConfigsInBridgelessMode([self fabricEnabled]);
RCTSetUseNativeViewConfigsInBridgelessMode(fabricEnabled);

// Enable TurboModule interop by default in Bridgeless mode
RCTEnableTurboModuleInterop(YES);
Expand All @@ -100,7 +116,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[self createReactHost];
[self unstable_registerLegacyComponents];
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
NSDictionary *initProps = [self prepareInitialProps];
RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:self.moduleName initialProperties:initProps];

RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
Expand All @@ -121,7 +136,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[self unstable_registerLegacyComponents];
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
#endif
NSDictionary *initProps = [self prepareInitialProps];

rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps];
}
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
Expand All @@ -143,15 +158,7 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge

- (NSDictionary *)prepareInitialProps
{
NSMutableDictionary *initProps = self.initialProps ? [self.initialProps mutableCopy] : [NSMutableDictionary new];

#ifdef RCT_NEW_ARCH_ENABLED
// Hardcoding the Concurrent Root as it it not recommended to
// have the concurrentRoot turned off when Fabric is enabled.
initProps[kRNConcurrentRoot] = @([self fabricEnabled]);
#endif

return initProps;
return self.initialProps;
}

- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
Expand Down