-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
print silently kills spawnUri isolate in Dartium #14080
Comments
Is this running in dartium or compiled with dart2js? Added Area-Library, Triaged labels. |
This comment was originally written by kbec...@gmail.com In dartium. The dart2js Version that spawns with the compiled JavaScript version works. — |
We recently modified the spawnUri/spawnFunction in Dartium, but normally this should still work. cc @vsmenon. |
Haven't yet have the time to really investigate, but Vijay told me that "print" currently relies on the DOM and is therefore not available in spawnUri threads (which don't have access to the DOM). |
This comment was originally written by kbecker...@gmail.com The problem is not that the isolate can not print (which is annoying as well), but the isolate sends back data, the String "Test" which is not done. So the isolate is not responding at all.. |
Just reproduced. It seems like calling "print" in the spawned isolate will silently kill the isolate. After removing the print I got the message back. Changing title of bug accordingly. Changed the title to: "print silently kills spawnUri isolate in Dartium". |
This comment was originally written by kbec...@gmail.com Ah, thanks! That was causing the problem. I was able to work around that by eliminating the print statements. Now it works as expected. Well except that debugging of isolates is now close to impossible ;) |
For now the easiest work-around is to overwrite "print" with a function that sends the message to the other side: in the DOM isolate: otherIsolatePort.send(printReceiver.toSendPort()); -- in the other Isolate: main() { print(o) { _globalPrintPort.send(o.toString()); } It's not optimal, but at least it should get you going (and this is probably what we are going to do behind the scenes). |
This comment was originally written by @filiph I understand this is not simple to fix properly, but a huge improvement would be if: a) calling print() in an isolate would just be ignored, or Right now, debugging a complex isolate is a nightmare. And since there was the recent major change in the dart:isolate library (https://plus.google.com/+dartlang/posts/NF6AJ3oPYuk), that's a lot of nightmares out there. |
Issue #14800 has been merged into this issue. |
This comment was originally written by salgat...@gmail.com This problem gave me a lot of headaches last night, was finally able to isolate it down to this reason. Good to see it confirmed here. filip.hr has a good point that print should be ignored for the time being. |
Should this be reclassified as Dartium? |
cc @lrhn. |
Issue #19170 has been merged into this issue. |
Issue #16402 has been merged into this issue. |
Issue #21877 has been merged into this issue. |
@ivan: I will talk to Lasse tomorrow to see if there is a work-around, but this really should be fixed at the Dartium level (which is why I reassigned the Area). A similar issue #21925 fails because of the same restrictions (there because of missing Timers). cc @iposva-google. |
I also created 22163 for this. It might be a duplicate. The problem is not that it silently kills the isolate, it throws with a clear error message which then gets discarded. Possibly the root problem is that setting up isolate exception handling is hard. But print should also just work. |
This issue was originally filed by kbecker81...@gmail.com
What steps will reproduce the problem?
There is a file test.dart:
import 'dart:isolate';
void main(){
port.receive((String map, SendPort send){
print("Received: $map");
send.send("Test");
});
}
A file server.dart:
import 'dart:async';
import 'dart:io';
void main() {
HttpServer.bind("localhost", 9998)
.then((server) {
print("http://${server.address}:${server.port}/");
server.listen(
(request) {
// request.response.headers.set(HttpHeaders.CONTENT_TYPE, "application/dart");
new File("test.dart").openRead().pipe(request.response);
});
});
}
A command line test:
import 'dart:isolate';
void main(){
var spawn=spawnUri("http://localhost:9998/");
spawn.call("Hallo").then((map){
print(map);
});
}
And a web test (with all the example application stuff and this dart file):
import 'dart:html';
import 'dart:isolate';
void main() {
query("#sample_text_id")
..text = "Click me!"
..onClick.listen(reverseText);
}
void reverseText(MouseEvent event) {
var spawn=spawnUri("http://localhost:9998/");
spawn.call("Hallo").then((map){
print(map);
query("#sample_text_id").text = map.toString();
});
}
What is the expected output? What do you see instead?
The output of the web version should be the same as the web version:
Received: Hallo
Test
What version of the product are you using? On what operating system?
Dart SDK version 0.8.1.2_r28355 on MacOS X
The only message you get is that the script is transferred as text/plain, but I also tried application/dart which did not change anything..
The text was updated successfully, but these errors were encountered: