-
Notifications
You must be signed in to change notification settings - Fork 1.7k
HttpRequest not supported in non-DOM isolates in Dartium #10223
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
Comments
This comment was originally written by [email protected] Peter, this by design. dart2js isolates are just workers so they have partial DOM API. In Dartium non-DOM enabled isolates are pure threads. Let's discuss in the broader context if we'd like to have something like that. Vijay, Pete, your thoughts? cc @blois. |
I'm having a hard time understanding what you'd use non-DOM isolates for in Dartium if they don't support roughly the same API as web workers. I'm also having a hard time understanding how you imagine getting apps developed for JavaScript to run in Dartium if dart2js and Dartium doesn't agree on features like this. Given that this is a difference between Dartium and dart2js, this is a bug, not a request for enhancement. Removed Type-Enhancement label. |
This comment was originally written by [email protected] Peter, webworkers are heavier weight that pure VM isolates and they are still useful for many purposes like number crunching and alike. Given that Dart API are non blocking, there are less use cases to do stuff like httprequest in a separate isolate (not to be understood that there is no reason for that). Disagreement in API is definitely a problem, that's why I reclassified it as Area-HTML, it's not obvious though if we'd like to extend API available or reduce it. |
My vote is that we need support for Web Workers in Dartium. |
Added this to the M6 milestone. |
Just hit this today and it was highly unexpected. |
This comment was originally written by [email protected] Just ran into this issue, very disappointing. I have an isolate which needs to make requests for files to process from the server. Now I have to send the request to the main thread, have it get the file, and send the file to the isolate. |
This comment was originally written by @Bluenuance ran into this today. Nearly a blocking bug in my opinion, as I load a file that has > 5MB that I need to transfer to the isolate and transfer the processed data back. Ugly ugly ugly |
This comment was originally written by @yjbanov Fully agree with comment #8. Browser isolates should support XHR. Number crunching becomes expensive when you have to crunch though lots of data. You get that data from the server. If the main isolate is in charge of talking to the server, then you have to copy data unnecessarily from one isolate to another. |
Removed Area-HTML label. |
Removed this from the Later milestone. |
Removed Oldschool-Milestone-Later label. |
Issue #16565 has been merged into this issue. |
What is the status on this bug? Is anyone working on it? |
Yes, in that we expect to turn isolates in Dartium into webworkers, but it's gated on some other Dartium work. Note that a workaround is that you can spawn a webworker running JS explicitly in Dartium, it's just awkward and not fun to debug. |
This program works fine in dart2js:
import 'dart:isolate';
import 'dart:html' show HttpRequest;
useHttpRequest() {
port.receive((String uri, SendPort replyTo) {
try {
HttpRequest.getString('test.dart').then((text) => replyTo.send(text));
} catch (e, trace) {
replyTo.send('$e\n$trace');
}
});
}
main() {
print('Starting isolate');
spawnFunction(useHttpRequest).call('test.dart').then((reply) => print('Reply: $reply'));
}
The console shows:
Starting isolate test.dart.js:4629
Reply: import 'dart:isolate';
import 'dart:html' show HttpRequest;
useHttpRequest() {
port.receive((String uri, SendPort replyTo) {
try {
// replyTo.send('Hello');
HttpRequest.getString('test.dart').then((text) => replyTo.send(text));
} catch (e, trace) {
replyTo.send('$e\n$trace');
}
});
}
main() {
print('Starting isolate');
spawnFunction(useHttpRequest).call('test.dart').then((reply) => print('Reply: $reply'));
}
test.dart.js:4629
Unfortunately, sadness descents on Dartium. This is what is printed in the console:
Starting isolate undefined:1
Reply: DOM access is not enabled in this isolate
0 HttpRequest._create (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:60:3)
1 HttpRequest.HttpRequest (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:58:35)
2 HttpRequest.request (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:10:15)
3 HttpRequest.getString (file:///Volumes/data/b/build/slave/dartium-mac-inc/build/src/out/Release/gen/webkit/bindings/dart/dart/html/HttpRequest.dart:5:19)
4 useHttpRequest.<anonymous closure> (http://127.0.0.1:56653/web_editor/test.dart:6:28)
5 _ReceivePortImpl._handleMessage (dart:isolate-patch:81:92)
undefined:1
The text was updated successfully, but these errors were encountered: