Closed
Bug 711286
Opened 13 years ago
Closed 13 years ago
web worker threads have functional ajax but callback function not working.
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: ericjang2004, Unassigned)
References
()
Details
Attachments
(1 file)
78.10 KB,
application/octet-stream
|
Details |
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0a2) Gecko/20111215 Firefox/10.0a2 Build ID: 20111215042030 Steps to reproduce: I have a web app hosted on Google App Engine that uses Web Workers to compute a value, then returns it back to the server. I navigated to http://montecarlo-tester.appspot.com/ and clicked 'Run Worker' to start the javascript. Actual results: the web worker does soemthing wrong and all the values inside the worker become 0. Expected results: If http://montecarlo-tester.appspot.com/ is visited in a Webkit-based browser, it works perfectly.
Reporter | ||
Updated•13 years ago
|
Updated•13 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment 1•13 years ago
|
||
I confirmed the behavior, but it's hard to debug because a saved copy of the page doesn't work. Could you provide a zip with the files needed to run the test, or better yet, a reduced test case? When I run the site directly, in the developer console I get: [18:22:43.745] received data from webworker! @ http://montecarlo-tester.appspot.com/:79 [18:22:43.747] undefined undefined NaN @ http://montecarlo-tester.appspot.com/:84 so the receive method is getting called, but the expected data is not there. It might be informative if you logged |uneval(event)| or something like that at the start of the method.
Reporter | ||
Comment 2•13 years ago
|
||
Reporter | ||
Comment 3•13 years ago
|
||
I have another application that ran into a similar problem, where webkit-based browsers work and firefox doesn't. I am unable to package this particular program (due to restrictive XHR access from a certain domain) but I believe that Firefox's web workers have different rules regarding scope of variables. For example, in a different program: importScripts("/static/js/lib/glMatrix.js","/static/js/lib/jquery.hive.pollen.js","/static/js/lib/ChemDoodleWeb-unpacked-reduced-mod.js"); var fetchedmolecule;//a global object $(function (data) { main(data); close(); }); function main(data) { ChemDoodle.iChemLabs.readSMILES('N1(C)C(=O)N(C)C(C(=C1N1)N(C=1)C)=O', function(mol){ fetchedmolecule = mol; }); var result = { "x":fetchedmolecule.atoms[0].x, "y":fetchedmolecule.atoms[0].y, "z":fetchedmolecule.atoms[0].z }; $.send(result); } Chrome works just fine but Firefox reports: fetchedmolecule is undefined
Comment 4•13 years ago
|
||
> static/js/lib/jquery.hive.pollen.js
This browser-sniffs and runs different code in Gecko and in Safari/Chrome. In particular, it defaults to sync XHR in Safari/Chrome and async XHR in all other browsers. I'll bet money that's all you're seeing there, though I'd have to look at what readSMILES actually does to make sure.
And for that matter, your montecarlo thing has the same problem. It does a hive.pollen ajax.post and assumes that once the call returns the success callback has run. This will be true in Safari/Chrome but not in any other browser, due to the sniffing I mention above.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Comment 5•13 years ago
|
||
For what it's worth, I filed http://code.google.com/p/thermetics-forum-extensions/issues/detail?id=32 and http://code.google.com/p/thermetics-forum-extensions/issues/detail?id=33
Comment 6•13 years ago
|
||
Though it's not clear to me whether that's the canonical source for hive.pollen
Comment 7•13 years ago
|
||
Perhaps the right place is https://github.com/rwldrn/jquery-hive/issues Looks like that needs a github account to report a bug... :(
Reporter | ||
Comment 8•13 years ago
|
||
I made a couple changes to hive.pollen to maintain compatibility with the chemdoodle js library, but nothing related to the async/sync bit. Thanks for the tip! I replaced the weird user-agent checking feature with sync: false and now it works across both Gecko and Webkit. That's a bit counterintuitive though, shouldn't it be sync: true because async is causing problems?
Resolution: INVALID → WORKSFORME
Reporter | ||
Comment 9•13 years ago
|
||
filed the bug, rwaldron agrees! hooray!
Comment 10•13 years ago
|
||
> shouldn't it be sync: true If hive.pollen were sane, yes. But it's not. See https://github.com/rwldrn/jquery-hive/issues/8
Resolution: WORKSFORME → INVALID
Comment 11•13 years ago
|
||
Or more precisely "wasn't", since rwaldron just fixed it.
You need to log in
before you can comment on or make changes to this bug.
Description
•