Skip to content

Commit 54a83ad

Browse files
committed
Initialize the RuntimeScheduler and TurboModule bindings via RuntimeExecutor
In order to minimize the dependency on the JSI runtime holder, this switches the initialization of TurboModules and RuntimeScheduler bindings to use the RuntimeExecutor, which hands us back the Runtime instance.
1 parent 128ef19 commit 54a83ad

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

vnext/Shared/OInstance.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,15 @@ InstanceImpl::InstanceImpl(
361361
winrt::Microsoft::ReactNative::ReactPropertyBag(propertyBag), m_runtimeScheduler);
362362
}
363363

364-
// Using runOnQueueSync because initializeBridge calls createJSExecutor with runOnQueueSync,
365-
// so this is an attempt to keep the same semantics for exiting this method with TurboModuleManager
366-
// initialized.
367-
m_jsThread->runOnQueueSync([propertyBag,
368-
innerInstance = m_innerInstance,
369-
runtimeHolder = m_devSettings->jsiRuntimeHolder,
370-
runtimeScheduler = m_runtimeScheduler,
371-
turboModuleRegistry = m_turboModuleRegistry,
372-
longLivedObjectCollection = m_longLivedObjectCollection]() {
364+
// Use RuntimeExecutor so non-ABI JSExecutorFactory instances passed in through DevSettings
365+
// can use the same logic
366+
runtimeExecutor([propertyBag,
367+
innerInstance = m_innerInstance,
368+
runtimeScheduler = m_runtimeScheduler,
369+
turboModuleRegistry = m_turboModuleRegistry,
370+
longLivedObjectCollection = m_longLivedObjectCollection](jsi::Runtime &runtime) {
373371
if (runtimeScheduler) {
374-
RuntimeSchedulerBinding::createAndInstallIfNeeded(*runtimeHolder->getRuntime(), runtimeScheduler);
372+
RuntimeSchedulerBinding::createAndInstallIfNeeded(runtime, runtimeScheduler);
375373
}
376374
auto turboModuleManager = std::make_shared<TurboModuleManager>(
377375
turboModuleRegistry,
@@ -386,10 +384,7 @@ InstanceImpl::InstanceImpl(
386384
};
387385

388386
TurboModuleBinding::install(
389-
*runtimeHolder->getRuntime(),
390-
std::function(binding),
391-
TurboModuleBindingMode::HostObject,
392-
longLivedObjectCollection);
387+
runtime, std::function(binding), TurboModuleBindingMode::HostObject, longLivedObjectCollection);
393388

394389
// init TurboModule
395390
for (const auto &moduleName : turboModuleManager->getEagerInitModuleNames()) {

0 commit comments

Comments
 (0)