From 13da82a337826ac30fd2d4b581d963f5b872381b Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 25 Nov 2025 10:32:59 -0800 Subject: [PATCH] Remove unnecessary BridgeDevSupportManager (#54683) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/54683 This class is no longer needed and can be removed. This is a breaking change, but the class was long deprecated so we should be fine removing it. Changelog: [Android] [Removed] - Remove unnecessary and unused BridgeDevSupportManager Reviewed By: javache Differential Revision: D87859861 fbshipit-source-id: f77d7121ace072b2c37408b0d81d84309692e05a --- .../ReactAndroid/api/ReactAndroid.api | 5 - .../devsupport/BridgeDevSupportManager.kt | 105 ------------------ .../devsupport/BridgelessDevSupportManager.kt | 5 +- .../DefaultDevSupportManagerFactory.kt | 70 ++---------- .../devsupport/DevSupportManagerFactory.kt | 5 +- .../interfaces/DevSupportManager.kt | 4 +- .../devsupport/interfaces/RedBoxHandler.kt | 4 +- 7 files changed, 17 insertions(+), 181 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 67cc51aac3f..1c989b8cce9 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1833,11 +1833,6 @@ public final class com/facebook/react/defaults/DefaultTurboModuleManagerDelegate public synthetic fun build (Lcom/facebook/react/bridge/ReactApplicationContext;Ljava/util/List;)Lcom/facebook/react/ReactPackageTurboModuleManagerDelegate; } -public final class com/facebook/react/devsupport/BridgeDevSupportManager : com/facebook/react/devsupport/DevSupportManagerBase { - public fun (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)V - public fun handleReloadJS ()V -} - public final class com/facebook/react/devsupport/BundleDownloader { public static final field Companion Lcom/facebook/react/devsupport/BundleDownloader$Companion; public fun (Lokhttp3/OkHttpClient;)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.kt deleted file mode 100644 index e63ec897678..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.devsupport - -import android.content.Context -import com.facebook.debug.holder.PrinterHolder.printer -import com.facebook.debug.tags.ReactDebugOverlayTags -import com.facebook.infer.annotation.Assertions -import com.facebook.react.bridge.ReactMarker -import com.facebook.react.bridge.ReactMarkerConstants -import com.facebook.react.bridge.UiThreadUtil -import com.facebook.react.common.SurfaceDelegateFactory -import com.facebook.react.common.annotations.internal.LegacyArchitecture -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel -import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger.assertLegacyArchitecture -import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener -import com.facebook.react.devsupport.interfaces.DevLoadingViewManager -import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager -import com.facebook.react.devsupport.interfaces.RedBoxHandler -import com.facebook.react.packagerconnection.RequestHandler - -/** - * Interface for accessing and interacting with development features. Following features are - * supported through this manager class: - * 1) Displaying JS errors (aka RedBox) - * 2) Displaying developers menu (Reload JS, Debug JS) - * 3) Communication with developer server in order to download updated JS bundle - * 4) Starting/stopping broadcast receiver for js reload signals - * 5) Starting/stopping motion sensor listener that recognize shake gestures which in turn may - * trigger developers menu. - * 6) Launching developers settings view - * - * This class automatically monitors the state of registered views and activities to which they are - * bound to make sure that we don't display overlay or that we we don't listen for sensor events - * when app is backgrounded. - * - * [com.facebook.react.ReactInstanceManager] implementation is responsible for instantiating this - * class as well as for populating with a reference to [com.facebook.react.bridge.CatalystInstance] - * whenever instance manager recreates it (through [onNewReactContextCreated]). Also, instance - * manager is responsible for enabling/disabling dev support in case when app is backgrounded or - * when all the views has been detached from the instance (through `setDevSupportEnabled` method). - */ -@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) -@Deprecated( - message = "This class is part of Legacy Architecture and will be removed in a future release", - level = DeprecationLevel.WARNING, -) -public class BridgeDevSupportManager( - applicationContext: Context, - reactInstanceManagerHelper: ReactInstanceDevHelper, - packagerPathForJSBundleName: String?, - enableOnCreate: Boolean, - redBoxHandler: RedBoxHandler?, - devBundleDownloadListener: DevBundleDownloadListener?, - minNumShakes: Int, - customPackagerCommandHandlers: Map?, - surfaceDelegateFactory: SurfaceDelegateFactory?, - devLoadingViewManager: DevLoadingViewManager?, - pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?, -) : - DevSupportManagerBase( - applicationContext, - reactInstanceManagerHelper, - packagerPathForJSBundleName, - enableOnCreate, - redBoxHandler, - devBundleDownloadListener, - minNumShakes, - customPackagerCommandHandlers, - surfaceDelegateFactory, - devLoadingViewManager, - pausedInDebuggerOverlayManager, - ) { - - override val uniqueTag: String - get() = "Bridge" - - override fun handleReloadJS() { - UiThreadUtil.assertOnUiThread() - ReactMarker.logMarker( - ReactMarkerConstants.RELOAD, - devSettings.packagerConnectionSettings.debugServerHost, - ) - - // dismiss redbox if exists - hideRedboxDialog() - - printer.logMessage(ReactDebugOverlayTags.RN_CORE, "RNCore: load from Server") - val bundleURL = devServerHelper.getDevServerBundleURL(Assertions.assertNotNull(jsAppBundleName)) - reloadJSFromServer(bundleURL) { - UiThreadUtil.runOnUiThread { reactInstanceDevHelper.onJSBundleLoadedFromServer() } - } - } - - private companion object { - init { - assertLegacyArchitecture("BridgeDevSupportManager", LegacyArchitectureLogLevel.ERROR) - } - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt index 9679ea67c2f..06aeeea9fc3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgelessDevSupportManager.kt @@ -23,9 +23,8 @@ import com.facebook.react.packagerconnection.RequestHandler * [DevSupportManagerBase] with some additional, more flexible APIs for asynchronously loading the * JS bundle. * - * @constructor The primary constructor mirrors the same constructor we have for - * [BridgeDevSupportManager] and - * * is kept for backward compatibility. + * @constructor The primary constructor mirrors the same constructor we had for + * `BridgeDevSupportManager` and is kept for backward compatibility. */ internal class BridgelessDevSupportManager( applicationContext: Context, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt index ad2e4f3ed43..353e3f9a7eb 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt @@ -18,10 +18,10 @@ import com.facebook.react.devsupport.interfaces.RedBoxHandler import com.facebook.react.packagerconnection.RequestHandler /** - * A simple factory that creates instances of [DevSupportManager] implementations. Uses reflection - * to create BridgeDevSupportManager if it exists. This allows ProGuard to strip that class and its - * dependencies in release builds. If the class isn't found, [PerftestDevSupportManager] is returned - * instead. + * A simple factory that creates instances of [DevSupportManager] implementations. + * + * The first create() method is for the Old Architecture flow and is deprecated and should not be + * used anymore. The second create() method is for the New Architecture/Bridgeless flow. */ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory { @@ -44,57 +44,12 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory { surfaceDelegateFactory: SurfaceDelegateFactory?, devLoadingViewManager: DevLoadingViewManager?, pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?, - ): DevSupportManager { - return if (!enableOnCreate) { - ReleaseDevSupportManager() - } else - try { - // Developer support is enabled, we now must choose whether to return a DevSupportManager, - // or a more lean profiling-only PerftestDevSupportManager. We make the choice by first - // trying to return the full support DevSupportManager and if it fails, then just - // return PerftestDevSupportManager. - - // ProGuard is surprisingly smart in this case and will keep a class if it detects a call - // to - // Class.forName() with a static string. So instead we generate a quasi-dynamic string to - // confuse it. - val className = - StringBuilder(DEVSUPPORT_IMPL_PACKAGE) - .append(".") - .append(DEVSUPPORT_IMPL_CLASS) - .toString() - val devSupportManagerClass = Class.forName(className) - val constructor = - devSupportManagerClass.getConstructor( - Context::class.java, - ReactInstanceDevHelper::class.java, - String::class.java, - Boolean::class.javaPrimitiveType, - RedBoxHandler::class.java, - DevBundleDownloadListener::class.java, - Int::class.javaPrimitiveType, - MutableMap::class.java, - SurfaceDelegateFactory::class.java, - DevLoadingViewManager::class.java, - PausedInDebuggerOverlayManager::class.java, - ) - constructor.newInstance( - applicationContext, - reactInstanceManagerHelper, - packagerPathForJSBundleName, - true, - redBoxHandler, - devBundleDownloadListener, - minNumShakes, - customPackagerCommandHandlers, - surfaceDelegateFactory, - devLoadingViewManager, - pausedInDebuggerOverlayManager, - ) as DevSupportManager - } catch (e: Exception) { - PerftestDevSupportManager(applicationContext) - } - } + ): DevSupportManager = + if (!enableOnCreate) { + ReleaseDevSupportManager() + } else { + PerftestDevSupportManager(applicationContext) + } override fun create( applicationContext: Context, @@ -129,9 +84,4 @@ internal class DefaultDevSupportManagerFactory : DevSupportManagerFactory { } else { ReleaseDevSupportManager() } - - private companion object { - private const val DEVSUPPORT_IMPL_PACKAGE = "com.facebook.react.devsupport" - private const val DEVSUPPORT_IMPL_CLASS = "BridgeDevSupportManager" - } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt index 9bc293477a9..7210d90a4c8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerFactory.kt @@ -18,10 +18,7 @@ import com.facebook.react.packagerconnection.RequestHandler public interface DevSupportManagerFactory { - /** - * Factory used by the Old Architecture flow to create a [DevSupportManager] and a - * [BridgeDevSupportManager] - */ + /** Factory used by the Old Architecture flow to create a [DevSupportManager]. */ @Deprecated( message = "Use the other create() method with useDevSupport parameter for New Architecture. This method will be removed in a future release.", diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevSupportManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevSupportManager.kt index f48122aeb9e..1851a821f9c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevSupportManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/DevSupportManager.kt @@ -19,8 +19,8 @@ import java.io.File /** * Interface for accessing and interacting with development features. In dev mode, use the - * implementation [com.facebook.react.devsupport.BridgeDevSupportManager]. In production mode, use - * the dummy implementation [com.facebook.react.devsupport.ReleaseDevSupportManager]. + * implementation [com.facebook.react.devsupport.BridgelessDevSupportManager]. In production mode, + * use the dummy implementation [com.facebook.react.devsupport.ReleaseDevSupportManager]. */ public interface DevSupportManager : JSExceptionHandler { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/RedBoxHandler.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/RedBoxHandler.kt index 50f707fb833..13fb6a52fd0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/RedBoxHandler.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/interfaces/RedBoxHandler.kt @@ -11,8 +11,8 @@ import android.content.Context import android.text.SpannedString /** - * Interface used by [com.facebook.react.devsupport.BridgeDevSupportManager] to allow interception - * on any redboxes during development and handling the information from the redbox. The + * Interface used by [com.facebook.react.devsupport.interfaces.DevSupportManager] to allow + * interception on any redboxes during development and handling the information from the redbox. The * implementation should be passed by setRedBoxHandler in ReactInstanceManager. */ public interface RedBoxHandler {