Skip to content

Commit

Permalink
Enable event loop by default when bridgeless is enabled (facebook#43396)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#43396

Changelog: [General][Changed] Enabled new event loop behavior when bridgeless (new architecture) is enabled.

Reviewed By: rshest

Differential Revision: D54682678

fbshipit-source-id: ff8c45bc1caae0e9182aa94d915d7b6f9427caf9
  • Loading branch information
rubennorte authored and facebook-github-bot committed Mar 18, 2024
1 parent a1c752c commit 87b73a0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <React/RCTUtils.h>
#import <objc/runtime.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
#import <react/renderer/graphics/ColorComponents.h>
#import "RCTAppDelegate+Protected.h"
#import "RCTAppSetupUtils.h"
Expand All @@ -38,6 +40,8 @@ @implementation RCTAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self _setUpFeatureFlags];

RCTSetNewArchEnabled([self newArchEnabled]);
[RCTColorSpaceUtils applyDefaultColorSpace:self.defaultColorSpace];
RCTAppSetupPrepareApp(application, self.turboModuleEnabled);
Expand Down Expand Up @@ -259,4 +263,29 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
return [[RCTRootViewFactory alloc] initWithConfiguration:configuration andTurboModuleManagerDelegate:self];
}

#pragma mark - Feature Flags

class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
public:
bool useModernRuntimeScheduler() override
{
return true;
}
bool enableMicrotasks() override
{
return true;
}
bool batchRenderingUpdatesInEventLoop() override
{
return true;
}
};

- (void)_setUpFeatureFlags
{
if ([self bridgelessEnabled]) {
facebook::react::ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
}
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Pod::Spec.new do |s|
add_dependency(s, "React-utils")
add_dependency(s, "React-debug")
add_dependency(s, "React-rendererdebug")
add_dependency(s, "React-featureflags")

if use_hermes
s.dependency "React-hermes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package com.facebook.react.defaults

import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.config.ReactFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults

/**
* A utility class that serves as an entry point for users setup the New Architecture.
Expand Down Expand Up @@ -45,6 +47,17 @@ public object DefaultNewArchitectureEntryPoint {
ReactFeatureFlags.unstable_useTurboModuleInterop = bridgelessEnabled
ReactFeatureFlags.enableFabricPendingEventQueue = fabricEnabled

if (bridgelessEnabled) {
ReactNativeFeatureFlags.override(
object : ReactNativeFeatureFlagsDefaults() {
override fun useModernRuntimeScheduler(): Boolean = true

override fun enableMicrotasks(): Boolean = true

override fun batchRenderingUpdatesInEventLoop(): Boolean = true
})
}

privateFabricEnabled = fabricEnabled
privateTurboModulesEnabled = turboModulesEnabled
privateConcurrentReactEnabled = fabricEnabled
Expand Down

0 comments on commit 87b73a0

Please sign in to comment.