From cad4158be8a4db9efa9e28a1561426c2fe2b779f Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Fri, 21 Nov 2025 09:31:02 -0300 Subject: [PATCH] =?UTF-8?q?Revert=20"feat(runtime):=20improve=20initializa?= =?UTF-8?q?tion=20with=20context=20scope=20management=20a=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 968043e3988defc69b734bc4ce9c9580e1deb612. --- NativeScript/runtime/Runtime.h | 3 --- NativeScript/runtime/Runtime.mm | 24 +++++++----------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/NativeScript/runtime/Runtime.h b/NativeScript/runtime/Runtime.h index c685acf8..92d95dba 100644 --- a/NativeScript/runtime/Runtime.h +++ b/NativeScript/runtime/Runtime.h @@ -1,8 +1,6 @@ #ifndef Runtime_h #define Runtime_h -#include - #include "Caches.h" #include "Common.h" #include "MetadataBuilder.h" @@ -61,7 +59,6 @@ class Runtime { static thread_local Runtime* currentRuntime_; static std::shared_ptr platform_; static std::vector isolates_; - static std::atomic nextRuntimeId_; static SpinMutex isolatesMutex_; static bool v8Initialized_; static std::atomic nextIsolateId; diff --git a/NativeScript/runtime/Runtime.mm b/NativeScript/runtime/Runtime.mm index 0569743f..e98f56f4 100644 --- a/NativeScript/runtime/Runtime.mm +++ b/NativeScript/runtime/Runtime.mm @@ -22,15 +22,15 @@ #include "DisposerPHV.h" #include "IsolateWrapper.h" -#include #include -#include "DevFlags.h" -#include "HMRSupport.h" #include "ModuleBinding.hpp" #include "ModuleInternalCallbacks.h" #include "URLImpl.h" #include "URLPatternImpl.h" #include "URLSearchParamsImpl.h" +#include +#include "HMRSupport.h" +#include "DevFlags.h" #define STRINGIZE(x) #x #define STRINGIZE_VALUE_OF(x) STRINGIZE(x) @@ -128,7 +128,7 @@ static void InitializeImportMetaObject(Local context, Local mod std::atomic Runtime::nextIsolateId{0}; SimpleAllocator allocator_; NSDictionary* AppPackageJson = nil; -static std::unordered_map AppConfigCache; // generic cache for app config values +static std::unordered_map AppConfigCache; // generic cache for app config values static std::mutex AppConfigCacheMutex; // Global flag to track when JavaScript errors occur during execution @@ -261,9 +261,6 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { v8Initialized_ = true; } - int runtimeId = Runtime::nextRuntimeId_.fetch_add(1, std::memory_order_relaxed); - this->SetWorkerId(runtimeId); - startTime = platform_->MonotonicallyIncreasingTime(); realtimeOrigin = platform_->CurrentClockTimeMillis(); @@ -304,8 +301,8 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { DefineDrainMicrotaskMethod(isolate, globalTemplate); // queueMicrotask(callback) per spec { - Local qmtTemplate = - FunctionTemplate::New(isolate, [](const FunctionCallbackInfo& info) { + Local qmtTemplate = FunctionTemplate::New( + isolate, [](const FunctionCallbackInfo& info) { auto* isolate = info.GetIsolate(); if (info.Length() < 1 || !info[0]->IsFunction()) { isolate->ThrowException(Exception::TypeError( @@ -437,11 +434,6 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { v8::Locker locker(isolate); Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); - - auto cache = Caches::Get(isolate); - auto context = cache->GetContext(); - Context::Scope context_scope(context); - this->moduleInternal_->RunModule(isolate, "./"); } @@ -496,8 +488,7 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { result = AppPackageJson[nsKey]; } - // Store in cache (can cache nil as NSNull to differentiate presence if desired; for now, cache - // as-is) + // Store in cache (can cache nil as NSNull to differentiate presence if desired; for now, cache as-is) { std::lock_guard lock(AppConfigCacheMutex); AppConfigCache[key] = result; @@ -633,7 +624,6 @@ void DisposeIsolateWhenPossible(Isolate* isolate) { std::vector Runtime::isolates_; bool Runtime::v8Initialized_ = false; thread_local Runtime* Runtime::currentRuntime_ = nullptr; -std::atomic Runtime::nextRuntimeId_ = {0}; SpinMutex Runtime::isolatesMutex_; } // namespace tns