Skip to content

spawnFunction does not work when compiled to JavaScript #9493

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
sethladd opened this issue Mar 28, 2013 · 6 comments
Closed

spawnFunction does not work when compiled to JavaScript #9493

sethladd opened this issue Mar 28, 2013 · 6 comments
Labels
closed-duplicate Closed in favor of an existing report P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js
Milestone

Comments

@sethladd
Copy link
Contributor

Consider this code:

import 'dart:html';
import 'dart:isolate';

void main() {
  var elem = query("#sample_text_id");
  var port = spawnFunction(runInIsolate);
  port.call('go!').then((msg) => elem.text = msg);
}

runInIsolate() {
  port.receive((msg, SendPort replyTo) {
    replyTo.send('hello from isolate');
  });
}

This works in Dartium, but not when compiled to dart2js

I've attached the necessary files. Please unzip and then run 'pub install' to clean up all the symlinks.

Using Dart Editor version 0.4.3_r20515

When I open the console in Chrome, I see:

Uncaught ReferenceError: window is not defined


Attachment:
spawnStuff.zip (47.94 KB)

@sethladd
Copy link
Contributor Author


Attachment:
[Screen Shot 2013-03-28 at 10.01.53 AM.png](https://storage.googleapis.com/google-code-attachments/dart/issue-9493/comment-1/Screen Shot 2013-03-28 at 10.01.53 AM.png) (59.09 KB)

@DartBot
Copy link

DartBot commented Mar 28, 2013

This comment was originally written by [email protected]


Set owner to [email protected].
Added Accepted label.

@sethladd
Copy link
Contributor Author

Thanks Nicolas!


Added this to the M4 milestone.
Removed Priority-Medium label.
Added Priority-High, C2 labels.

@DartBot
Copy link

DartBot commented Apr 1, 2013

This comment was originally written by [email protected]


This is actually a duplicate of https://code.google.com/p/dart/issues/detail?id=8455. An easy workaround for now is to avoid web workers by using 'spawnDomFunction' instead of 'spawnFunction.


Added Duplicate label.
Marked as being merged into #8455.

@sethladd
Copy link
Contributor Author

sethladd commented Apr 1, 2013

Thanks for de-duping. spawnDomFunction doesn't run concurrently (as is my understanding...)

@DartBot
Copy link

DartBot commented Apr 7, 2013

This comment was originally written by [email protected]


Indeed, spawnDomFunction does not work concurrently. Nor is spawnFunction without web workers.

@sethladd sethladd added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js closed-duplicate Closed in favor of an existing report labels Apr 7, 2013
@sethladd sethladd added this to the M4 milestone Apr 7, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js
Projects
None yet
Development

No branches or pull requests

2 participants