Skip to content

Commit 8d5ce24

Browse files
javachefacebook-github-bot
authored andcommitted
Remove obsolete Android UIManager surface APIs
Summary: The legacy bridge can no longer be initialized, and the native bridge+Fabric surface path was removed by the parent diff. Remove the corresponding View-based lifecycle APIs from `UIManager`, `FabricUIManager`, and `UIManagerModule`, along with their throwing implementations and unreachable `ReactInstanceManager` call paths. The supported `SurfaceHandlerBinding` lifecycle remains unchanged. Changelog: [Android][Breaking] - Remove legacy View-based surface lifecycle methods from `UIManager`, `FabricUIManager`, and `UIManagerModule`. Reviewed By: christophpurrer Differential Revision: D124983537
1 parent bca384f commit 8d5ce24

7 files changed

Lines changed: 4 additions & 258 deletions

File tree

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,6 @@ public final class com/facebook/react/bridge/ScrollEndedListeners {
13641364
}
13651365

13661366
public abstract interface class com/facebook/react/bridge/UIManager : com/facebook/react/bridge/PerformanceCounter {
1367-
public abstract fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
13681367
public abstract fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
13691368
public abstract fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
13701369
public abstract fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
@@ -1378,8 +1377,6 @@ public abstract interface class com/facebook/react/bridge/UIManager : com/facebo
13781377
public abstract fun resolveCustomDirectEventName (Ljava/lang/String;)Ljava/lang/String;
13791378
public abstract fun resolveView (I)Landroid/view/View;
13801379
public abstract fun sendAccessibilityEvent (II)V
1381-
public abstract fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
1382-
public abstract fun stopSurface (I)V
13831380
public abstract fun sweepActiveTouchForTag (II)V
13841381
public abstract fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
13851382
public abstract fun updateRootLayoutSpecs (IIIII)V
@@ -2248,7 +2245,6 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
22482245
public static final field TAG Ljava/lang/String;
22492246
public field mDevToolsReactPerfLogger Lcom/facebook/react/fabric/DevToolsReactPerfLogger;
22502247
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerRegistry;Lcom/facebook/react/uimanager/events/BatchEventDispatchedListener;)V
2251-
public fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
22522248
public fun addUIBlock (Lcom/facebook/react/fabric/interop/UIBlock;)V
22532249
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
22542250
public fun attachRootView (Lcom/facebook/react/fabric/SurfaceHandlerBinding;Landroid/view/View;)V
@@ -2286,9 +2282,7 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
22862282
public fun sendAccessibilityEvent (II)V
22872283
public fun sendAccessibilityEventFromJS (IILjava/lang/String;)V
22882284
public fun setJSResponder (IIIZ)V
2289-
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
22902285
public fun startSurface (Lcom/facebook/react/fabric/SurfaceHandlerBinding;Landroid/content/Context;Landroid/view/View;)V
2291-
public fun stopSurface (I)V
22922286
public fun stopSurface (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
22932287
public fun sweepActiveTouchForTag (II)V
22942288
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
@@ -4241,8 +4235,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
42414235
public static final field TAG Ljava/lang/String;
42424236
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Lcom/facebook/react/uimanager/ViewManagerResolver;I)V
42434237
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/util/List;I)V
4244-
public fun addRootView (Landroid/view/View;)I
4245-
public fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
42464238
public fun addUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
42474239
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
42484240
public fun clearJSResponder ()V
@@ -4287,8 +4279,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
42874279
public fun setJSResponder (IZ)V
42884280
public fun setLayoutAnimationEnabledExperimental (Z)V
42894281
public fun setViewLocalData (ILjava/lang/Object;)V
4290-
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
4291-
public fun stopSurface (I)V
42924282
public fun sweepActiveTouchForTag (II)V
42934283
public fun synchronouslyUpdateViewOnUIThread (ILcom/facebook/react/bridge/ReadableMap;)V
42944284
public fun updateInsetsPadding (IIIII)V

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

Lines changed: 4 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
package com.facebook.react;
99

1010
import static com.facebook.infer.annotation.ThreadConfined.UI;
11-
import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROOT_VIEWS_END;
12-
import static com.facebook.react.bridge.ReactMarkerConstants.ATTACH_MEASURED_ROOT_VIEWS_START;
1311
import static com.facebook.react.bridge.ReactMarkerConstants.CHANGE_THREAD_PRIORITY;
1412
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_END;
1513
import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_VIEW_MANAGERS_START;
@@ -20,7 +18,6 @@
2018
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_END;
2119
import static com.facebook.react.bridge.ReactMarkerConstants.SETUP_REACT_CONTEXT_START;
2220
import static com.facebook.react.bridge.ReactMarkerConstants.VM_INIT;
23-
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
2421
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT;
2522

2623
import android.annotation.SuppressLint;
@@ -42,7 +39,6 @@
4239
import com.facebook.infer.annotation.Assertions;
4340
import com.facebook.infer.annotation.ThreadConfined;
4441
import com.facebook.infer.annotation.ThreadSafe;
45-
import com.facebook.react.bridge.Arguments;
4642
import com.facebook.react.bridge.CatalystInstance;
4743
import com.facebook.react.bridge.JSBundleLoader;
4844
import com.facebook.react.bridge.JSExceptionHandler;
@@ -54,10 +50,8 @@
5450
import com.facebook.react.bridge.ReactMarkerConstants;
5551
import com.facebook.react.bridge.ReactNoCrashSoftException;
5652
import com.facebook.react.bridge.ReactSoftExceptionLogger;
57-
import com.facebook.react.bridge.UIManager;
5853
import com.facebook.react.bridge.UIManagerProvider;
5954
import com.facebook.react.bridge.UiThreadUtil;
60-
import com.facebook.react.bridge.WritableNativeMap;
6155
import com.facebook.react.common.LifecycleState;
6256
import com.facebook.react.common.ReactConstants;
6357
import com.facebook.react.common.SurfaceDelegateFactory;
@@ -82,8 +76,6 @@
8276
import com.facebook.react.packagerconnection.RequestHandler;
8377
import com.facebook.react.uimanager.DisplayMetricsHolder;
8478
import com.facebook.react.uimanager.ReactRoot;
85-
import com.facebook.react.uimanager.ReactStage;
86-
import com.facebook.react.uimanager.UIManagerHelper;
8779
import com.facebook.react.uimanager.ViewManager;
8880
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
8981
import com.facebook.soloader.SoLoader;
@@ -766,7 +758,7 @@ public void destroy() {
766758
synchronized (mReactContextLock) {
767759
if (mCurrentReactContext != null) {
768760
for (ReactRoot reactRoot : mAttachedReactRoots) {
769-
detachRootViewFromInstance(reactRoot, mCurrentReactContext);
761+
detachRootViewFromInstance(reactRoot);
770762
}
771763

772764
mCurrentReactContext.destroy();
@@ -910,14 +902,6 @@ public void attachRootView(ReactRoot reactRoot) {
910902
} else {
911903
FLog.e(ReactConstants.TAG, "ReactRoot was attached multiple times");
912904
}
913-
914-
// If react context is being created in the background, JS application will be started
915-
// automatically when creation completes, as reactRoot is part of the attached
916-
// reactRoot list.
917-
ReactContext currentContext = getCurrentReactContext();
918-
if (mCreateReactContextThread == null && currentContext != null) {
919-
attachRootViewToInstance(reactRoot);
920-
}
921905
}
922906
}
923907

@@ -935,11 +919,7 @@ public void detachRootView(ReactRoot reactRoot) {
935919
if (!mAttachedReactRoots.remove(reactRoot)) {
936920
return;
937921
}
938-
939-
ReactContext reactContext = mCurrentReactContext;
940-
if (reactContext != null && reactContext.hasActiveReactInstance()) {
941-
detachRootViewFromInstance(reactRoot, reactContext);
942-
}
922+
clearReactRoot(reactRoot);
943923
}
944924

945925
/** Uses configured {@link ReactPackage} instances to create all view managers. */
@@ -1217,12 +1197,6 @@ private void setupReactContext(final ReactApplicationContext reactContext) {
12171197

12181198
mDevSupportManager.onNewReactContextCreated(reactContext);
12191199
mMemoryPressureRouter.addMemoryPressureListener(catalystInstance);
1220-
1221-
ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_START);
1222-
for (ReactRoot reactRoot : mAttachedReactRoots) {
1223-
attachRootViewToInstance(reactRoot);
1224-
}
1225-
ReactMarker.logMarker(ATTACH_MEASURED_ROOT_VIEWS_END);
12261200
}
12271201

12281202
// There is a race condition here - `finalListeners` can contain null entries
@@ -1260,48 +1234,7 @@ private void setupReactContext(final ReactApplicationContext reactContext) {
12601234
ReactMarker.logMarker(ReactMarkerConstants.REACT_BRIDGE_LOADING_END);
12611235
}
12621236

1263-
private void attachRootViewToInstance(final ReactRoot reactRoot) {
1264-
FLog.d(ReactConstants.TAG, "ReactInstanceManager.attachRootViewToInstance()");
1265-
if (!reactRoot.getState().compareAndSet(ReactRoot.STATE_STOPPED, ReactRoot.STATE_STARTED)) {
1266-
// Already started
1267-
return;
1268-
}
1269-
1270-
Systrace.beginSection(TRACE_TAG_REACT, "attachRootViewToInstance");
1271-
1272-
@Nullable UIManager uiManager = UIManagerHelper.getUIManager(mCurrentReactContext, FABRIC);
1273-
1274-
// If we can't get a UIManager something has probably gone horribly wrong
1275-
if (uiManager == null) {
1276-
throw new IllegalStateException(
1277-
"Unable to attach a rootView to ReactInstance when UIManager is not properly"
1278-
+ " initialized.");
1279-
}
1280-
1281-
@Nullable Bundle initialProperties = reactRoot.getAppProperties();
1282-
1283-
final int rootTag =
1284-
uiManager.startSurface(
1285-
reactRoot.getRootViewGroup(),
1286-
reactRoot.getJSModuleName(),
1287-
initialProperties == null
1288-
? new WritableNativeMap()
1289-
: Arguments.fromBundle(initialProperties),
1290-
reactRoot.getWidthMeasureSpec(),
1291-
reactRoot.getHeightMeasureSpec());
1292-
reactRoot.setShouldLogContentAppeared(true);
1293-
1294-
Systrace.beginAsyncSection(TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag);
1295-
UiThreadUtil.runOnUiThread(
1296-
() -> {
1297-
Systrace.endAsyncSection(
1298-
TRACE_TAG_REACT, "pre_rootView.onAttachedToReactInstance", rootTag);
1299-
reactRoot.onStage(ReactStage.ON_ATTACH_TO_INSTANCE);
1300-
});
1301-
Systrace.endSection(TRACE_TAG_REACT);
1302-
}
1303-
1304-
private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactContext) {
1237+
private void detachRootViewFromInstance(ReactRoot reactRoot) {
13051238
FLog.d(ReactConstants.TAG, "ReactInstanceManager.detachRootViewFromInstance()");
13061239
UiThreadUtil.assertOnUiThread();
13071240

@@ -1310,27 +1243,6 @@ private void detachRootViewFromInstance(ReactRoot reactRoot, ReactContext reactC
13101243
return;
13111244
}
13121245

1313-
// Stop surface in Fabric.
1314-
// Calling FabricUIManager.stopSurface causes the C++ Binding.stopSurface
1315-
// to be called synchronously over the JNI, which causes an empty tree
1316-
// to be committed via the Scheduler, which will cause mounting instructions
1317-
// to be queued up and synchronously executed to delete and remove
1318-
// all the views in the hierarchy.
1319-
final int surfaceId = reactRoot.getRootViewTag();
1320-
if (surfaceId != View.NO_ID) {
1321-
UIManager uiManager = UIManagerHelper.getUIManager(reactContext, FABRIC);
1322-
if (uiManager != null) {
1323-
uiManager.stopSurface(surfaceId);
1324-
} else {
1325-
FLog.w(ReactConstants.TAG, "Failed to stop surface, UIManager has already gone away");
1326-
}
1327-
} else {
1328-
ReactSoftExceptionLogger.logSoftException(
1329-
TAG,
1330-
new RuntimeException(
1331-
"detachRootViewFromInstance called with ReactRootView with invalid id"));
1332-
}
1333-
13341246
clearReactRoot(reactRoot);
13351247
}
13361248

@@ -1344,7 +1256,7 @@ private void tearDownReactContext(ReactContext reactContext) {
13441256

13451257
synchronized (mAttachedReactRoots) {
13461258
for (ReactRoot reactRoot : mAttachedReactRoots) {
1347-
detachRootViewFromInstance(reactRoot, reactContext);
1259+
detachRootViewFromInstance(reactRoot);
13481260
}
13491261
}
13501262

‎packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/UIManager.kt‎

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,13 @@
88
package com.facebook.react.bridge
99

1010
import android.view.View
11-
import androidx.annotation.AnyThread
1211
import androidx.annotation.UiThread
1312
import com.facebook.infer.annotation.ThreadConfined
1413
import com.facebook.react.common.annotations.UnstableReactNativeAPI
1514
import com.facebook.react.uimanager.events.EventDispatcher
1615

1716
@OptIn(UnstableReactNativeAPI::class)
1817
public interface UIManager : PerformanceCounter {
19-
/**
20-
* Registers a new root view.
21-
*
22-
* @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead.
23-
*/
24-
@UiThread
25-
@ThreadConfined(ThreadConfined.UI)
26-
@Deprecated(
27-
"This legacy surface API will be removed in a future release. " +
28-
"Use ReactHost.createSurface(...) and ReactSurface.start() instead."
29-
)
30-
public fun <T : View> addRootView(rootView: T, initialProps: WritableMap?): Int
31-
32-
/**
33-
* Registers a new root view with width and height.
34-
*
35-
* @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead.
36-
*/
37-
@AnyThread
38-
@Deprecated(
39-
"This legacy surface API will be removed in a future release. " +
40-
"Use ReactHost.createSurface(...) and ReactSurface.start() instead."
41-
)
42-
public fun <T : View?> startSurface(
43-
rootView: T,
44-
moduleName: String,
45-
initialProps: WritableMap?,
46-
widthMeasureSpec: Int,
47-
heightMeasureSpec: Int,
48-
): Int
49-
50-
/**
51-
* Stop a surface from running in JS and clears up native memory usage. Assumes that the native
52-
* View hierarchy has already been cleaned up. Fabric-only.
53-
*
54-
* @deprecated Use `ReactSurface.stop()` instead.
55-
*/
56-
@AnyThread
57-
@Deprecated(
58-
"This legacy surface API will be removed in a future release. Use ReactSurface.stop() instead."
59-
)
60-
public fun stopSurface(surfaceId: Int)
61-
6218
/**
6319
* Updates the layout specs of the RootShadowNode based on the Measure specs received by
6420
* parameters. offsetX and offsetY are the position of the RootView within the screen.

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,6 @@ public FabricUIManager(
255255
mReactApplicationContext.registerComponentCallbacks(viewManagerRegistry);
256256
}
257257

258-
/**
259-
* @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead.
260-
*/
261-
@Override
262-
@UiThread
263-
@ThreadConfined(UI)
264-
@Deprecated
265-
public <T extends View> int addRootView(
266-
final T rootView, final @Nullable WritableMap initialProps) {
267-
throw new UnsupportedOperationException("FabricUIManager.addRootView is unsupported.");
268-
}
269-
270258
/**
271259
* Find the next focusable element's id and position relative to the parent from the shadow tree
272260
* based on the current focusable element and the direction.
@@ -319,23 +307,6 @@ public <T extends View> int addRootView(
319307
return mBinding != null ? mBinding.getRelativeAncestorList(rootTag, childTag) : null;
320308
}
321309

322-
/**
323-
* @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead.
324-
*/
325-
@Deprecated
326-
@Override
327-
@AnyThread
328-
@ThreadConfined(ANY)
329-
public <T extends View> int startSurface(
330-
final T rootView,
331-
final String moduleName,
332-
final @Nullable WritableMap initialProps,
333-
int widthMeasureSpec,
334-
int heightMeasureSpec) {
335-
throw new UnsupportedOperationException(
336-
"FabricUIManager.startSurface(View, ...) is unsupported.");
337-
}
338-
339310
public void startSurface(
340311
final SurfaceHandlerBinding surfaceHandler,
341312
final Context context,
@@ -384,17 +355,6 @@ public void onRequestEventBeat() {
384355
mEventDispatcher.dispatchAllEvents();
385356
}
386357

387-
/**
388-
* @deprecated Use {@code ReactSurface.stop()} instead.
389-
*/
390-
@Deprecated
391-
@AnyThread
392-
@ThreadConfined(ANY)
393-
@Override
394-
public void stopSurface(final int surfaceID) {
395-
throw new UnsupportedOperationException("FabricUIManager.stopSurface(int) is unsupported.");
396-
}
397-
398358
@Override
399359
public void initialize() {
400360
mEventDispatcher.addBatchEventDispatchedListener(mBatchEventDispatchedListener);

0 commit comments

Comments
 (0)