| diff --git a/third_party/tonic/dart_persistent_value.cc b/third_party/tonic/dart_persistent_value.cc |
| index 9ed6f70f3532..3bc46505d31f 100644 |
| --- a/third_party/tonic/dart_persistent_value.cc |
| +++ b/third_party/tonic/dart_persistent_value.cc |
| @@ -43,8 +43,12 @@ void DartPersistentValue::Clear() { |
| return; |
| } |
| |
| - DartIsolateScope scope(dart_state->isolate()); |
| - Dart_DeletePersistentHandle(value_); |
| + if (Dart_CurrentIsolateGroup()) { |
| + Dart_DeletePersistentHandle(value_); |
| + } else { |
| + DartIsolateScope scope(dart_state->isolate()); |
| + Dart_DeletePersistentHandle(value_); |
| + } |
| dart_state_.reset(); |
| value_ = nullptr; |
| } |
| diff --git a/third_party/tonic/dart_wrappable.cc b/third_party/tonic/dart_wrappable.cc |
| index 42c8fff2805b..89064ac8eef7 100644 |
| --- a/third_party/tonic/dart_wrappable.cc |
| +++ b/third_party/tonic/dart_wrappable.cc |
| @@ -37,7 +37,7 @@ void DartWrappable::ClearDartWrapper() { |
| TONIC_CHECK(!LogIfError(Dart_SetNativeInstanceField(wrapper, kPeerIndex, 0))); |
| TONIC_CHECK( |
| !LogIfError(Dart_SetNativeInstanceField(wrapper, kWrapperInfoIndex, 0))); |
| - Dart_DeleteWeakPersistentHandle(Dart_CurrentIsolate(), dart_wrapper_); |
| + Dart_DeleteWeakPersistentHandle(dart_wrapper_); |
| dart_wrapper_ = nullptr; |
| this->ReleaseDartWrappableReference(); |
| } |