Skip to content

Commit

Permalink
Enable event loop by default when bridgeless is enabled (#43396)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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 cipolleschi committed Apr 30, 2024
1 parent 261a587 commit b440672
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
#import <React/RCTRootView.h>
#import <React/RCTSurfacePresenterBridgeAdapter.h>
#import <React/RCTUtils.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.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"

#if RN_DISABLE_OSS_PLUGIN_HEADER
Expand Down Expand Up @@ -46,6 +50,8 @@ @implementation RCTAppDelegate

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

RCTSetNewArchEnabled([self newArchEnabled]);
RCTAppSetupPrepareApp(application, self.turboModuleEnabled);

Expand Down Expand Up @@ -258,4 +264,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 @@ -89,6 +89,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 b440672

Please sign in to comment.