Skip to content
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

Simple echo isolate fails to work when compiled to JavaScript #2289

Closed
sethladd opened this issue Mar 24, 2012 · 8 comments
Closed

Simple echo isolate fails to work when compiled to JavaScript #2289

sethladd opened this issue Mar 24, 2012 · 8 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-isolate

Comments

@sethladd
Copy link
Contributor

This simple isolates example:

import('dart:isolate');

echo() {
  port.receive((msg, reply) => reply.send("Echo: $msg"));
 }

 void main() {
  SendPort sendPort = spawnFunction(echo);
  sendPort.call("Hello, Dart!").then((response) => print(response));
 }

fails to work when compiled to JavaScript. My version of Frog is perhaps a week old, so perhaps it works in the latest and greatest? However, there's another bug with absolute latest Frog so I can't test with bleeding edge.

@sethladd
Copy link
Contributor Author

Sorry, here's the errors:

Uncaught Error: SECURITY_ERR: DOM Exception 18

_IsolateNatives._newWorker = function(url) {
  return new Worker(url);
Uncaught Error: SECURITY_ERR: DOM Exception 18
}

I've attached the offending JS file.


Attachment:
isolates2.dart.js (75.92 KB)

@DartBot
Copy link

DartBot commented Mar 25, 2012

This comment was originally written by zanekam...@gmail.com


Same problem for me, in both the "stabler" SDK and the bleeding edge one, as of right now.

@sigmundch
Copy link
Member

This might be a problem in how you are loading the HTML file in your browser. In particular, are you loading it directly (e.g. a file:/// url) and the .js file is a relative path?

If so, you might be running into browser restricted permissions. Creating a worker requires a url to the script to run in the worker, we derive this url from the original script you use in the page. Browsers like chrome doesn't allow by default creating a worker to a script that sits in your file system (e.g. a file:/// url).

There are a couple ways to work around this:

  • if you are using chrome, you can pass '--allow-file-access-from-files' when launching it.
  • you can also set up a tiny websever and load the page from it.

@DartBot
Copy link

DartBot commented Mar 26, 2012

This comment was originally written by zanekam...@gmail.com


Nope. I'm running from Visual Studio 2010's integrated web server.

@sigmundch
Copy link
Member

  • Which browser are you using?
  • What is the value of 'url' before the call to 'new Worker(url)'?

@DartBot
Copy link

DartBot commented Mar 26, 2012

This comment was originally written by zanekami...@gmail.com


I tested in the latest version of Chrome. Dunno the version number; I'll
check that in a bit.

I'll also look into the worker url thing, too. How can I check on that?
Should I just add some debugging code to the complied JS?

@sigmundch
Copy link
Member

Adding debugging code to the compiled JS should be enough. You can also set a breakpoint on that line with the debugger (chrome developer tool) and reload the page afterwards.

@dgrove
Copy link
Contributor

dgrove commented Jun 1, 2012

This is using the old isolate API, which is no longer supported.


Added AssumedStale label.

@sethladd sethladd added Type-Defect closed-obsolete Closed as the reported issue is no longer relevant labels Jun 1, 2012
@nex3 nex3 added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Jun 8, 2015
dart-bot pushed a commit that referenced this issue Jan 16, 2020
New commits included in this revision:
```
$ git log --pretty=oneline 4d8ecbd409d773fec47da33b7e6c8db0b51487fd..429a06039d185149f387a65e3503b0693ce6d24e
429a06039d185149f387a65e3503b0693ce6d24e (HEAD -> master, origin/master, origin/HEAD) Parallel fetching of available versions (#2280)
6705b085b9bf4754a4c8002a070f436f115dc4d1 Retry on all SocketExceptions (#2254)
a1820273b9f3c7bb5a13d26cd14d30d5bab187ae Use a unqiue file name for the snapshot during testing. (#2303)
72686563e767f8a359e48a267a2c323953a6a0ef Include osx and windows testing on Travis (#2299)
a7a66821d13920b9b22cc394dfa55c679e971e40 Fail travis for lints and warnings (#2301)
25aa24c023453f064dad8f3cce1bbd55269d0efa Omit languageVersion when there is no SDK constraint (#2300)
82e60a3dcb3afe753563e7d304827fb650bc4833 Use LOCALAPPDATA for system cache on windows (#2297)
ceaa86f2c7eb35f044b4c202268a17361de68d13 Enforce and fix lints from package:pedantic (#2291)
6ce1606564352c305bd0f6d97704f0f7f6ebbca0 Use more collection literals for args (#2293)
be245e6baeebb71aaf3b3a260fcfbbb011a9a7e0 Rename some test utilities from Mock to Fake (#2294)
f7638ce85298df7d9e73d717dd4d81f499681720 Refactor Set.add following !Set.contains (#2295)
390022b24bc076cb934385936ac7904f045a75ba Filter out `null` from `getCachedPackages`. (#2292)
0eea0c4421ed0b83c8597b62dacf68b93de172b9 Fix existing hints and lints (#2290)
7cf2fe860a40517ccb65f5efdda9e4dc350142c3 promote strict deps failures to errors from warnings (#2289)
```

Change-Id: I62782b29e16092114940df00811bfdd20c8045fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131839
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-isolate
Projects
None yet
Development

No branches or pull requests

5 participants