Skip to content

Commit 64b87e0

Browse files
committed
fix: thread is blocked after the isolate died.
1 parent 90c9dce commit 64b87e0

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

dart_native/ios/Classes/native_runtime.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ intptr_t InitDartApiDL(void *data) {
433433

434434
typedef std::function<void()> Work;
435435

436-
void NotifyDart(Dart_Port send_port, const Work* work) {
436+
BOOL NotifyDart(Dart_Port send_port, const Work* work) {
437437
const intptr_t work_addr = reinterpret_cast<intptr_t>(work);
438438

439439
Dart_CObject dart_object;
@@ -444,6 +444,7 @@ void NotifyDart(Dart_Port send_port, const Work* work) {
444444
if (!result) {
445445
NSLog(@"Native callback to Dart failed! Invalid port or isolate died");
446446
}
447+
return result;
447448
}
448449

449450
DN_EXTERN
@@ -475,8 +476,8 @@ void NotifyBlockInvokeToDart(DNInvocation *invocation,
475476
}
476477
};
477478
const Work* work_ptr = new Work(work);
478-
NotifyDart(wrapper.dartPort, work_ptr);
479-
if (sema) {
479+
BOOL success = NotifyDart(wrapper.dartPort, work_ptr);
480+
if (sema && success) {
480481
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
481482
}
482483
}
@@ -504,8 +505,8 @@ void NotifyMethodPerformToDart(DNInvocation *invocation,
504505
}
505506
};
506507
const Work* work_ptr = new Work(work);
507-
NotifyDart(methodIMP.dartPort, work_ptr);
508-
if (sema) {
508+
BOOL success = NotifyDart(methodIMP.dartPort, work_ptr);
509+
if (sema && success) {
509510
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
510511
}
511512
}
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)