Index: runtime/vm/dart_api_impl.cc |
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
index f25747cdd707c74414acb52d4c3e7951e379e94c..bd24209a73f60daf4f9d09483ed6512e37d5c98c 100644 |
--- a/runtime/vm/dart_api_impl.cc |
+++ b/runtime/vm/dart_api_impl.cc |
@@ -1664,8 +1664,9 @@ DART_EXPORT Dart_Handle Dart_RunLoop() { |
Monitor monitor; |
MonitorLocker ml(&monitor); |
{ |
- SwitchIsolateScope switch_scope(NULL); |
- |
+ // The message handler run loop does not expect to have a current isolate |
+ // so we exit the isolate here and enter it again after the runloop is done. |
+ Thread::ExitIsolate(); |
RunLoopData data; |
data.monitor = &monitor; |
data.done = false; |
@@ -1675,6 +1676,7 @@ DART_EXPORT Dart_Handle Dart_RunLoop() { |
while (!data.done) { |
ml.Wait(); |
} |
+ Thread::EnterIsolate(I); |
} |
if (I->object_store()->sticky_error() != Object::null()) { |
Dart_Handle error = Api::NewHandle(I, I->object_store()->sticky_error()); |