Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dart2js not using web worker for isolate #4689

Closed
sethladd opened this issue Aug 23, 2012 · 19 comments
Closed

dart2js not using web worker for isolate #4689

sethladd opened this issue Aug 23, 2012 · 19 comments

Comments

@sethladd
Copy link
Contributor

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)

@sethladd
Copy link
Contributor Author

Digging in, it looks like "$._globalState().get$useWorkers()" is returning undefined. (line 4242) How do we set $supportsWorkers ?

@DartBot
Copy link

DartBot commented Aug 24, 2012

This comment was originally written by ngeoffray@google.com


When I did the original port of the frog code for isolates to dart2js, I think I only made sure we could run isolates. So web workers may not work out of the box and some new magic JS glue might be needed.

@sigmundch
Copy link
Member

That's right - the implementation in dart2js is not working correctly exactly for that reason. The library implementation simulates isolates in the UI thread as a fallback.

Thanks for filing the bug. I thought I already had filed a bug about this a while back, but I wasn't able to find it.


cc @floitschG.
cc @kasperl.

@kasperl
Copy link

kasperl commented Aug 29, 2012

Assigning to Florian.


Set owner to @floitschG.
Added Accepted label.

@kasperl
Copy link

kasperl commented Sep 3, 2012

Added this to the Later milestone.

@sigmundch
Copy link
Member

Marked this as blocking #2599.

@sigmundch
Copy link
Member

Added Library-Isolates label.

@DartBot
Copy link

DartBot commented Sep 11, 2012

This comment was originally written by jjinux...@google.com


Whenever this is ready, I want to take a stab at porting (http://www.html5rocks.com/en/tutorials/workers/basics/) to Dart.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Removed this from the Later milestone.

@kasperl
Copy link

kasperl commented Oct 17, 2012

Added this to the M2 milestone.

@floitschG
Copy link
Contributor

Removed the owner.
Added Triaged label.

@peter-ahe-google
Copy link
Contributor

Set owner to ngeoffray@google.com.

@DartBot
Copy link

DartBot commented Nov 29, 2012

This comment was originally written by trapped.into...@gmail.com


Evaluating Dart and looks awesome. This is an important feature for my use case. Is there a workaround I can use with current code base? Or even some "magic glue" as mentioned in one of the comments?

@DartBot
Copy link

DartBot commented Nov 30, 2012

This comment was originally written by ngeoffray@google.com


Thanks for the feedback. I don't think there is any easy workaround for supporting web workers, other than implementing it :) But getting support back for web workers in isolates is definitely in our radar.

@DartBot
Copy link

DartBot commented Nov 30, 2012

This comment was originally written by trapped.into...@gmail.com


Thanks for getting back.

Isolates are great, of course I understand with the design limitations on Workers, its not trivial to translate them. I did read somewhere Frog supported Isolates to Workers? or it was not so?

I can just work with plain Workers too. It was my plan before my eyes lit up seeing Isolates. What about Worker from dart:html? Is that class translated correctly?

@DartBot
Copy link

DartBot commented Nov 30, 2012

This comment was originally written by ngeoffray@google.com


Yes, Workers in the html library are translated correctly, so you could start playing with them until we use them for isolates.

@kasperl
Copy link

kasperl commented Dec 13, 2012

Postponing until M3. CL out for review: https://codereview.chromium.org/11553024/.


Removed this from the M2 milestone.
Added this to the M3 milestone.
Added Started label.

@kwalrath
Copy link
Contributor

It looks like this was committed December 14. So maybe it works now?

@kasperl
Copy link

kasperl commented Jan 11, 2013

Nope - still doesn't work. The commit was reverted.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants