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 3434SimpleAllocator allocator_;
3535NSDictionary * AppPackageJson = nil ;
3636
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+
3753void Runtime::Initialize () {
3854 MetaFile::setInstance (RuntimeConfig.MetadataPtr );
3955}
8298 this ->isolate_ ->SetData (Constants::RUNTIME_SLOT, nullptr );
8399 }
84100
85- this ->isolate_ -> Dispose ( );
101+ DisposeIsolateWhenPossible ( this ->isolate_ );
86102
87103 currentRuntime_ = nullptr ;
88104}
You can’t perform that action at this time.
0 commit comments