Skip to content

Commit d77ccbe

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Remove enableBridgelessArchitecture branches from ReactAndroid simple call sites (#56999)
Summary: Second in a stack that collapses Android-side branches on `ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()` under the standing assumption that on Android the flag is always `true`. The underlying generated `ReactNativeFeatureFlags.enableBridgelessArchitecture()` is untouched. Scope of this commit — ReactAndroid simple call sites: - `DevSupportManagerBase` — drop the flag from the AND chain that gates `PerfMonitorOverlayManager` creation. - `HeadlessJsTaskService.reactContext` getter and `createReactContextAndScheduleTask` — keep the `reactHost` branches; drop the `reactInstanceManager` fallbacks. - `ViewManager.getNativeProps` — drop the flag from the AND with `UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE`. - `ReactImageView` — delete the `warnImageSource` helper and its two call sites. The helper existed only to emit a debug warning that was already gated off in bridgeless mode. - `ReactEditText.onConfigurationChanged` — drop the flag from the AND with `enableFontScaleChangesUpdatingLayout`. - `ReactHostImpl.getOrCreateStartTask` — drop the always-true debug assertion. - `DefaultNewArchitectureEntryPoint.loadWithFeatureFlags` — set `privateBridgelessEnabled = true` directly (was reading from the provider). - `ReactPackageTurboModuleManagerDelegate.shouldEnableLegacyModuleInterop` — drop the flag from the AND with `useTurboModuleInterop`. No public API surfaces change. `arc f` auto-removed the now-unused `ReactNativeNewArchitectureFeatureFlags` imports in the affected files. Subsequent diffs in the stack will handle: `ReactDelegate` + deprecated constructors + `reactNativeHost` field; wrapper method + lint detector. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D106719839
1 parent 6720760 commit d77ccbe

8 files changed

Lines changed: 16 additions & 73 deletions

File tree

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

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import android.os.PowerManager
1717
import android.os.PowerManager.WakeLock
1818
import com.facebook.react.bridge.ReactContext
1919
import com.facebook.react.bridge.UiThreadUtil
20-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
2120
import com.facebook.react.jstasks.HeadlessJsTaskConfig
2221
import com.facebook.react.jstasks.HeadlessJsTaskContext.Companion.getInstance
2322
import com.facebook.react.jstasks.HeadlessJsTaskEventListener
@@ -126,40 +125,21 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
126125

127126
protected val reactContext: ReactContext?
128127
get() {
129-
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()) {
130-
val reactHost =
131-
checkNotNull(reactHost) { "ReactHost is not initialized in New Architecture" }
132-
return reactHost.currentReactContext
133-
} else {
134-
val reactInstanceManager = reactNativeHost.reactInstanceManager
135-
return reactInstanceManager.currentReactContext
136-
}
128+
val reactHost = checkNotNull(reactHost) { "ReactHost is not initialized in New Architecture" }
129+
return reactHost.currentReactContext
137130
}
138131

139132
private fun createReactContextAndScheduleTask(taskConfig: HeadlessJsTaskConfig) {
140-
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()) {
141-
val reactHost = checkNotNull(reactHost)
142-
reactHost.addReactInstanceEventListener(
143-
object : ReactInstanceEventListener {
144-
override fun onReactContextInitialized(context: ReactContext) {
145-
invokeStartTask(context, taskConfig)
146-
reactHost.removeReactInstanceEventListener(this)
147-
}
148-
}
149-
)
150-
reactHost.start()
151-
} else {
152-
val reactInstanceManager = reactNativeHost.reactInstanceManager
153-
reactInstanceManager.addReactInstanceEventListener(
154-
object : ReactInstanceEventListener {
155-
override fun onReactContextInitialized(context: ReactContext) {
156-
invokeStartTask(context, taskConfig)
157-
reactInstanceManager.removeReactInstanceEventListener(this)
158-
}
133+
val reactHost = checkNotNull(reactHost)
134+
reactHost.addReactInstanceEventListener(
135+
object : ReactInstanceEventListener {
136+
override fun onReactContextInitialized(context: ReactContext) {
137+
invokeStartTask(context, taskConfig)
138+
reactHost.removeReactInstanceEventListener(this)
159139
}
160-
)
161-
reactInstanceManager.createReactContextInBackground()
162-
}
140+
}
141+
)
142+
reactHost.start()
163143
}
164144

165145
public companion object {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
2424
private val moduleProviders = mutableListOf<ModuleProvider>()
2525
private val packageModuleInfos = mutableMapOf<ModuleProvider, Map<String, ReactModuleInfo>>()
2626
private val shouldEnableLegacyModuleInterop =
27-
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
28-
ReactNativeNewArchitectureFeatureFlags.useTurboModuleInterop()
27+
ReactNativeNewArchitectureFeatureFlags.useTurboModuleInterop()
2928

3029
protected constructor(
3130
reactApplicationContext: ReactApplicationContext,

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public object DefaultNewArchitectureEntryPoint {
113113
ReactNativeFeatureFlags.override(featureFlags)
114114

115115
privateTurboModulesEnabled = true
116-
privateBridgelessEnabled = featureFlags.enableBridgelessArchitecture()
116+
privateBridgelessEnabled = true
117117

118118
val (isValid, errorMessage) =
119119
isConfigurationValid(

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ import com.facebook.react.devsupport.interfaces.StackFrame
7171
import com.facebook.react.devsupport.perfmonitor.PerfMonitorDevHelper
7272
import com.facebook.react.devsupport.perfmonitor.PerfMonitorOverlayManager
7373
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
74-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
7574
import com.facebook.react.modules.core.RCTNativeAppEventEmitter
7675
import com.facebook.react.modules.debug.interfaces.DeveloperSettings
7776
import com.facebook.react.packagerconnection.RequestHandler
@@ -243,8 +242,7 @@ public abstract class DevSupportManagerBase(
243242
)
244243
}
245244
if (
246-
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
247-
ReactNativeFeatureFlags.perfMonitorV2Enabled() &&
245+
ReactNativeFeatureFlags.perfMonitorV2Enabled() &&
248246
reactInstanceDevHelper is PerfMonitorDevHelper
249247
) {
250248
perfMonitorOverlayManager =

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,12 +851,6 @@ public class ReactHostImpl(
851851
}
852852

853853
stateTracker.enterState("getOrCreateStartTask()", "Schedule")
854-
if (ReactBuildConfig.DEBUG) {
855-
Assertions.assertCondition(
856-
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture(),
857-
"enableBridgelessArchitecture FeatureFlag must be set to start ReactNative.",
858-
)
859-
}
860854
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
861855
Assertions.assertCondition(
862856
!ReactNativeNewArchitectureFeatureFlags.useFabricInterop(),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.facebook.react.common.build.ReactBuildConfig;
2424
import com.facebook.react.common.mapbuffer.MapBuffer;
2525
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags;
26-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
2726
import com.facebook.react.touch.JSResponderHandler;
2827
import com.facebook.react.touch.ReactInterceptingViewGroup;
2928
import com.facebook.react.uimanager.annotations.ReactProp;
@@ -406,8 +405,7 @@ public void receiveCommand(@NonNull T view, String commandId, ReadableArray args
406405
* Map contains the names (key) and types (value) of the ViewManager's props.
407406
*/
408407
public Map<String, String> getNativeProps() {
409-
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE
410-
&& ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()) {
408+
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
411409
// TODO: review if we need to check fabricInterop here
412410
return ViewManagerPropertyUpdater.getNativeProps(getClass(), null);
413411
} else {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/image/ReactImageView.kt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ import com.facebook.react.bridge.ReadableArray
4949
import com.facebook.react.bridge.ReadableMap
5050
import com.facebook.react.common.annotations.UnstableReactNativeAPI
5151
import com.facebook.react.common.annotations.VisibleForTesting
52-
import com.facebook.react.common.build.ReactBuildConfig
53-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
5452
import com.facebook.react.modules.fresco.ImageCacheControl
5553
import com.facebook.react.modules.fresco.ReactNetworkImageRequest
5654
import com.facebook.react.uimanager.BackgroundStyleApplicator
@@ -61,7 +59,6 @@ import com.facebook.react.uimanager.PixelUtil.pxToDp
6159
import com.facebook.react.uimanager.UIManagerHelper
6260
import com.facebook.react.uimanager.style.BorderRadiusProp
6361
import com.facebook.react.uimanager.style.LogicalEdge
64-
import com.facebook.react.util.RNLog
6562
import com.facebook.react.views.image.ImageLoadEvent.Companion.createErrorEvent
6663
import com.facebook.react.views.image.ImageLoadEvent.Companion.createLoadEndEvent
6764
import com.facebook.react.views.image.ImageLoadEvent.Companion.createLoadEvent
@@ -282,7 +279,6 @@ public class ReactImageView(
282279
val cacheControl = computeCacheControl(source.getString("cache"))
283280
var imageSource = ImageSource(context, source.getString("uri"), cacheControl = cacheControl)
284281
if (Uri.EMPTY == imageSource.uri) {
285-
warnImageSource(source.getString("uri"))
286282
imageSource = getTransparentBitmapImageSource(context)
287283
}
288284
tmpSources.add(imageSource)
@@ -299,7 +295,6 @@ public class ReactImageView(
299295
cacheControl,
300296
)
301297
if (Uri.EMPTY == imageSource.uri) {
302-
warnImageSource(source.getString("uri"))
303298
imageSource = getTransparentBitmapImageSource(context)
304299
}
305300
tmpSources.add(imageSource)
@@ -589,23 +584,6 @@ public class ReactImageView(
589584
return ResizeOptions(width, height)
590585
}
591586

592-
private fun warnImageSource(uri: String?) {
593-
// TODO(T189014077): This code-path produces an infinite loop of js calls with logbox.
594-
// This is an issue with Fabric view preallocation, react, and LogBox. Fix.
595-
// The bug:
596-
// 1. An app renders an <Image/>
597-
// 2. Fabric preallocates <Image/>; sets a null src to ReactImageView (potential problem?).
598-
// 3. ReactImageView detects the null src; displays a warning in LogBox (via this code).
599-
// 3. LogBox renders an <Image/>, which fabric preallocates.
600-
// 4. Rinse and repeat.
601-
if (
602-
ReactBuildConfig.DEBUG &&
603-
!ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture()
604-
) {
605-
RNLog.w(context as ReactContext, "ReactImageView: Image source \"$uri\" doesn't exist")
606-
}
607-
}
608-
609587
private inner class TilePostprocessor : BasePostprocessor() {
610588
override fun process(
611589
source: Bitmap,

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import com.facebook.react.bridge.ReactSoftExceptionLogger.logSoftException
4747
import com.facebook.react.common.ReactConstants
4848
import com.facebook.react.common.build.ReactBuildConfig
4949
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
50-
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags
5150
import com.facebook.react.uimanager.BackgroundStyleApplicator.clipToPaddingBox
5251
import com.facebook.react.uimanager.BackgroundStyleApplicator.getBackgroundColor
5352
import com.facebook.react.uimanager.BackgroundStyleApplicator.getBorderColor
@@ -915,10 +914,7 @@ public open class ReactEditText public constructor(context: Context) : AppCompat
915914
public override fun onConfigurationChanged(newConfig: Configuration) {
916915
super.onConfigurationChanged(newConfig)
917916

918-
if (
919-
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
920-
ReactNativeFeatureFlags.enableFontScaleChangesUpdatingLayout()
921-
) {
917+
if (ReactNativeFeatureFlags.enableFontScaleChangesUpdatingLayout()) {
922918
applyTextAttributes()
923919
}
924920
}

0 commit comments

Comments
 (0)