Skip to content

Commit 7e24de8

Browse files
committed
fix: soif on runtime destruction
1 parent 0c4c017 commit 7e24de8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

NativeScript/runtime/Runtime.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ModuleInternal.h"
77
#include "MetadataBuilder.h"
88
#include "SpinLock.h"
9+
#include "Caches.h"
910

1011
namespace tns {
1112

@@ -73,6 +74,12 @@ class Runtime {
7374
std::unique_ptr<ModuleInternal> moduleInternal_;
7475
int workerId_;
7576
CFRunLoopRef runtimeLoop_;
77+
// TODO: refactor this. This is only needed because, during program termination (UIApplicationMain not called)
78+
// the Cache::Workers is released (static initialization order fiasco https://en.cppreference.com/w/cpp/language/siof)
79+
// so it released the Cache::Workers shared_ptr and then releases the Runtime unique_ptr
80+
// eventually we just need to refactor so that Runtime::Initialize is responsible for its initalization
81+
// and lifecycle
82+
std::shared_ptr<ConcurrentMap<int, std::shared_ptr<Caches::WorkerState>>> workerCache_;
7683
};
7784

7885
}

NativeScript/runtime/Runtime.mm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
Runtime::Runtime() {
4242
currentRuntime_ = this;
4343
workerId_ = -1;
44+
workerCache_ = Caches::Workers;
4445
}
4546

4647
Runtime::~Runtime() {

0 commit comments

Comments
 (0)