File tree 6 files changed +25
-3
lines changed
ReactAndroid/src/main/jni/react/fabric
ReactCommon/react/renderer/scheduler
6 files changed +25
-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
+ bridgelessBindingsExecutor : (std::optional<facebook::react::RuntimeExecutor>)bridgelessBindingsExecutor ;
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
+ std::optional<RuntimeExecutor> _bridgelessBindingsExecutor; // 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
+ bridgelessBindingsExecutor : (std::optional<RuntimeExecutor>)bridgelessBindingsExecutor
89
91
{
90
92
if (self = [super init ]) {
91
93
assert (contextContainer && " RuntimeExecutor must be not null." );
92
94
_runtimeExecutor = runtimeExecutor;
95
+ _bridgelessBindingsExecutor = bridgelessBindingsExecutor;
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.bridgelessBindingsExecutor = _bridgelessBindingsExecutor;
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 @@ -90,7 +90,8 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge contextContainer:(ContextCont
90
90
if (self = [super init ]) {
91
91
contextContainer->update (*RCTContextContainerFromBridge (bridge));
92
92
_surfacePresenter = [[RCTSurfacePresenter alloc ] initWithContextContainer: contextContainer
93
- runtimeExecutor: RCTRuntimeExecutorFromBridge (bridge)];
93
+ runtimeExecutor: RCTRuntimeExecutorFromBridge (bridge)
94
+ bridgelessBindingsExecutor:std: :nullopt];
94
95
95
96
_bridge = bridge;
96
97
_batchedBridge = [_bridge batchedBridge ] ?: _bridge;
Original file line number Diff line number Diff line change @@ -468,7 +468,12 @@ void Binding::installFabricUIManager(
468
468
auto toolbox = SchedulerToolbox{};
469
469
toolbox.contextContainer = contextContainer;
470
470
toolbox.componentRegistryFactory = componentsRegistry->buildRegistryFunction ;
471
+
472
+ // TODO: (T130208323) runtimeExecutor should execute lambdas after
473
+ // main bundle eval, and bindingsInstallExecutor should execute before.
474
+ toolbox.bridgelessBindingsExecutor = std::nullopt;
471
475
toolbox.runtimeExecutor = runtimeExecutor;
476
+
472
477
toolbox.synchronousEventBeatFactory = synchronousBeatFactory;
473
478
toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory;
474
479
Original file line number Diff line number Diff line change @@ -95,7 +95,11 @@ Scheduler::Scheduler(
95
95
uiManager->setDelegate (this );
96
96
uiManager->setComponentDescriptorRegistry (componentDescriptorRegistry_);
97
97
98
- runtimeExecutor_ ([uiManager](jsi::Runtime &runtime) {
98
+ auto bindingsExecutor =
99
+ schedulerToolbox.bridgelessBindingsExecutor .has_value ()
100
+ ? schedulerToolbox.bridgelessBindingsExecutor .value ()
101
+ : runtimeExecutor_;
102
+ bindingsExecutor ([uiManager](jsi::Runtime &runtime) {
99
103
UIManagerBinding::createAndInstallIfNeeded (runtime, uiManager);
100
104
});
101
105
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
+ std::optional<RuntimeExecutor> bridgelessBindingsExecutor;
46
+
47
+ /*
48
+ * Represents running JavaScript VM and associated execution queue.
49
+ * 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