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

Unable to import poly2tri.js script in web worker script. #35

Closed
GoogleCodeExporter opened this issue Oct 24, 2015 · 7 comments
Closed

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Create Web worker script.
2. Use importScripts() to import poly2tri.js in onmessage() of worker.
3. In chrome (on F12), you can see the error as "Uncaught ReferenceError: 
window is not defined"

What is the expected output? What do you see instead?
Script should get loaded. But failing to load script.

What version of the product are you using? On what operating system?
Windows 7, Google chrome 16.0.912.63 m

Please provide any additional information below.
Please see the below code for main script and worker script.

//main script file.

//callback function for web worker.
function callback(event) {
    console.log(event.data);
}
var w = new Worker('task.js');
w.onmessage = callback;
w.postMessage("Hi"); // call worker.


//task.js file
self.onmessage = function(event) {
    importScripts('poly2tri.js'); // load the poly2tri utility.
    this.postMessage("Hello");
};



Original issue reported on code.google.com by mahesh4c...@gmail.com on 20 Dec 2011 at 12:39

@GoogleCodeExporter
Copy link
Author

I am unable to find use of "window" object in poly2tri.js file :( 
Is there use of "window" object for this utility ?

Original comment by mahesh4c...@gmail.com on 20 Dec 2011 at 12:41

@GoogleCodeExporter
Copy link
Author

Sorry the actual error is "Uncaught ReferenceError: Namespace is not defined"

Original comment by mahesh4c...@gmail.com on 20 Dec 2011 at 12:56

@GoogleCodeExporter
Copy link
Author

I'm sorry the javascript port was not written by any of the authors of this lib 
but simply ported by a user. So can't really help you since I've never worked 
with javascript myself.

You might try to ask the original javascript porter if he have any insights.
http://code.google.com/p/poly2tri/issues/detail?id=5&can=1

Original comment by thahlen@gmail.com on 20 Dec 2011 at 11:39

@GoogleCodeExporter
Copy link
Author

Original comment by thahlen@gmail.com on 5 Jan 2012 at 11:03

  • Changed state: WontFix

@GoogleCodeExporter
Copy link
Author

got workaround for this:
remove the use of "Namespace"; instead use like MyNameSpace = MyNameSpace || {};
this solves the issue.

Original comment by mahesh4c...@gmail.com on 6 Jan 2012 at 5:15

@GoogleCodeExporter
Copy link
Author

Thanks for posting the solution to your problem :)

Original comment by thahlen@gmail.com on 6 Jan 2012 at 11:08

@GoogleCodeExporter
Copy link
Author

see change in issue 68 : Namespace.js dependency is now optional    

Original comment by remi.tur...@gmail.com on 14 Mar 2013 at 8:51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant