Discussion:
[dart-misc] dart2js isolates?
Alec Henninger
2016-01-01 22:50:15 UTC
Permalink
Admittedly I have yet to try it out, but I'm curious if anywhere here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says "Dart
web apps can't currently create additional isolates, but they can create
additional *workers.*"

Do they currently fully map to workers in JS? If not, is it planned?

Thanks!

Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2016-01-02 20:20:10 UTC
Permalink
Curious about this as well. Never saw a statement that clearly says isolate should work in the browser, and how.
Admittedly I have yet to try it out, but I'm curious if anyone here successfully uses additional isolates in their web app. I have been reading competing things about isolates WRT dart2js. Seth has said they compile to web workers, but https://www.dartlang.org/articles/event-loop/ says "Dart web apps can't currently create additional isolates, but they can create additional workers."
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Andreas Reiter
2016-01-04 09:02:42 UTC
Permalink
Isolate.spawn(...) does not work in the browser, but spawnUri does.

A nice example is provided here: http://stackoverflow.com/a/25104337/4370360

Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says isolate should work in the browser, and how.
Admittedly I have yet to try it out, but I'm curious if anyone here successfully uses additional isolates in their web app. I have been reading competing things about isolates WRT dart2js. Seth has said they compile to web workers, but https://www.dartlang.org/articles/event-loop/ says "Dart web apps can't currently create additional isolates, but they can create additional workers."
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2016-01-04 11:21:58 UTC
Permalink
That loads a Dart script. I doubt this example works in Chrome after `pub
build`.
I guess there is a way to make it work (building the isolate source to JS
as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no details
how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says "Dart
web apps can't currently create additional isolates, but they can create
additional workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Peter StJ
2016-09-17 12:36:44 UTC
Permalink
I have successfully used isolates in dart and js from the same source code.

It works fine, the only limitation is that you have to have your url for
worker in web dir because once built the urls for lib change, other than
that it works as expected, use the same URL (for example 'worker.dart') and
it is compiled to a separate js executable. I have not tried to call the
worker unit from JS from main thread, I am not sure it this will work, but
calling it from dart from main thread works.

Here is an example:



/// Initializes the worker (url is passes static - worker.dart).
Future _initWorker() async {
var uri = Uri.parse(url);
_worker = await Isolate.spawnUri(uri, [], _reciever.sendPort);
_reciever.listen(_handleData);
return null;
}


Interestingly the dart file for worker is not requested, instead the js
file is fetched:

<Loading Image...>

localhost 200 document Other 669 B 6 ms
dart.js 200 script (index):7 <http://localhost:8080/> 1.0 KB 6 ms
main.dart.js 200 script dart.js:27 39.7 KB 23 ms
⚙ service-worker.js (failed) :8080/service-worker.js:1
<http://localhost:8080/service-worker.js> 0 B 10 ms
petstore.json 200 xhr html_dart2js.dart:19486 1.1 KB 5 ms
worker.dart.js 200 script isolate_helper.dart:1094 46.2 KB 19 ms
⚙ service-worker.js (failed) :8080/service-worker.js:1
<http://localhost:8080/service-worker.js> 0 B 5 ms
localhost 200 document Other 669 B 6 ms
dart.js 200 script (index):7 <http://localhost:8080/> 1.0 KB 6 ms
main.dart.js 200 script dart.js:27 39.7 KB 23 ms
⚙ service-worker.js (failed) :8080/service-worker.js:1
<http://localhost:8080/service-worker.js> 0 B 10 ms
petstore.json 200 xhr html_dart2js.dart:19486 1.1 KB 5 ms
worker.dart.js 200 script isolate_helper.dart:1094 46.2 KB 19 ms
⚙ service-worker.js (failed) :8080/service-worker.js:1
<http://localhost:8080/service-worker.js> 0 B 5 ms
Post by Günter Zöchbauer
That loads a Dart script. I doubt this example works in Chrome after `pub
build`.
I guess there is a way to make it work (building the isolate source to JS
as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no details
how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says
"Dart web apps can't currently create additional isolates, but they can
create additional workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Edouard Tavinor
2016-09-19 12:49:29 UTC
Permalink
Hi!

Can you tell me what's in your pubspec.yaml and how you're compiling the
code?

I'm compiling using dart2js without options and my pubspec.yaml is as
follows:
name: 'isolatetest'
version: 0.0.1
description: An absolute bare-bones web app.
#author: Your Name <***@example.com>
#homepage: https://www.example.com

environment:
sdk: '>=1.0.0 <2.0.0'

dependencies:
browser: "^0.10.0"
dart_to_js_script_rewriter: '^0.1.0'

transformers:
- dart_to_js_script_rewriter
Post by Peter StJ
I have successfully used isolates in dart and js from the same source code.
It works fine, the only limitation is that you have to have your url for
worker in web dir because once built the urls for lib change, other than
that it works as expected, use the same URL (for example 'worker.dart') and
it is compiled to a separate js executable. I have not tried to call the
worker unit from JS from main thread, I am not sure it this will work, but
calling it from dart from main thread works.
/// Initializes the worker (url is passes static - worker.dart).
Future _initWorker() async {
var uri = Uri.parse(url);
_worker = await Isolate.spawnUri(uri, [], _reciever.sendPort);
_reciever.listen(_handleData);
return null;
}
Interestingly the dart file for worker is not requested, instead the js
<https://lh3.googleusercontent.com/-pA_HEIpiAHA/V904waTBhPI/AAAAAAAAOD4/RLt68vJf-MUepcI9ELH8UKYQ0JktkqTBQCLcB/s1600/Screenshot%2Bfrom%2B2016-09-17%2B15-35-49.png>
Post by Günter Zöchbauer
That loads a Dart script. I doubt this example works in Chrome after `pub
build`.
I guess there is a way to make it work (building the isolate source to JS
as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no details
how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says
"Dart web apps can't currently create additional isolates, but they can
create additional workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Peter StJ
2016-09-20 11:09:36 UTC
Permalink
Sure:


name: swagger_tools
description: Collection of instruments to work with REST API describing
documents.
version: 0.0.1
author: PeterStJ <***@gmail.com>


environment:
sdk: '>=1.0.0 <2.0.0'


dependencies:
semver: "^0.2.1"


dev_dependencies:
test: '>=0.12.0 <0.13.0'
args: '^0.13.4'
browser: '>=0.10.0 <0.11.0'
dart_to_js_script_rewriter: '^0.1.0'


# Include transformers for the web test to run
transformers:
- dart_to_js_script_rewriter
- $dart2js:
csp: false
sourceMaps: true
checked: false
minify: true
commandLineOptions:
- --trust-type-annotations
- --trust-primitives


pub serve / pub build is used to serve/compile
Post by Edouard Tavinor
Hi!
Can you tell me what's in your pubspec.yaml and how you're compiling the
code?
I'm compiling using dart2js without options and my pubspec.yaml is as
name: 'isolatetest'
version: 0.0.1
description: An absolute bare-bones web app.
#homepage: https://www.example.com
sdk: '>=1.0.0 <2.0.0'
browser: "^0.10.0"
dart_to_js_script_rewriter: '^0.1.0'
- dart_to_js_script_rewriter
Post by Peter StJ
I have successfully used isolates in dart and js from the same source code.
It works fine, the only limitation is that you have to have your url for
worker in web dir because once built the urls for lib change, other than
that it works as expected, use the same URL (for example 'worker.dart') and
it is compiled to a separate js executable. I have not tried to call the
worker unit from JS from main thread, I am not sure it this will work, but
calling it from dart from main thread works.
/// Initializes the worker (url is passes static - worker.dart).
Future _initWorker() async {
var uri = Uri.parse(url);
_worker = await Isolate.spawnUri(uri, [], _reciever.sendPort);
_reciever.listen(_handleData);
return null;
}
Interestingly the dart file for worker is not requested, instead the js
<https://lh3.googleusercontent.com/-pA_HEIpiAHA/V904waTBhPI/AAAAAAAAOD4/RLt68vJf-MUepcI9ELH8UKYQ0JktkqTBQCLcB/s1600/Screenshot%2Bfrom%2B2016-09-17%2B15-35-49.png>
Post by Günter Zöchbauer
That loads a Dart script. I doubt this example works in Chrome after
`pub build`.
I guess there is a way to make it work (building the isolate source to
JS as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no details
how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
On Friday, January 1, 2016 at 11:50:15 PM UTC+1, Alec Henninger
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says
"Dart web apps can't currently create additional isolates, but they can
create additional workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Doug Reese
2016-10-03 12:36:57 UTC
Permalink
I am curious about your swagger_tools package. I don't see it on pub
(yet). I have just started looking into Swagger with respect to Dart.

Doug
Post by Peter StJ
name: swagger_tools
description: Collection of instruments to work with REST API describing
documents.
version: 0.0.1
sdk: '>=1.0.0 <2.0.0'
semver: "^0.2.1"
test: '>=0.12.0 <0.13.0'
args: '^0.13.4'
browser: '>=0.10.0 <0.11.0'
dart_to_js_script_rewriter: '^0.1.0'
# Include transformers for the web test to run
- dart_to_js_script_rewriter
csp: false
sourceMaps: true
checked: false
minify: true
- --trust-type-annotations
- --trust-primitives
pub serve / pub build is used to serve/compile
Post by Edouard Tavinor
Hi!
Can you tell me what's in your pubspec.yaml and how you're compiling the
code?
I'm compiling using dart2js without options and my pubspec.yaml is as
name: 'isolatetest'
version: 0.0.1
description: An absolute bare-bones web app.
#homepage: https://www.example.com
sdk: '>=1.0.0 <2.0.0'
browser: "^0.10.0"
dart_to_js_script_rewriter: '^0.1.0'
- dart_to_js_script_rewriter
Post by Peter StJ
I have successfully used isolates in dart and js from the same source code.
It works fine, the only limitation is that you have to have your url for
worker in web dir because once built the urls for lib change, other than
that it works as expected, use the same URL (for example 'worker.dart') and
it is compiled to a separate js executable. I have not tried to call the
worker unit from JS from main thread, I am not sure it this will work, but
calling it from dart from main thread works.
/// Initializes the worker (url is passes static - worker.dart).
Future _initWorker() async {
var uri = Uri.parse(url);
_worker = await Isolate.spawnUri(uri, [], _reciever.sendPort);
_reciever.listen(_handleData);
return null;
}
Interestingly the dart file for worker is not requested, instead the js
<https://lh3.googleusercontent.com/-pA_HEIpiAHA/V904waTBhPI/AAAAAAAAOD4/RLt68vJf-MUepcI9ELH8UKYQ0JktkqTBQCLcB/s1600/Screenshot%2Bfrom%2B2016-09-17%2B15-35-49.png>
Post by Günter Zöchbauer
That loads a Dart script. I doubt this example works in Chrome after
`pub build`.
I guess there is a way to make it work (building the isolate source to
JS as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no
details how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
On Friday, January 1, 2016 at 11:50:15 PM UTC+1, Alec Henninger
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says
"Dart web apps can't currently create additional isolates, but they can
create additional workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it
planned?
Post by Günter Zöchbauer
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Peter StJ
2016-10-04 12:07:51 UTC
Permalink
Its nothing special, it ingests swagger format API description and produces
dart, closure compatible JS, angular services etc, similar to the code gen
utility used in dart to produce code for discovery document format APIs. I
used it as a demo project while teaching a short term course on dart to
demonstrate capabilities like type system, analyzer, isolates, running the
same code on server, on client and as CLI app etc. The tools is not ready
for public consumption and this is why you are not finding it on pub.
Post by Doug Reese
I am curious about your swagger_tools package. I don't see it on pub
(yet). I have just started looking into Swagger with respect to Dart.
Doug
Post by Peter StJ
name: swagger_tools
description: Collection of instruments to work with REST API describing
documents.
version: 0.0.1
sdk: '>=1.0.0 <2.0.0'
semver: "^0.2.1"
test: '>=0.12.0 <0.13.0'
args: '^0.13.4'
browser: '>=0.10.0 <0.11.0'
dart_to_js_script_rewriter: '^0.1.0'
# Include transformers for the web test to run
- dart_to_js_script_rewriter
csp: false
sourceMaps: true
checked: false
minify: true
- --trust-type-annotations
- --trust-primitives
pub serve / pub build is used to serve/compile
Post by Edouard Tavinor
Hi!
Can you tell me what's in your pubspec.yaml and how you're compiling the
code?
I'm compiling using dart2js without options and my pubspec.yaml is as
name: 'isolatetest'
version: 0.0.1
description: An absolute bare-bones web app.
#homepage: https://www.example.com
sdk: '>=1.0.0 <2.0.0'
browser: "^0.10.0"
dart_to_js_script_rewriter: '^0.1.0'
- dart_to_js_script_rewriter
Post by Peter StJ
I have successfully used isolates in dart and js from the same source code.
It works fine, the only limitation is that you have to have your url
for worker in web dir because once built the urls for lib change, other
than that it works as expected, use the same URL (for example
'worker.dart') and it is compiled to a separate js executable. I have not
tried to call the worker unit from JS from main thread, I am not sure it
this will work, but calling it from dart from main thread works.
/// Initializes the worker (url is passes static - worker.dart).
Future _initWorker() async {
var uri = Uri.parse(url);
_worker = await Isolate.spawnUri(uri, [], _reciever.sendPort);
_reciever.listen(_handleData);
return null;
}
Interestingly the dart file for worker is not requested, instead the js
<https://lh3.googleusercontent.com/-pA_HEIpiAHA/V904waTBhPI/AAAAAAAAOD4/RLt68vJf-MUepcI9ELH8UKYQ0JktkqTBQCLcB/s1600/Screenshot%2Bfrom%2B2016-09-17%2B15-35-49.png>
Post by Günter Zöchbauer
That loads a Dart script. I doubt this example works in Chrome after
`pub build`.
I guess there is a way to make it work (building the isolate source to
JS as well and change the uri to *.js).
I saw it mentioned that some use isolates in the browser, but no
details how.
To me it looks like this is just experimental with no official support.
Post by Andreas Reiter
Isolate.spawn(...) does not work in the browser, but spawnUri does.
http://stackoverflow.com/a/25104337/4370360
Regards,
Andreas
Post by Günter Zöchbauer
Curious about this as well. Never saw a statement that clearly says
isolate should work in the browser, and how.
Post by Günter Zöchbauer
On Friday, January 1, 2016 at 11:50:15 PM UTC+1, Alec Henninger
Admittedly I have yet to try it out, but I'm curious if anyone
here successfully uses additional isolates in their web app. I have been
reading competing things about isolates WRT dart2js. Seth has said they
compile to web workers, but
https://www.dartlang.org/articles/event-loop/ says "Dart web apps
can't currently create additional isolates, but they can create additional
workers."
Post by Günter Zöchbauer
Do they currently fully map to workers in JS? If not, is it
planned?
Post by Günter Zöchbauer
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Edouard Tavinor
2016-09-13 22:21:58 UTC
Permalink
Im interested in this too. Has anybody got it to work? Code that runs in
Dartium bugs out when compiled to Javascript. Indeed, Isolate.spawnUri
isn't even trying to fetch the file, as far as I can see.
Admittedly I have yet to try it out, but I'm curious if anyone here
successfully uses additional isolates in their web app. I have been reading
competing things about isolates WRT dart2js. Seth has said they compile to
web workers, but https://www.dartlang.org/articles/event-loop/ says "Dart
web apps can't currently create additional isolates, but they can create
additional *workers.*"
Do they currently fully map to workers in JS? If not, is it planned?
Thanks!
Alec
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...