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

js-interop call in isolate compiled via dart2js throws Uncaught Instance of 'UnknownJavaScriptObject' #14072

Closed
DartBot opened this issue Oct 14, 2013 · 4 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-js type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Oct 14, 2013

This issue was originally filed by ross.dart.la...@gmail.com


0.8.1_r28355
Windows 7x64

I am using spawnFunction from dart:isolate to attempt to offload some expensive work from my ui thread. This expensive work needs to make some js-interop calls, but it blows up on the first such call with:

Uncaught Instance of 'UnknownJavaScriptObject'
ReferenceError: window is not defined
    at ReceivePortSync.receive$1 (...)
    at _ProxiedObjectTable._ProxiedObjectTable$0 (...)
    at Object._ProxiedObjectTable.static._ProxiedObjectTable$ (...)
    at Isolate.prototype.(anonymous function) (...)
    at Object._enterScopeIfNeeded (...)

The offending code looks like:

ReceivePortSync: {"": "Object;_portId@-,_callback@-,_portSubscription@-",
  _callback$1: function(arg0) {
    return this._callback.call$1(arg0);
  },
  _callback$0: function() {
    return this._callback.call$0();
  },
  get$_listenerName: function() {
    var t1, t2;
    t1 = W.ReceivePortSync__isolateId();
    t2 = this._portId;
    return "dart-port-" + H.S(t1) + "-" + H.S(t2);
    "18";
  },
  "+_listenerName": 1,
  receive$1: function(callback) {
    var t1, t2, t3;
    this._callback = callback;
    if (this._portSubscription == null) {
      t1 = window; // THIS IS THE PROBLEM
      t2 = W.ReceivePortSync__isolateId();
...

I spent some time trying to figure out precisely where this is coming from but did not succeed. Can I use dart:js instead of js-interop to avoid this, or is it somewhere deeper?

thanks,

@kasperl
Copy link

kasperl commented Oct 14, 2013

cc @justinfagnani.
Added Area-Library, Library-JS, Triaged labels.

@justinfagnani
Copy link
Contributor

Ross, package:js now uses dart:js and doesn't use sync ports, so it's likely that this is fixed. Can you confirm?


Set owner to @justinfagnani.
Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Oct 31, 2013

This comment was originally written by ross.dart.lan...@gmail.com


Hi Justin,

I downloaded a bleeding_edge SDK (r29643) to try and confirm but I seem to be stuck.

  1. spawnFunction now throws an UnsupportedError that it cannot be called from the main DOM isolate :(
  2. spawnUri let's me run a dart script, but how can I get any javascript into the context?

Is there something like importScripts available to load the javascripts that I need? (https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers#Importing_scripts_and_libraries)

At the moment I feel a bit stuck in regards to offloading work from my main (DOM) thread. I'd like to just use a web worker but that means re-writing a lot of my code in javascript :(

thanks,

@DartBot
Copy link
Author

DartBot commented Oct 31, 2013

This comment was originally written by ross.dart...@gmail.com


Upon further thought, I'm not really sure that I have a valid use case anymore, so feel free to close this. When I originally opened this issue I wanted to make a chrome.* API call from the worker, but I have since learned that is not possible.

Whether or not there may be valid use cases, I'm not sure.

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-js labels Oct 31, 2013
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
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-js type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants