From 2deede0551794f53cae50d3a064ac009bb8de266 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Tue, 11 Jun 2024 04:11:40 -0700 Subject: [PATCH] Expose unstable_fuseboxEnabled API on iOS (#44860) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44860 - Enables an opt-in to the Fusebox stack on iOS for both architectures in open source. - Templates use of this opt-in in RNTester. Changelog: [Internal] Reviewed By: rubennorte Differential Revision: D58364053 --- .../Libraries/AppDelegate/RCTAppDelegate.h | 3 ++ .../Libraries/AppDelegate/RCTAppDelegate.mm | 31 +++++++++++++++++-- packages/rn-tester/RNTester/AppDelegate.mm | 8 +++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h index 741dfa92f7fc..51ce13d83219 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h @@ -160,6 +160,9 @@ NS_ASSUME_NONNULL_BEGIN /// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`. - (BOOL)bridgelessEnabled; +/// Controls whether the new debugger stack (codename Fusebox) is enabled. +- (BOOL)unstable_fuseboxEnabled; + /// Return the bundle URL for the main bundle. - (NSURL *__nullable)bundleURL; diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index 1e87756cad8c..d3f77eca50f4 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -151,6 +151,11 @@ - (BOOL)bridgelessEnabled return [self newArchEnabled]; } +- (BOOL)unstable_fuseboxEnabled +{ + return [self unstable_fuseboxEnabled]; +} + - (NSURL *)bundleURL { [NSException raise:@"RCTAppDelegate::bundleURL not implemented" @@ -300,8 +305,26 @@ - (RCTRootViewFactory *)createRCTRootViewFactory #pragma mark - Feature Flags -class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults { +class RCTAppDelegateFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults { public: + RCTAppDelegateFeatureFlags(bool fuseboxEnabled) + { + fuseboxEnabled_ = fuseboxEnabled; + } + + bool fuseboxEnabledDebug() override + { + return fuseboxEnabled_; + } + + private: + bool fuseboxEnabled_; +}; + +class RCTAppDelegateBridgelessFeatureFlags : public RCTAppDelegateFeatureFlags { + public: + RCTAppDelegateBridgelessFeatureFlags(bool fuseboxEnabled) : RCTAppDelegateFeatureFlags(fuseboxEnabled) {} + bool useModernRuntimeScheduler() override { return true; @@ -319,7 +342,11 @@ bool batchRenderingUpdatesInEventLoop() override - (void)_setUpFeatureFlags { if ([self bridgelessEnabled]) { - facebook::react::ReactNativeFeatureFlags::override(std::make_unique()); + facebook::react::ReactNativeFeatureFlags::override( + std::make_unique([self unstable_fuseboxEnabled])); + } else { + facebook::react::ReactNativeFeatureFlags::override( + std::make_unique([self unstable_fuseboxEnabled])); } } diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index eacc13101b2c..d61c9ab68517 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -144,6 +144,14 @@ - (BOOL)bridgelessEnabled return [super bridgelessEnabled]; } +#pragma mark - Experimental settings + +// [Experiment] Enable the new debugger stack (codename Fusebox) +- (BOOL)unstable_fuseboxEnabled +{ + return false; +} + #pragma mark - RCTComponentViewFactoryComponentProvider #ifndef RN_DISABLE_OSS_PLUGIN_HEADER