| 335 | |
| 336 | _upTime.start(); |
| 337 | _initLock.enter(); |
| 338 | _dispatchQueue->async([this]() { |
| 339 | _initLock.blockingWait(); // Wait for postInit() to be called first before initializing |
| 340 | this->doInitialize(); |
| 341 | }); |
| 342 | |
| 343 | _globalContext = _contextManager->createContext(nullptr, nullptr, /* deferRender */ true); |
| 344 | // Keep a +1 disposable until we complete the teardown |
| 345 | _globalContext->retainDisposables(); |
| 346 | } |
| 347 | |
| 348 | void JavaScriptRuntime::postInit() { |
| 349 | if (!_isWorker && _anrDetector != nullptr) { |
| 350 | _anrDetector->appendTaskScheduler(this); |
| 351 | } |
| 352 | |
| 353 | _contextHandler = makeShared<JavaScriptComponentContextHandler>(*this, this, *_logger); |
| 354 | _initLock.leaveIfNotCompleted(); |
| 355 | |
| 356 | if (auto listener = getListener()) { |
| 357 | auto runtimeTweaks = listener->getRuntimeTweaks(); |
| 358 | if (runtimeTweaks != nullptr) { |
| 359 | _dispatchQueue->setDisableSyncCallsInCallingThread(runtimeTweaks->disableSyncCallsInCallingThread()); |
| 360 | // Pull the termination mode here too: worker runtimes are created fresh (runtimeCreateWorker) |
| 361 | // and only inherit the host's listener, not its pushed tweaks, so Runtime::setRuntimeTweaks |
| 362 | // (which targets the host runtime) never reaches them. Reading it at postInit — after the |
| 363 | // worker's listener is set — lets a worker honor an aggressive-termination override. |
| 364 | setCooperativeTermination(runtimeTweaks->useCooperativeTermination()); |
no test coverage detected