File tree Expand file tree Collapse file tree 6 files changed +22
-3
lines changed
ReactAndroid/src/main/jni/react/fabric
ReactCommon/react/renderer/scheduler Expand file tree Collapse file tree 6 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
28
28
@interface RCTSurfacePresenter : NSObject
29
29
30
30
- (instancetype )initWithContextContainer : (facebook::react::ContextContainer::Shared)contextContainer
31
- runtimeExecutor : (facebook::react::RuntimeExecutor)runtimeExecutor ;
31
+ runtimeExecutor : (facebook::react::RuntimeExecutor)runtimeExecutor
32
+ bindingsInstallExecutor : (facebook::react::RuntimeExecutor)bindingsInstallExecutor ;
32
33
33
34
@property (nonatomic ) facebook::react::ContextContainer::Shared contextContainer;
34
35
@property (nonatomic ) facebook::react::RuntimeExecutor runtimeExecutor;
Original file line number Diff line number Diff line change @@ -79,17 +79,20 @@ @implementation RCTSurfacePresenter {
79
79
RCTScheduler *_Nullable _scheduler; // Thread-safe. Pointer is protected by `_schedulerAccessMutex`.
80
80
ContextContainer::Shared _contextContainer; // Protected by `_schedulerLifeCycleMutex`.
81
81
RuntimeExecutor _runtimeExecutor; // Protected by `_schedulerLifeCycleMutex`.
82
+ RuntimeExecutor _bindingsInstallExecutor; // Only used for installing bindings.
82
83
83
84
butter::shared_mutex _observerListMutex;
84
85
std::vector<__weak id <RCTSurfacePresenterObserver>> _observers; // Protected by `_observerListMutex`.
85
86
}
86
87
87
88
- (instancetype )initWithContextContainer : (ContextContainer::Shared)contextContainer
88
89
runtimeExecutor : (RuntimeExecutor)runtimeExecutor
90
+ bindingsInstallExecutor : (RuntimeExecutor)bindingsInstallExecutor
89
91
{
90
92
if (self = [super init ]) {
91
93
assert (contextContainer && " RuntimeExecutor must be not null." );
92
94
_runtimeExecutor = runtimeExecutor;
95
+ _bindingsInstallExecutor = bindingsInstallExecutor;
93
96
_contextContainer = contextContainer;
94
97
95
98
_surfaceRegistry = [RCTSurfaceRegistry new ];
@@ -295,6 +298,7 @@ - (RCTScheduler *)_createScheduler
295
298
}
296
299
297
300
toolbox.runtimeExecutor = runtimeExecutor;
301
+ toolbox.bindingsInstallExecutor = _bindingsInstallExecutor;
298
302
299
303
toolbox.mainRunLoopObserverFactory = [](RunLoopObserver::Activity activities,
300
304
RunLoopObserver::WeakOwner const &owner) {
Original file line number Diff line number Diff line change @@ -89,8 +89,10 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge contextContainer:(ContextCont
89
89
{
90
90
if (self = [super init ]) {
91
91
contextContainer->update (*RCTContextContainerFromBridge (bridge));
92
+ auto runtimeExecuter = RCTRuntimeExecutorFromBridge (bridge);
92
93
_surfacePresenter = [[RCTSurfacePresenter alloc ] initWithContextContainer: contextContainer
93
- runtimeExecutor: RCTRuntimeExecutorFromBridge (bridge)];
94
+ runtimeExecutor: runtimeExecuter
95
+ bindingsInstallExecutor: runtimeExecuter];
94
96
95
97
_bridge = bridge;
96
98
_batchedBridge = [_bridge batchedBridge ] ?: _bridge;
Original file line number Diff line number Diff line change @@ -462,7 +462,12 @@ void Binding::installFabricUIManager(
462
462
auto toolbox = SchedulerToolbox{};
463
463
toolbox.contextContainer = contextContainer;
464
464
toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction ;
465
+
466
+ // TODO: (T130208323) runtimeExecutor should execute lambdas after
467
+ // main bundle eval, and bindingsInstallExecutor should execute before.
468
+ toolbox.bindingsInstallExecutor = runtimeExecutor;
465
469
toolbox.runtimeExecutor = runtimeExecutor;
470
+
466
471
toolbox.synchronousEventBeatFactory = synchronousBeatFactory;
467
472
toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory;
468
473
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ Scheduler::Scheduler(
95
95
uiManager->setDelegate (this );
96
96
uiManager->setComponentDescriptorRegistry (componentDescriptorRegistry_);
97
97
98
- runtimeExecutor_ ([uiManager](jsi::Runtime &runtime) {
98
+ schedulerToolbox. bindingsInstallExecutor ([uiManager](jsi::Runtime &runtime) {
99
99
UIManagerBinding::createAndInstallIfNeeded (runtime, uiManager);
100
100
});
101
101
Original file line number Diff line number Diff line change @@ -40,6 +40,13 @@ struct SchedulerToolbox final {
40
40
41
41
/*
42
42
* Represents running JavaScript VM and associated execution queue.
43
+ * Can execute lambdas before main bundle has loaded.
44
+ */
45
+ RuntimeExecutor bindingsInstallExecutor;
46
+
47
+ /*
48
+ * Represents running JavaScript VM and associated execution queue.
49
+ * Only executes lambdas after main bundle has loaded.
43
50
*/
44
51
RuntimeExecutor runtimeExecutor;
45
52
You can’t perform that action at this time.
0 commit comments