Skip to content

Commit bedf33f

Browse files
javachemeta-codesync[bot]
authored andcommitted
Deprecate ViewUtil.getUIManagerType and inline UIManagerType.Fabric (#56451)
Summary: With Fabric as the only supported renderer, `ViewUtil.getUIManagerType()` always returns `UIManagerType.FABRIC`. This diff inlines that constant throughout and removes all Paper-only code paths: - `ReactRootView.setIsFabric()` → no-op, `getUIManagerType()` → returns FABRIC - `ReactInstanceManager.attachRootViewToInstance` → Fabric-only (removes `addRootView`/`runApplication` path) - `ReactInstanceManager.detachRootViewFromInstance` → removes `AppRegistry.unmountApplicationComponentAtRootTag` path - `NativeAnimatedModule` → removes Fabric/non-Fabric animation counting, `willDispatchViewUpdates` is no-op - `PropsAnimatedNode.restoreDefaultValues()` → no-op (was only relevant for Paper ShadowNode sync) - `BackgroundStyleApplicator` → removes Fabric guards on outline/boxShadow/filter/blendMode setters - `BaseViewManager` → removes Fabric guards on filter/mixBlendMode - `TransformHelper` → removes `allowPercentageResolution` parameter (always true) - `TouchTargetHelper` → removes Fabric guard on overflow inset check - `ComponentsReactNativeSupportProcessor` → removes legacy Litho view creation path - `ReactHorizontalScrollContainerLegacyView` → deleted, `ReactHorizontalScrollContainerViewManager` simplified - `ReactTextView` → removes Paper-specific text update logic - `ViewUtil.getUIManagerType()` → deprecated, hardcoded to return FABRIC Pull Request resolved: #56451 Changelog: [Internal] Reviewed By: christophpurrer, NickGerleman Differential Revision: D91222827 fbshipit-source-id: 26172ad8111e927ff4787e566b19de9490659209
1 parent cf1975f commit bedf33f

24 files changed

Lines changed: 186 additions & 767 deletions

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,7 +3062,6 @@ public final class com/facebook/react/runtime/ReactSurfaceView : com/facebook/re
30623062
public fun <init> (Landroid/content/Context;Lcom/facebook/react/runtime/ReactSurfaceImpl;)V
30633063
public fun getCurrentReactContext ()Lcom/facebook/react/bridge/ReactContext;
30643064
public fun getJSModuleName ()Ljava/lang/String;
3065-
public fun getUIManagerType ()I
30663065
public fun handleException (Ljava/lang/Throwable;)V
30673066
public fun hasActiveReactContext ()Z
30683067
public fun hasActiveReactInstance ()Z
@@ -3071,7 +3070,6 @@ public final class com/facebook/react/runtime/ReactSurfaceView : com/facebook/re
30713070
public fun onChildStartedNativeGesture (Landroid/view/View;Landroid/view/MotionEvent;)V
30723071
public fun requestChildFocus (Landroid/view/View;Landroid/view/View;)V
30733072
public fun requestDisallowInterceptTouchEvent (Z)V
3074-
public fun setIsFabric (Z)V
30753073
}
30763074

30773075
public abstract class com/facebook/react/runtime/cxxreactpackage/CxxReactPackage {
@@ -5520,7 +5518,6 @@ public final class com/facebook/react/views/scroll/ReactHorizontalScrollContaine
55205518
public static final field Companion Lcom/facebook/react/views/scroll/ReactHorizontalScrollContainerViewManager$Companion;
55215519
public static final field REACT_CLASS Ljava/lang/String;
55225520
public fun <init> ()V
5523-
public synthetic fun createViewInstance (ILcom/facebook/react/uimanager/ThemedReactContext;Lcom/facebook/react/uimanager/ReactStylesDiffMap;Lcom/facebook/react/uimanager/StateWrapper;)Landroid/view/View;
55245521
public synthetic fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Landroid/view/View;
55255522
public fun createViewInstance (Lcom/facebook/react/uimanager/ThemedReactContext;)Lcom/facebook/react/views/view/ReactViewGroup;
55265523
public fun getName ()Ljava/lang/String;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java

Lines changed: 30 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
import com.facebook.react.internal.ChoreographerProvider;
7878
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
7979
import com.facebook.react.modules.appearance.AppearanceModule;
80-
import com.facebook.react.modules.appregistry.AppRegistry;
8180
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
8281
import com.facebook.react.modules.core.DeviceEventManagerModule;
8382
import com.facebook.react.modules.core.ReactChoreographer;
@@ -87,7 +86,6 @@
8786
import com.facebook.react.uimanager.ReactStage;
8887
import com.facebook.react.uimanager.UIManagerHelper;
8988
import com.facebook.react.uimanager.ViewManager;
90-
import com.facebook.react.uimanager.common.UIManagerType;
9189
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
9290
import com.facebook.soloader.SoLoader;
9391
import com.facebook.systrace.Systrace;
@@ -767,10 +765,7 @@ public void destroy() {
767765
synchronized (mReactContextLock) {
768766
if (mCurrentReactContext != null) {
769767
for (ReactRoot reactRoot : mAttachedReactRoots) {
770-
// Fabric surfaces must be cleaned up when React Native is destroyed.
771-
if (reactRoot.getUIManagerType() == UIManagerType.FABRIC) {
772-
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
773-
}
768+
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
774769
}
775770

776771
mCurrentReactContext.destroy();
@@ -1271,9 +1266,7 @@ private void attachRootViewToInstance(final ReactRoot reactRoot) {
12711266

12721267
Systrace.beginSection(TRACE_TAG_REACT, "attachRootViewToInstance");
12731268

1274-
@Nullable
1275-
UIManager uiManager =
1276-
UIManagerHelper.getUIManager(mCurrentReactContext, reactRoot.getUIManagerType());
1269+
@Nullable UIManager uiManager = UIManagerHelper.getUIManager(mCurrentReactContext, FABRIC);
12771270

12781271
// If we can't get a UIManager something has probably gone horribly wrong
12791272
if (uiManager == null) {
@@ -1284,28 +1277,16 @@ private void attachRootViewToInstance(final ReactRoot reactRoot) {
12841277

12851278
@Nullable Bundle initialProperties = reactRoot.getAppProperties();
12861279

1287-
final int rootTag;
1288-
if (reactRoot.getUIManagerType() == FABRIC) {
1289-
rootTag =
1290-
uiManager.startSurface(
1291-
reactRoot.getRootViewGroup(),
1292-
reactRoot.getJSModuleName(),
1293-
initialProperties == null
1294-
? new WritableNativeMap()
1295-
: Arguments.fromBundle(initialProperties),
1296-
reactRoot.getWidthMeasureSpec(),
1297-
reactRoot.getHeightMeasureSpec());
1298-
reactRoot.setShouldLogContentAppeared(true);
1299-
} else {
1300-
rootTag =
1301-
uiManager.addRootView(
1302-
reactRoot.getRootViewGroup(),
1303-
initialProperties == null
1304-
? new WritableNativeMap()
1305-
: Arguments.fromBundle(initialProperties));
1306-
reactRoot.setRootViewTag(rootTag);
1307-
reactRoot.runApplication();
1308-
}
1280+
final int rootTag =
1281+
uiManager.startSurface(
1282+
reactRoot.getRootViewGroup(),
1283+
reactRoot.getJSModuleName(),
1284+
initialProperties == null
1285+
? new WritableNativeMap()
1286+
: Arguments.fromBundle(initialProperties),
1287+
reactRoot.getWidthMeasureSpec(),
1288+
reactRoot.getHeightMeasureSpec());
1289+
reactRoot.setShouldLogContentAppeared(true);
13091290

13101291
Systrace.beginAsyncSection(TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag);
13111292
UiThreadUtil.runOnUiThread(
@@ -1326,36 +1307,28 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC
13261307
return;
13271308
}
13281309

1329-
@UIManagerType int uiManagerType = reactRoot.getUIManagerType();
1330-
if (uiManagerType == UIManagerType.FABRIC) {
1331-
// Stop surface in Fabric.
1332-
// Calling FabricUIManager.stopSurface causes the C++ Binding.stopSurface
1333-
// to be called synchronously over the JNI, which causes an empty tree
1334-
// to be committed via the Scheduler, which will cause mounting instructions
1335-
// to be queued up and synchronously executed to delete and remove
1336-
// all the views in the hierarchy.
1337-
final int surfaceId = reactRoot.getRootViewTag();
1338-
if (surfaceId != View.NO_ID) {
1339-
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, uiManagerType);
1340-
if (uiManager != null) {
1341-
uiManager.stopSurface(surfaceId);
1342-
} else {
1343-
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
1344-
}
1310+
// Stop surface in Fabric.
1311+
// Calling FabricUIManager.stopSurface causes the C++ Binding.stopSurface
1312+
// to be called synchronously over the JNI, which causes an empty tree
1313+
// to be committed via the Scheduler, which will cause mounting instructions
1314+
// to be queued up and synchronously executed to delete and remove
1315+
// all the views in the hierarchy.
1316+
final int surfaceId = reactRoot.getRootViewTag();
1317+
if (surfaceId != View.NO_ID) {
1318+
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, FABRIC);
1319+
if (uiManager != null) {
1320+
uiManager.stopSurface(surfaceId);
13451321
} else {
1346-
ReactSoftExceptionLogger.logSoftException(
1347-
TAG,
1348-
new RuntimeException(
1349-
"detachRootViewFromInstance called with ReactRootView with invalid id"));
1322+
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
13501323
}
1351-
1352-
clearReactRoot(reactRoot);
13531324
} else {
1354-
reactContext
1355-
.getCatalystInstance()
1356-
.getJSModule(AppRegistry.class)
1357-
.unmountApplicationComponentAtRootTag(reactRoot.getRootViewTag());
1325+
ReactSoftExceptionLogger.logSoftException(
1326+
TAG,
1327+
new RuntimeException(
1328+
"detachRootViewFromInstance called with ReactRootView with invalid id"));
13581329
}
1330+
1331+
clearReactRoot(reactRoot);
13591332
}
13601333

13611334
@ThreadConfined(UI)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import static com.facebook.infer.annotation.ThreadConfined.UI;
1111
import static com.facebook.react.uimanager.BlendModeHelper.needsIsolatedLayer;
1212
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
13-
import static com.facebook.react.uimanager.common.UIManagerType.LEGACY;
1413
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT;
1514

1615
import android.annotation.SuppressLint;
@@ -51,6 +50,7 @@
5150
import com.facebook.react.bridge.WritableMap;
5251
import com.facebook.react.bridge.WritableNativeMap;
5352
import com.facebook.react.common.annotations.VisibleForTesting;
53+
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
5454
import com.facebook.react.config.ReactFeatureFlags;
5555
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
5656
import com.facebook.react.modules.appregistry.AppRegistry;
@@ -69,7 +69,6 @@
6969
import com.facebook.react.uimanager.RootViewUtil;
7070
import com.facebook.react.uimanager.UIManagerHelper;
7171
import com.facebook.react.uimanager.common.UIManagerType;
72-
import com.facebook.react.uimanager.common.ViewUtil;
7372
import com.facebook.react.uimanager.events.EventDispatcher;
7473
import com.facebook.systrace.Systrace;
7574
import java.util.concurrent.atomic.AtomicInteger;
@@ -116,7 +115,6 @@ public interface ReactRootViewEventListener {
116115
private int mLastHeight = 0;
117116
private int mLastOffsetX = Integer.MIN_VALUE;
118117
private int mLastOffsetY = Integer.MIN_VALUE;
119-
private @UIManagerType int mUIManagerType = LEGACY;
120118
private final AtomicInteger mState = new AtomicInteger(STATE_STOPPED);
121119

122120
public ReactRootView(Context context) {
@@ -307,9 +305,7 @@ protected void dispatchDraw(Canvas canvas) {
307305
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
308306

309307
BlendMode mixBlendMode = null;
310-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
311-
&& ViewUtil.getUIManagerType(this) == UIManagerType.FABRIC
312-
&& needsIsolatedLayer(this)) {
308+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && needsIsolatedLayer(this)) {
313309
mixBlendMode = (BlendMode) child.getTag(R.id.mix_blend_mode);
314310
if (mixBlendMode != null) {
315311
Paint p = new Paint();
@@ -474,7 +470,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
474470
}
475471

476472
private boolean isFabric() {
477-
return getUIManagerType() == FABRIC;
473+
return true;
478474
}
479475

480476
@Override
@@ -646,9 +642,7 @@ private void updateRootLayoutSpecs(
646642
final ReactContext reactApplicationContext = getCurrentReactContext();
647643

648644
if (reactApplicationContext != null) {
649-
@Nullable
650-
UIManager uiManager =
651-
UIManagerHelper.getUIManager(reactApplicationContext, getUIManagerType());
645+
@Nullable UIManager uiManager = UIManagerHelper.getUIManager(reactApplicationContext, FABRIC);
652646
// Ignore calling updateRootLayoutSpecs if UIManager is not properly initialized.
653647
if (uiManager != null) {
654648
// In Fabric only, get position of view within screen
@@ -887,15 +881,18 @@ public void handleException(final Throwable t) {
887881
getCurrentReactContext().handleException(e);
888882
}
889883

884+
@LegacyArchitecture
885+
@Deprecated
890886
public void setIsFabric(boolean isFabric) {
891-
mUIManagerType = isFabric ? FABRIC : LEGACY;
887+
/* noop */
892888
}
893889

894890
@Override
895891
public @UIManagerType int getUIManagerType() {
896-
return mUIManagerType;
892+
return FABRIC;
897893
}
898894

895+
@LegacyArchitecture
899896
@Nullable
900897
public ReactInstanceManager getReactInstanceManager() {
901898
return mReactInstanceManager;

0 commit comments

Comments
 (0)