Dart : Isolate not working when using html import

南楼画角 提交于 2019-12-11 03:00:32

问题


I found this very strange and unfortunate behavior in Dart. When I import 'dart:html' in my main file, my Isolate stops working.

With my file "isolate.dart" :

main(){
  print('BAM');
}

This prints "BAM":

import 'dart:core';
import 'dart:isolate';

void main() {
  Isolate.spawnUri(Uri.parse('isolate.dart'), [], null);
}

but this prints nothing :

import 'dart:core';
import 'dart:isolate';
import 'dart:html';

void main() {
  Isolate.spawnUri(Uri.parse('isolate.dart'), [], null);
}

How can I get Isolate to work while using the html import?

UPDATE : I've found this code https://github.com/TomCaserta/ExampleIsolate and tried to work it to find the problem. It seems like the print() call from the Isolate is causing problems.


回答1:


This are known bugs/limitations. It is being worked on.

Currently it is not possible to access functionality of the 'dart:html' package in an isolate and 'print()' crashes the isolate probably because there is no package with a 'print' functionality available where the command can be redirected to.

The Dart issue tracker seems not to be available currently.
I try again later to add some references.

Some open issues that I think are related:

  • Print statement inside isolate crashes isolate.
  • Isolate.spawn not allowed in Dartium DOM isolate
  • Support spawn of dom isolates in Dartium
  • Unable to break on breakpoint in library loaded by spawnUri
  • isolate in dartium not creating httprequest, works when compiled to javascript


来源:https://stackoverflow.com/questions/23419979/dart-isolate-not-working-when-using-html-import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!