Skip to content

Commit 9a253d1

Browse files
p-sunfacebook-github-bot
authored andcommitted
Back out "Back out "[Venice][iOS] Fix: Install Fabric UIManager before main bundle execution""
Summary: Changelog: [Internal][Bridgeless][iOS] # Before diff Be in Venice > run Metro > run FBiOS > navigate to any RN surface. `UIManagerBinding createAndInstallIfNeeded` happens After `ReactInstance loadScript -> evaluateJavaScript`: install Fabric UIManager before main bundle execution Reviewed By: RSNara Differential Revision: D39760231 fbshipit-source-id: f17bf02e9b1fb0f9b0ff24c86aa6dc9349c42192
1 parent 47548c1 commit 9a253d1

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

React/Fabric/RCTSurfacePresenter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN
2828
@interface RCTSurfacePresenter : NSObject
2929

3030
- (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;
3233

3334
@property (nonatomic) facebook::react::ContextContainer::Shared contextContainer;
3435
@property (nonatomic) facebook::react::RuntimeExecutor runtimeExecutor;

React/Fabric/RCTSurfacePresenter.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,20 @@ @implementation RCTSurfacePresenter {
7979
RCTScheduler *_Nullable _scheduler; // Thread-safe. Pointer is protected by `_schedulerAccessMutex`.
8080
ContextContainer::Shared _contextContainer; // Protected by `_schedulerLifeCycleMutex`.
8181
RuntimeExecutor _runtimeExecutor; // Protected by `_schedulerLifeCycleMutex`.
82+
std::optional<RuntimeExecutor> _bridgelessBindingsExecutor; // Only used for installing bindings.
8283

8384
butter::shared_mutex _observerListMutex;
8485
std::vector<__weak id<RCTSurfacePresenterObserver>> _observers; // Protected by `_observerListMutex`.
8586
}
8687

8788
- (instancetype)initWithContextContainer:(ContextContainer::Shared)contextContainer
8889
runtimeExecutor:(RuntimeExecutor)runtimeExecutor
90+
bridgelessBindingsExecutor:(std::optional<RuntimeExecutor>)bridgelessBindingsExecutor
8991
{
9092
if (self = [super init]) {
9193
assert(contextContainer && "RuntimeExecutor must be not null.");
9294
_runtimeExecutor = runtimeExecutor;
95+
_bridgelessBindingsExecutor = bridgelessBindingsExecutor;
9396
_contextContainer = contextContainer;
9497

9598
_surfaceRegistry = [RCTSurfaceRegistry new];
@@ -295,6 +298,7 @@ - (RCTScheduler *)_createScheduler
295298
}
296299

297300
toolbox.runtimeExecutor = runtimeExecutor;
301+
toolbox.bridgelessBindingsExecutor = _bridgelessBindingsExecutor;
298302

299303
toolbox.mainRunLoopObserverFactory = [](RunLoopObserver::Activity activities,
300304
RunLoopObserver::WeakOwner const &owner) {

React/Fabric/RCTSurfacePresenterBridgeAdapter.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge contextContainer:(ContextCont
9090
if (self = [super init]) {
9191
contextContainer->update(*RCTContextContainerFromBridge(bridge));
9292
_surfacePresenter = [[RCTSurfacePresenter alloc] initWithContextContainer:contextContainer
93-
runtimeExecutor:RCTRuntimeExecutorFromBridge(bridge)];
93+
runtimeExecutor:RCTRuntimeExecutorFromBridge(bridge)
94+
bridgelessBindingsExecutor:std::nullopt];
9495

9596
_bridge = bridge;
9697
_batchedBridge = [_bridge batchedBridge] ?: _bridge;

ReactAndroid/src/main/jni/react/fabric/Binding.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,12 @@ void Binding::installFabricUIManager(
468468
auto toolbox = SchedulerToolbox{};
469469
toolbox.contextContainer = contextContainer;
470470
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;
471475
toolbox.runtimeExecutor = runtimeExecutor;
476+
472477
toolbox.synchronousEventBeatFactory = synchronousBeatFactory;
473478
toolbox.asynchronousEventBeatFactory = asynchronousBeatFactory;
474479

ReactCommon/react/renderer/scheduler/Scheduler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ Scheduler::Scheduler(
9595
uiManager->setDelegate(this);
9696
uiManager->setComponentDescriptorRegistry(componentDescriptorRegistry_);
9797

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) {
99103
UIManagerBinding::createAndInstallIfNeeded(runtime, uiManager);
100104
});
101105

ReactCommon/react/renderer/scheduler/SchedulerToolbox.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ struct SchedulerToolbox final {
4040

4141
/*
4242
* 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.
4350
*/
4451
RuntimeExecutor runtimeExecutor;
4552

0 commit comments

Comments
 (0)