Skip to content

Commit d4d0813

Browse files
javachemeta-codesync[bot]
authored andcommitted
Deprecate legacy Android UIManager surface APIs (#59039)
Summary: Pull Request resolved: #59039 The View-based `UIManager` lifecycle predates `ReactHost` and `ReactSurface` and is no longer used by the supported architecture. Deprecate these methods before their planned removal and point callers to `ReactHost.createSurface(...)` and `ReactSurface.start()` or `stop()`. Changelog: [Android][Deprecated] - Deprecate the legacy View-based surface lifecycle methods in `UIManager`. Reviewed By: christophpurrer Differential Revision: D124990160 fbshipit-source-id: a68d2b630aa12910b141430772903c22da147a03
1 parent 2560f7c commit d4d0813

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,29 @@ import com.facebook.react.uimanager.events.EventDispatcher
1616

1717
@OptIn(UnstableReactNativeAPI::class)
1818
public interface UIManager : PerformanceCounter {
19-
/** Registers a new root view. @Deprecated call startSurface instead */
19+
/**
20+
* Registers a new root view.
21+
*
22+
* @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead.
23+
*/
2024
@UiThread
2125
@ThreadConfined(ThreadConfined.UI)
22-
@Deprecated("")
26+
@Deprecated(
27+
"This legacy surface API will be removed in a future release. " +
28+
"Use ReactHost.createSurface(...) and ReactSurface.start() instead."
29+
)
2330
public fun <T : View> addRootView(rootView: T, initialProps: WritableMap?): Int
2431

25-
/** Registers a new root view with width and height. */
32+
/**
33+
* Registers a new root view with width and height.
34+
*
35+
* @deprecated Use `ReactHost.createSurface(...)` and `ReactSurface.start()` instead.
36+
*/
2637
@AnyThread
38+
@Deprecated(
39+
"This legacy surface API will be removed in a future release. " +
40+
"Use ReactHost.createSurface(...) and ReactSurface.start() instead."
41+
)
2742
public fun <T : View?> startSurface(
2843
rootView: T,
2944
moduleName: String,
@@ -35,8 +50,14 @@ public interface UIManager : PerformanceCounter {
3550
/**
3651
* Stop a surface from running in JS and clears up native memory usage. Assumes that the native
3752
* View hierarchy has already been cleaned up. Fabric-only.
53+
*
54+
* @deprecated Use `ReactSurface.stop()` instead.
3855
*/
39-
@AnyThread public fun stopSurface(surfaceId: Int)
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)
4061

4162
/**
4263
* Updates the layout specs of the RootShadowNode based on the Measure specs received by

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ public FabricUIManager(
262262
mReactApplicationContext.registerComponentCallbacks(viewManagerRegistry);
263263
}
264264

265+
/**
266+
* @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead.
267+
*/
265268
@Override
266269
@UiThread
267270
@ThreadConfined(UI)
@@ -271,7 +274,8 @@ public <T extends View> int addRootView(
271274
ReactSoftExceptionLogger.logSoftException(
272275
TAG,
273276
new IllegalViewOperationException(
274-
"Do not call addRootView in Fabric; it is unsupported. Call startSurface instead."));
277+
"Do not call addRootView in Fabric; it is unsupported. Use ReactHost.createSurface(...)"
278+
+ " and ReactSurface.start() instead."));
275279

276280
ReactRoot reactRootView = (ReactRoot) rootView;
277281
final int rootTag = reactRootView.getRootViewTag();
@@ -341,6 +345,10 @@ public <T extends View> int addRootView(
341345
return mBinding != null ? mBinding.getRelativeAncestorList(rootTag, childTag) : null;
342346
}
343347

348+
/**
349+
* @deprecated Use {@code ReactHost.createSurface(...)} and {@code ReactSurface.start()} instead.
350+
*/
351+
@Deprecated
344352
@Override
345353
@AnyThread
346354
@ThreadConfined(ANY)
@@ -430,6 +438,10 @@ public void onRequestEventBeat() {
430438
mEventDispatcher.dispatchAllEvents();
431439
}
432440

441+
/**
442+
* @deprecated Use {@code ReactSurface.stop()} instead.
443+
*/
444+
@Deprecated
433445
@AnyThread
434446
@ThreadConfined(ANY)
435447
@Override

‎packages/react-native/ReactAndroid/src/test/java/com/facebook/testutils/fakes/FakeUIManager.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class FakeUIManager : UIManager, UIBlockViewResolver {
3434
error("Not yet implemented")
3535
}
3636

37+
@Deprecated("")
3738
override fun <T : View?> startSurface(
3839
rootView: T,
3940
moduleName: String,
@@ -44,6 +45,7 @@ class FakeUIManager : UIManager, UIBlockViewResolver {
4445
error("Not yet implemented")
4546
}
4647

48+
@Deprecated("")
4749
override fun stopSurface(surfaceId: Int) {
4850
error("Not yet implemented")
4951
}

0 commit comments

Comments
 (0)