From 7d9cd6e63ae64125f2cf97fcd6a7e1fa9c43bdad Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 4 Jun 2020 15:46:51 +0200 Subject: [PATCH] DocLoader: Ensure the isolate has been properly started It seems that sometimes _sendPort is null. I'm not sure why. In those cases lets try to reinitialize the isolate. Fixes APP-2W --- lib/core/md_yaml_doc_loader.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/core/md_yaml_doc_loader.dart b/lib/core/md_yaml_doc_loader.dart index e75ad0bf..661b42b4 100644 --- a/lib/core/md_yaml_doc_loader.dart +++ b/lib/core/md_yaml_doc_loader.dart @@ -14,10 +14,14 @@ class MdYamlDocLoader { var _loadingLock = Lock(); Future _initIsolate() async { - if (_isolate != null) return; + if (_isolate != null && _sendPort != null) return; return await _loadingLock.synchronized(() async { - if (_isolate != null) return; + if (_isolate != null && _sendPort != null) return; + if (_isolate != null) { + _isolate.kill(priority: Isolate.immediate); + _isolate = null; + } _isolate = await Isolate.spawn(_isolateMain, _receivePort.sendPort); var data = await _receivePort.first;