Skip to content

Commit 7a2db6a

Browse files
javachefacebook-github-bot
authored andcommitted
Remove obsolete Android Fabric surface paths (#59036)
Summary: ReactInstanceManager can no longer initialise the legacy bridge, so the bridge+Fabric surface lifecycle JNI entry points are unreachable. Remove those methods while retaining the existing UIManager signatures as explicit unsupported/no-op compatibility overrides, and simplify native surface tracking to weak Java-owned SurfaceHandlers. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D124979204
1 parent ee9ce09 commit 7a2db6a

5 files changed

Lines changed: 30 additions & 439 deletions

File tree

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java‎

Lines changed: 5 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
import static com.facebook.infer.annotation.ThreadConfined.ANY;
1111
import static com.facebook.infer.annotation.ThreadConfined.UI;
12-
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMaxSize;
13-
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getMinSize;
1412
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getYogaMeasureMode;
1513
import static com.facebook.react.fabric.mounting.LayoutMetricsConversions.getYogaSize;
1614
import static com.facebook.react.uimanager.UIManagerHelper.PADDING_BOTTOM_INDEX;
@@ -20,7 +18,6 @@
2018

2119
import android.annotation.SuppressLint;
2220
import android.content.Context;
23-
import android.graphics.Point;
2421
import android.os.SystemClock;
2522
import android.view.View;
2623
import android.view.accessibility.AccessibilityEvent;
@@ -38,7 +35,6 @@
3835
import com.facebook.react.bridge.GuardedRunnable;
3936
import com.facebook.react.bridge.LifecycleEventListener;
4037
import com.facebook.react.bridge.NativeArray;
41-
import com.facebook.react.bridge.NativeMap;
4238
import com.facebook.react.bridge.ReactApplicationContext;
4339
import com.facebook.react.bridge.ReactContext;
4440
import com.facebook.react.bridge.ReactMarker;
@@ -73,14 +69,11 @@
7369
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
7470
import com.facebook.react.internal.interop.InteropEventEmitter;
7571
import com.facebook.react.modules.core.ReactChoreographer;
76-
import com.facebook.react.modules.i18nmanager.I18nUtil;
7772
import com.facebook.react.uimanager.DisplayMetricsHolder;
7873
import com.facebook.react.uimanager.GuardedFrameCallback;
79-
import com.facebook.react.uimanager.IllegalViewOperationException;
8074
import com.facebook.react.uimanager.PixelUtil;
8175
import com.facebook.react.uimanager.ReactRoot;
8276
import com.facebook.react.uimanager.ReactRootViewTagGenerator;
83-
import com.facebook.react.uimanager.RootViewUtil;
8477
import com.facebook.react.uimanager.StateWrapper;
8578
import com.facebook.react.uimanager.ThemedReactContext;
8679
import com.facebook.react.uimanager.UIManagerHelper;
@@ -271,26 +264,7 @@ public FabricUIManager(
271264
@Deprecated
272265
public <T extends View> int addRootView(
273266
final T rootView, final @Nullable WritableMap initialProps) {
274-
ReactSoftExceptionLogger.logSoftException(
275-
TAG,
276-
new IllegalViewOperationException(
277-
"Do not call addRootView in Fabric; it is unsupported. Use ReactHost.createSurface(...)"
278-
+ " and ReactSurface.start() instead."));
279-
280-
ReactRoot reactRootView = (ReactRoot) rootView;
281-
final int rootTag = reactRootView.getRootViewTag();
282-
283-
ThemedReactContext reactContext =
284-
new ThemedReactContext(
285-
mReactApplicationContext, rootView.getContext(), reactRootView.getSurfaceID(), rootTag);
286-
mMountingManager.startSurface(rootTag, reactContext, rootView);
287-
String moduleName = reactRootView.getJSModuleName();
288-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
289-
FLog.d(TAG, "Starting surface for module: %s and reactTag: %d", moduleName, rootTag);
290-
}
291-
Assertions.assertNotNull(mBinding, "Binding in FabricUIManager is null");
292-
mBinding.startSurface(rootTag, moduleName, (NativeMap) initialProps);
293-
return rootTag;
267+
throw new UnsupportedOperationException("FabricUIManager.addRootView is unsupported.");
294268
}
295269

296270
/**
@@ -358,36 +332,8 @@ public <T extends View> int startSurface(
358332
final @Nullable WritableMap initialProps,
359333
int widthMeasureSpec,
360334
int heightMeasureSpec) {
361-
final int rootTag = ((ReactRoot) rootView).getRootViewTag();
362-
Context context = rootView.getContext();
363-
ThemedReactContext reactContext =
364-
new ThemedReactContext(mReactApplicationContext, context, moduleName, rootTag);
365-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
366-
FLog.d(TAG, "Starting surface for module: %s and reactTag: %d", moduleName, rootTag);
367-
}
368-
mMountingManager.startSurface(rootTag, reactContext, rootView);
369-
370-
// If startSurface is executed in the UIThread then, it uses the ViewportOffset from the View,
371-
// Otherwise Fabric relies on calling {@link Binding#setConstraints} method to update the
372-
// ViewportOffset during measurement or onLayout.
373-
@SuppressLint("WrongThread")
374-
Point viewportOffset =
375-
UiThreadUtil.isOnUiThread() ? RootViewUtil.getViewportOffset(rootView) : new Point(0, 0);
376-
377-
Assertions.assertNotNull(mBinding, "Binding in FabricUIManager is null");
378-
mBinding.startSurfaceWithConstraints(
379-
rootTag,
380-
moduleName,
381-
(NativeMap) initialProps,
382-
getMinSize(widthMeasureSpec),
383-
getMaxSize(widthMeasureSpec),
384-
getMinSize(heightMeasureSpec),
385-
getMaxSize(heightMeasureSpec),
386-
viewportOffset.x,
387-
viewportOffset.y,
388-
I18nUtil.getInstance().isRTL(context),
389-
I18nUtil.getInstance().doLeftAndRightSwapInRTL(context));
390-
return rootTag;
335+
throw new UnsupportedOperationException(
336+
"FabricUIManager.startSurface(View, ...) is unsupported.");
391337
}
392338

393339
public void startSurface(
@@ -446,14 +392,7 @@ public void onRequestEventBeat() {
446392
@ThreadConfined(ANY)
447393
@Override
448394
public void stopSurface(final int surfaceID) {
449-
// Mark surfaceId as dead, stop executing mounting instructions
450-
mMountingManager.stopSurface(surfaceID);
451-
452-
// Communicate stopSurface to Cxx - causes an empty ShadowTree to be committed,
453-
// but all mounting instructions will be ignored because stopSurface was called
454-
// on the MountingManager
455-
Assertions.assertNotNull(mBinding, "Binding in FabricUIManager is null");
456-
mBinding.stopSurface(surfaceID);
395+
throw new UnsupportedOperationException("FabricUIManager.stopSurface(int) is unsupported.");
457396
}
458397

459398
@Override
@@ -1130,43 +1069,7 @@ public void updateRootLayoutSpecs(
11301069
final int widthMeasureSpec,
11311070
final int heightMeasureSpec,
11321071
final int offsetX,
1133-
final int offsetY) {
1134-
1135-
if (ReactNativeFeatureFlags.enableFabricLogs()) {
1136-
FLog.d(TAG, "Updating Root Layout Specs for [%d]", surfaceId);
1137-
}
1138-
1139-
SurfaceMountingManager surfaceMountingManager = mMountingManager.getSurfaceManager(surfaceId);
1140-
1141-
// TODO T83615646: make this a hard-crash in the future.
1142-
if (surfaceMountingManager == null) {
1143-
ReactSoftExceptionLogger.logSoftException(
1144-
TAG,
1145-
new IllegalViewOperationException(
1146-
"Cannot updateRootLayoutSpecs on surfaceId that does not exist: " + surfaceId));
1147-
return;
1148-
}
1149-
1150-
Context context = surfaceMountingManager.getContext();
1151-
boolean isRTL = false;
1152-
boolean doLeftAndRightSwapInRTL = false;
1153-
if (context != null) {
1154-
isRTL = I18nUtil.getInstance().isRTL(context);
1155-
doLeftAndRightSwapInRTL = I18nUtil.getInstance().doLeftAndRightSwapInRTL(context);
1156-
}
1157-
1158-
Assertions.assertNotNull(mBinding, "Binding in FabricUIManager is null");
1159-
mBinding.setConstraints(
1160-
surfaceId,
1161-
getMinSize(widthMeasureSpec),
1162-
getMaxSize(widthMeasureSpec),
1163-
getMinSize(heightMeasureSpec),
1164-
getMaxSize(heightMeasureSpec),
1165-
offsetX,
1166-
offsetY,
1167-
isRTL,
1168-
doLeftAndRightSwapInRTL);
1169-
}
1072+
final int offsetY) {}
11701073

11711074
@Override
11721075
public @Nullable View resolveView(int reactTag) {

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManagerBinding.kt‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ package com.facebook.react.fabric
1010
import android.annotation.SuppressLint
1111
import com.facebook.jni.HybridClassBase
1212
import com.facebook.proguard.annotations.DoNotStripAny
13-
import com.facebook.react.bridge.NativeMap
1413
import com.facebook.react.bridge.RuntimeExecutor
1514
import com.facebook.react.bridge.RuntimeScheduler
1615
import com.facebook.react.fabric.events.EventBeatManager
17-
import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity
1816

1917
@DoNotStripAny
2018
@SuppressLint("MissingNativeLoadLibrary")
@@ -33,22 +31,6 @@ internal class FabricUIManagerBinding : HybridClassBase() {
3331
componentsRegistry: ComponentFactory,
3432
)
3533

36-
external fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap?)
37-
38-
external fun startSurfaceWithConstraints(
39-
surfaceId: Int,
40-
moduleName: String,
41-
initialProps: NativeMap?,
42-
minWidth: Float,
43-
maxWidth: Float,
44-
minHeight: Float,
45-
maxHeight: Float,
46-
offsetX: Float,
47-
offsetY: Float,
48-
isRTL: Boolean,
49-
doLeftAndRightSwapInRTL: Boolean,
50-
)
51-
5234
external fun startSurfaceWithSurfaceHandler(
5335
surfaceId: Int,
5436
surfaceHandler: SurfaceHandlerBinding,
@@ -59,24 +41,8 @@ internal class FabricUIManagerBinding : HybridClassBase() {
5941

6042
external fun getRelativeAncestorList(rootTag: Int, childTag: Int): IntArray
6143

62-
external fun stopSurface(surfaceId: Int)
63-
6444
external fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)
6545

66-
external fun setPixelDensity(pointScaleFactor: Float)
67-
68-
external fun setConstraints(
69-
surfaceId: Int,
70-
minWidth: Float,
71-
maxWidth: Float,
72-
minHeight: Float,
73-
maxHeight: Float,
74-
offsetX: Float,
75-
offsetY: Float,
76-
isRTL: Boolean,
77-
doLeftAndRightSwapInRTL: Boolean,
78-
)
79-
8046
external fun driveCxxAnimations()
8147

8248
external fun driveAnimationBackend(frameTimeNanos: Long)
@@ -105,7 +71,6 @@ internal class FabricUIManagerBinding : HybridClassBase() {
10571
eventBeatManager,
10672
componentFactory,
10773
)
108-
setPixelDensity(getDisplayMetricDensity())
10974
}
11075

11176
private external fun uninstallFabricUIManager()

0 commit comments

Comments
 (0)