-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
Digging in, it looks like "$._globalState().get$useWorkers()" is returning undefined. (line 4242) How do we set $supportsWorkers ? |
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. |
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. |
Assigning to Florian. Set owner to @floitschG. |
Added this to the Later milestone. |
Marked this as blocking #2599. |
Added Library-Isolates label. |
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. |
Removed this from the Later milestone. |
Added this to the M2 milestone. |
Removed the owner. |
Set owner to ngeoffray@google.com. |
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? |
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. |
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? |
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. |
Postponing until M3. CL out for review: https://codereview.chromium.org/11553024/. Removed this from the M2 milestone. |
It looks like this was committed December 14. So maybe it works now? |
Nope - still doesn't work. The commit was reverted. |
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)
The text was updated successfully, but these errors were encountered: