Skip to content

dart2js not using web worker for isolate #4689

@sethladd

Description

@sethladd

This code doesn't seem to be using a web worker. I tested by setting breakpoint on line of "new Worker" and it's never hit.

import('dart:html');

import('dart:isolate');

myIsolate() {
  port.receive((msg, reply) {
    print("isolate received message");
    var s = new StringBuffer();
    // simulate heavy work
    for (var i = 0; i < 600000; i++) {
      s.add("$i");
    }
    reply.send("I received: ${s.toString()}");
  });
}

main() {
  var sendPort = spawnFunction(myIsolate);
  
  query('#myButton').on.click.add((Event e) {
    print("just clicked");
      sendPort.call("Hello from main").then((reply) {
        print("done with message size ${reply.length}");
      });
    print("sent request to isolate");
  });
  
}

I've attached the compiled JS output.

Should isolates use web workers when compiled to JavaScript ?


Attachment:
isolatesinweb.dart.js (201.12 KB)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions