mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Initialise RuntimeScheduler before bundle is executed
Summary: Changelog: [internal] RuntimeScheduler can be accessed before any Fabric surface is rendered. Therefore, it needs to be created and installed in the runtime at the start up of the runtime. Reviewed By: JoshuaGross Differential Revision: D29091848 fbshipit-source-id: ff75ef8c4882550795e5d4a258355b651cb0e637
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8ca8f0cbe3
commit
d540f88df8
@@ -282,14 +282,16 @@ static BackgroundExecutor RCTGetBackgroundExecutor()
|
||||
toolbox.contextContainer = _contextContainer;
|
||||
toolbox.componentRegistryFactory = componentRegistryFactory;
|
||||
|
||||
if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:enable_runtimescheduler_ios")) {
|
||||
auto runtimeScheduler = std::make_shared<RuntimeScheduler>(_runtimeExecutor);
|
||||
runtimeScheduler->setEnableYielding(
|
||||
reactNativeConfig->getBool("react_native_new_architecture:runtimescheduler_enable_yielding_ios"));
|
||||
toolbox.runtimeScheduler = runtimeScheduler;
|
||||
runtimeExecutor = [runtimeScheduler](std::function<void(jsi::Runtime & runtime)> &&callback) {
|
||||
runtimeScheduler->scheduleWork(std::move(callback));
|
||||
};
|
||||
auto runtimeScheduler = _contextContainer->find<std::weak_ptr<RuntimeScheduler>>("RuntimeScheduler");
|
||||
if (runtimeScheduler.hasValue()) {
|
||||
auto lockedRuntimeScheduler = runtimeScheduler.value().lock();
|
||||
if (lockedRuntimeScheduler) {
|
||||
lockedRuntimeScheduler->setEnableYielding(
|
||||
reactNativeConfig->getBool("react_native_new_architecture:runtimescheduler_enable_yielding_ios"));
|
||||
runtimeExecutor = [lockedRuntimeScheduler](std::function<void(jsi::Runtime & runtime)> &&callback) {
|
||||
lockedRuntimeScheduler->scheduleWork(std::move(callback));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
toolbox.runtimeExecutor = runtimeExecutor;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <ReactCommon/RuntimeExecutor.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import <react/utils/ContextContainer.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -15,6 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@class RCTSurfacePresenter;
|
||||
@class RCTBridge;
|
||||
|
||||
facebook::react::RuntimeExecutor RCTRuntimeExecutorFromBridge(RCTBridge *bridge);
|
||||
|
||||
/*
|
||||
* Controls a life-cycle of a Surface Presenter based on Bridge's life-cycle.
|
||||
* We are moving away from using Bridge.
|
||||
|
||||
@@ -41,7 +41,7 @@ static ContextContainer::Shared RCTContextContainerFromBridge(RCTBridge *bridge)
|
||||
return contextContainer;
|
||||
}
|
||||
|
||||
static RuntimeExecutor RCTRuntimeExecutorFromBridge(RCTBridge *bridge)
|
||||
RuntimeExecutor RCTRuntimeExecutorFromBridge(RCTBridge *bridge)
|
||||
{
|
||||
RCTAssert(bridge, @"RCTRuntimeExecutorFromBridge: Bridge must not be nil.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user