Removing Fabric check from UIManagerProvider (#41982)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41982

Moving the check for Fabric i.e. `ReactFeatureFlags.enableFabricRenderer` to old JSI Module path logic instead of new UIManagerProvider path for Fabric initialization and changing the default of UIManagerProvider from `null` -> `reactApplicationContext -> null;` since we are adding null check on the returned `UIManager`

Slight change of design of API for JSI Module in order to address the issues faced due to `ReactFeatureFlags.enableFabricRenderer`,
1. Getting rid of this check for the new Fabric initialization and keeping the old JSI Module path intact.
2. Allowing the UIManager to be nullable so as to allow Twilight surface not have UIManager set even though they it succeeds in initializing the TwilightJSIModule.
3. As made the UIManager nullable, added the null check for the same.
4. This eradicates the dependency on this flag for Anna as well.

Reviewed By: christophpurrer

Differential Revision: D52273097

fbshipit-source-id: bdf8b1de3771250c987c8f8bd4e48192f67a1afa
This commit is contained in:
Arushi Kesarwani authored and Facebook GitHub Bot committed 2023-12-19 00:03:17 -08:00
1 parent 43826facfa
commit 1045b225f1
3 files changed
+7 -7

No files matched your search

@@ -1406,14 +1406,14 @@ public class ReactInstanceManager {
mJSIModulePackage.getJSIModules(
reactContext, catalystInstance.getJavaScriptContextHolder()));
}
if (ReactFeatureFlags.enableFabricRenderer) {
if (mUIManagerProvider != null) {
UIManager uiManager = mUIManagerProvider.createUIManager(reactContext);
if (mUIManagerProvider != null) {
UIManager uiManager = mUIManagerProvider.createUIManager(reactContext);
if (uiManager != null) {
uiManager.initialize();
catalystInstance.setFabricUIManager(uiManager);
} else {
catalystInstance.getJSIModule(JSIModuleType.UIManager);
}
} else if (ReactFeatureFlags.enableFabricRenderer) {
catalystInstance.getJSIModule(JSIModuleType.UIManager);
}
if (mBridgeIdleDebugListener != null) {
catalystInstance.addBridgeIdleDebugListener(mBridgeIdleDebugListener);
@@ -132,7 +132,7 @@ public abstract class ReactNativeHost {
}
protected @Nullable UIManagerProvider getUIManagerProvider() {
return null;
return reactApplicationContext -> null;
}
/** Returns whether or not to treat it as normal if Activity is null. */
@@ -18,5 +18,5 @@ import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
fun interface UIManagerProvider {
/* Provides a {@link com.facebook.react.bridge.UIManager} for the context received as a parameter. */
fun createUIManager(context: ReactApplicationContext): UIManager
fun createUIManager(context: ReactApplicationContext): UIManager?
}