File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 34
34
SimpleAllocator allocator_;
35
35
NSDictionary * AppPackageJson = nil ;
36
36
37
+ void DisposeIsolateWhenPossible (Isolate* isolate) {
38
+ // most of the time, this will never delay disposal
39
+ // occasionally this can happen when the runtime is destroyed by actions of its own isolate
40
+ // as an example: isolate calls exit(0), which in turn destroys the Runtime unique_ptr
41
+ // another scenario is when embedding nativescript, if the embedder deletes the runtime as a result of a callback from JS
42
+ // in the case of exit(0), the app will die before actually disposing the isolate, which isn't a problem
43
+ if (isolate->IsInUse ()) {
44
+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(10.0 * NSEC_PER_MSEC)),
45
+ dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_LOW, 0 ), ^{
46
+ DisposeIsolateWhenPossible (isolate);
47
+ });
48
+ } else {
49
+ isolate->Dispose ();
50
+ }
51
+ }
52
+
37
53
void Runtime::Initialize () {
38
54
MetaFile::setInstance (RuntimeConfig.MetadataPtr );
39
55
}
82
98
this ->isolate_ ->SetData (Constants::RUNTIME_SLOT, nullptr );
83
99
}
84
100
85
- this ->isolate_ -> Dispose ( );
101
+ DisposeIsolateWhenPossible ( this ->isolate_ );
86
102
87
103
currentRuntime_ = nullptr ;
88
104
}
You can’t perform that action at this time.
0 commit comments