Skip to content

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

Closed
peter-ahe-google opened this issue Apr 26, 2013 · 16 comments
Closed

HttpRequest not supported in non-DOM isolates in Dartium #10223

peter-ahe-google opened this issue Apr 26, 2013 · 16 comments
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@peter-ahe-google
Copy link
Contributor

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

@DartBot
Copy link

DartBot commented Apr 26, 2013

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.
Removed Type-Defect, Area-Dartium labels.
Added Type-Enhancement, Area-HTML labels.

@peter-ahe-google
Copy link
Contributor Author

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.
Added Type-Defect label.

@DartBot
Copy link

DartBot commented Apr 26, 2013

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.

@peter-ahe-google
Copy link
Contributor Author

My vote is that we need support for Web Workers in Dartium.

@blois
Copy link

blois commented May 29, 2013

Added this to the M6 milestone.

@efortuna
Copy link
Contributor

Removed this from the M6 milestone.
Added this to the Later milestone.

@jtmcdole
Copy link
Contributor

jtmcdole commented Dec 6, 2013

Just hit this today and it was highly unexpected.

@DartBot
Copy link

DartBot commented Feb 7, 2014

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.

@DartBot
Copy link

DartBot commented Mar 19, 2014

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

@DartBot
Copy link

DartBot commented Mar 27, 2014

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.

@blois
Copy link

blois commented Mar 28, 2014

Removed Area-HTML label.
Added Area-Dartium label.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@alan-knight
Copy link
Contributor

Issue #16565 has been merged into this issue.

@jtmcdole
Copy link
Contributor

What is the status on this bug? Is anyone working on it?

@alan-knight
Copy link
Contributor

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.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

9 participants