web worker threads have functional ajax but callback function not working.

RESOLVED INVALID

Status

()

RESOLVED INVALID
7 years ago
7 years ago

People

(Reporter: ericjang2004, Unassigned)

Tracking

10 Branch
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

7 years ago
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.
Status: UNCONFIRMED → NEW
Ever confirmed: true
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

7 years ago
Created attachment 582167 [details]
zip file containing Google App Engine project and sample data
(Reporter)

Comment 3

7 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
> 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
Last Resolved: 7 years ago
Resolution: --- → INVALID
Though it's not clear to me whether that's the canonical source for hive.pollen
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

7 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

7 years ago
filed the bug, rwaldron agrees! hooray!
> 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
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.