Skip to content

Commit

Permalink
Expose unstable_loadFusebox API on Android (#44858)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44858

- Enables an opt-in to the Fusebox stack on Android for both architectures in open source.
- Templates use of this opt-in in RNTester.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D58359907
  • Loading branch information
huntie authored and facebook-github-bot committed Jun 10, 2024
1 parent fdb2427 commit 311fdfd
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1995,6 +1995,7 @@ public final class com/facebook/react/defaults/DefaultNewArchitectureEntryPoint
public static final fun load (ZZ)V
public static final fun load (ZZZ)V
public static synthetic fun load$default (ZZZILjava/lang/Object;)V
public static final fun unstable_loadFusebox (Z)V
}

public class com/facebook/react/defaults/DefaultReactActivityDelegate : com/facebook/react/ReactActivityDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public object DefaultNewArchitectureEntryPoint {
override fun batchRenderingUpdatesInEventLoop(): Boolean = true

override fun useNativeViewConfigsInBridgelessMode(): Boolean = true

// We need to assign this now as we can't call ReactNativeFeatureFlags.override()
// more than once.
override fun fuseboxEnabledDebug(): Boolean = isFuseboxEnabled
})
}

Expand All @@ -67,21 +71,25 @@ public object DefaultNewArchitectureEntryPoint {
}

private var privateFabricEnabled: Boolean = false

@JvmStatic
public val fabricEnabled: Boolean
get() = privateFabricEnabled

private var privateTurboModulesEnabled: Boolean = false

@JvmStatic
public val turboModulesEnabled: Boolean
get() = privateTurboModulesEnabled

private var privateConcurrentReactEnabled: Boolean = false

@JvmStatic
public val concurrentReactEnabled: Boolean
get() = privateConcurrentReactEnabled

private var privateBridgelessEnabled: Boolean = false

@JvmStatic
public val bridgelessEnabled: Boolean
get() = privateBridgelessEnabled
Expand All @@ -101,4 +109,29 @@ public object DefaultNewArchitectureEntryPoint {
"bridgelessEnabled=true requires (turboModulesEnabled=true AND fabricEnabled=true) - Please update your DefaultNewArchitectureEntryPoint.load() parameters."
else -> true to ""
}

/**
* If called, enables the new debugger stack (codename Fusebox). Must be called before
* {@link #load()}.
*
* @param isNewArchEnabled Please pass {@code BuildConfig.IS_NEW_ARCH_ENABLED} here.
*/
@JvmStatic
public fun unstable_loadFusebox(
isNewArchEnabled: Boolean,
) {
isFuseboxEnabled = true

if (!isNewArchEnabled) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun fuseboxEnabledDebug(): Boolean = true
})
} else {
// no-op as this will be taken care of inside load() instead
}
}

/** Set to {@code true} if {@link #unstable_loadFusebox()} was called. */
private var isFuseboxEnabled: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ class RNTesterApplication : Application(), ReactApplication {
ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik)
super.onCreate()
SoLoader.init(this, /* native exopackage */ false)

// [Experiment] Enable the new debugger stack (codename Fusebox)
// unstable_loadFusebox(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED)

if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
load()
}
Expand Down

0 comments on commit 311fdfd

Please sign in to comment.