Skip to content

Commit

Permalink
Set concurrentRoot to true whenever Fabric is used in renderApplicati…
Browse files Browse the repository at this point in the history
…on (#42821)

Summary:
Pull Request resolved: #42821

As the title says, we want `concurrentRoot iif fabric`.
This makes sure we invoke renderApplication correctly.

Changelog:
[Internal] [Changed] - Set concurrentRoot to true whenever Fabric is used in renderApplication

Reviewed By: sammy-SC

Differential Revision: D53353017

fbshipit-source-id: 8de88adf528eb71f233233bd85c2c6ef9430fb16
  • Loading branch information
cortinico authored and facebook-github-bot committed Feb 7, 2024
1 parent 665c400 commit 30d186c
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
* - (UIViewController *)createRootViewController;
* - (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
* New Architecture:
* - (BOOL)concurrentRootEnabled
* - (BOOL)turboModuleEnabled;
* - (BOOL)fabricEnabled;
* - (NSDictionary *)prepareInitialProps
Expand Down
5 changes: 0 additions & 5 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
#import <react/runtime/JSRuntimeFactory.h>

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface RCTAppDelegate () <
RCTTurboModuleManagerDelegate,
RCTComponentViewFactoryComponentProvider,
Expand All @@ -53,9 +51,6 @@ @interface RCTAppDelegate () <
static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabricEnabled)
{
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;
}

Expand Down
11 changes: 4 additions & 7 deletions packages/react-native/Libraries/ReactNative/renderApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,13 @@ export default function renderApplication<Props: Object>(
);
}

if (fabric && !useConcurrentRoot) {
console.warn(
'Using Fabric without concurrent root is deprecated. Please enable concurrent root for this application.',
);
}
// We want to have concurrentRoot always enabled when you're on Fabric.
const useConcurrentRootOverride = fabric;

performanceLogger.startTimespan('renderApplication_React_render');
performanceLogger.setExtra(
'usedReactConcurrentRoot',
useConcurrentRoot ? '1' : '0',
useConcurrentRootOverride ? '1' : '0',
);
performanceLogger.setExtra('usedReactFabric', fabric ? '1' : '0');
performanceLogger.setExtra(
Expand All @@ -103,7 +100,7 @@ export default function renderApplication<Props: Object>(
element: renderable,
rootTag,
useFabric: Boolean(fabric),
useConcurrentRoot: Boolean(useConcurrentRoot),
useConcurrentRoot: Boolean(useConcurrentRootOverride),
});
performanceLogger.stopTimespan('renderApplication_React_render');
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public ReactActivityDelegate(
if (composedLaunchOptions == null) {
composedLaunchOptions = new Bundle();
}
composedLaunchOptions.putBoolean("concurrentRoot", true);
}
return composedLaunchOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ protected boolean isFabricEnabled() {
if (composedLaunchOptions == null) {
composedLaunchOptions = new Bundle();
}
composedLaunchOptions.putBoolean("concurrentRoot", true);
}
return composedLaunchOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ public JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
ReactRootView rootView = new ReactRootView(currentActivity);
boolean isFabric = ReactFeatureFlags.enableFabricRenderer;
rootView.setIsFabric(isFabric);
Bundle launchOptions = new Bundle();
launchOptions.putBoolean("concurrentRoot", isFabric);
rootView.startReactApplication(ReactInstanceManager.this, appKey, launchOptions);
rootView.startReactApplication(ReactInstanceManager.this, appKey, new Bundle());
return rootView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,8 @@ public JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
public View createRootView(String appKey) {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null && !reactHost.isSurfaceWithModuleNameAttached(appKey)) {
Bundle launchOptions = new Bundle();
launchOptions.putBoolean("concurrentRoot", true);

ReactSurfaceImpl reactSurface =
ReactSurfaceImpl.createWithView(currentActivity, appKey, launchOptions);
ReactSurfaceImpl.createWithView(currentActivity, appKey, new Bundle());
reactSurface.attach(reactHost);
reactSurface.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ReactActivityDelegateTest {
}

assertNotNull(delegate.inspectLaunchOptions)
assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot"))
assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot"))
// False because oncurrentRoot is hardcoded to true for Fabric inside renderApplication
assertFalse(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot"))
}

@Test
Expand Down Expand Up @@ -60,8 +60,8 @@ class ReactActivityDelegateTest {
}

assertNotNull(delegate.inspectLaunchOptions)
assertTrue(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot"))
assertTrue(delegate.inspectLaunchOptions!!.getBoolean("concurrentRoot"))
// False because oncurrentRoot is hardcoded to true for Fabric inside renderApplication
assertFalse(delegate.inspectLaunchOptions!!.containsKey("concurrentRoot"))
assertTrue(delegate.inspectLaunchOptions!!.containsKey("test-property"))
assertEquals("test-value", delegate.inspectLaunchOptions!!.getString("test-property"))
}
Expand Down

0 comments on commit 30d186c

Please sign in to comment.