Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose unstable_loadFusebox API on Android #44858

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1994,6 +1994,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 @@ -9,6 +9,7 @@

package com.facebook.react.defaults

import com.facebook.infer.annotation.Assertions
import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
Expand Down Expand Up @@ -44,6 +45,7 @@ public object DefaultNewArchitectureEntryPoint {
ReactFeatureFlags.unstable_useFabricInterop = fabricEnabled
ReactFeatureFlags.enableBridgelessArchitecture = bridgelessEnabled
ReactFeatureFlags.unstable_useTurboModuleInterop = bridgelessEnabled
val fuseboxEnabledDebug = fuseboxEnabled

if (bridgelessEnabled) {
ReactNativeFeatureFlags.override(
Expand All @@ -55,6 +57,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 = fuseboxEnabledDebug
})
}

Expand All @@ -64,24 +70,29 @@ public object DefaultNewArchitectureEntryPoint {
privateBridgelessEnabled = bridgelessEnabled

DefaultSoLoader.maybeLoadSoLibrary()
loaded = true
}

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 +112,41 @@ public object DefaultNewArchitectureEntryPoint {
"bridgelessEnabled=true requires (turboModulesEnabled=true AND fabricEnabled=true) - Please update your DefaultNewArchitectureEntryPoint.load() parameters."
else -> true to ""
}

// region unstable_loadFusebox (short-lived API for testing Fusebox - EXPERIMENTAL)

/**
* Set to {@code true} when {@link #load()} is called. Used for assertion in
* {@link #unstable_loadFusebox()}.
*/
private var loaded: Boolean = false

/** Set to {@code true} if {@link #unstable_loadFusebox()} was called. */
private var fuseboxEnabled: Boolean = false

/**
* 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,
) {
fuseboxEnabled = true

if (!isNewArchEnabled) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun fuseboxEnabledDebug(): Boolean = true
})
} else {
Assertions.assertCondition(
loaded == false, "unstable_loadFusebox() must be called before load()")
}
}

// endregion

}
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
Loading