Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart : Isolate not working when using html import

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 Answers

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
like image 93
Günter Zöchbauer Avatar answered Aug 02 '26 16:08

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!