Closed Bug 860805 Opened 11 years ago Closed 5 years ago

geolocation.getCurrentPosition has incorrect timeout failures and requests location sharing too much

Categories

(Core :: DOM: Geolocation, defect)

19 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1283563

People

(Reporter: jeffg, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0
Build ID: 20130307023931

Steps to reproduce:

I am developing a small app using geolocation which runs on all modern browsers except Opera and it runs successfully on all of them except for Firefox 19.  I've tested this code on Windows, Macs, and on iphones (on the latter two i'm only trying webkit based browsers).  The geolocation code works on all of these platforms and browsers except for FF19 on Windows (I've not tried the mac/iphone version of FF).

My app repeatly calls geolocation.getCurrentPosition via setInterval every 5 seconds (as opposed to watchCurrentPosition, which I have no information on, but I see a similar error reported for that api in the mozilla buglist to which the response was 'it works for me').


Actual results:

At some point, which is hard to determine but is always after many many minutes of operation and after multiple priori restarts of the application via refresh, the getCurrentPosition() api will start getting timeout errors from which there is no recovery possible.  Up until this point, the app behaves correctly, and then it goes into this error mode of repeated timeout errors.  A second important observation is that if the app sets the getCurrentPosition() timeout to be large (like 30 seconds), and if I've you set Firefox to confirm each position query (as opposed to automatically allowing them), then you will be asked to confirm repeatedly within the 30second period and yet neither the success or error functions have been called. And then, after the 30 seconds has expired, the error function is called with the timeout error.  But the repeated queries for confirmation without a corresponding call to either the success() or error() functions of getCurrentPosition() is not right and makes no sense.


Expected results:

The api should work repeatedly for long periods (like for hours) after repeated restarts via refresh... and it should only ask to confirm access to location information once per call (or perhaps only once to a domain).

There is something very broken with the geolocation API, and it's not too easy to get it in that mode, but when it does, it's severe.  I can reports related to this in this buglist but they seem to be unaddressed... Please address it!
Can you provide a self-contained, public and reduced Testcase showing the Issue?
Flags: needinfo?(jeffg)
(In reply to XtC4UaLL [:xtc4uall] from comment #1)
> Can you provide a self-contained, public and reduced Testcase showing the
> Issue?

Try this untested code I just wrote for you:
// Test code: extracted from actual code... (not tested!)
// 1. Check out the options in getLocation()
// 2. This just logs to the console, but in the actual failing code, there is an jquery ajax call on
// geolocation success, which may or may not have an effect (just guessing).
// 3. to run:
// 	- let this run untouched for some minutes 
//	- restart the app by refreshing the url. Do this repeatedly... (as if editing the code and testing
//		the results)
//	- repeat above
//	4.note my real app actually calls geolocation using a library rather than exactly as above through
// the navigator object.  Of course, the library might have an issue, but I doubt it... but for
// completeness, here is the the url to it: http://diveintohtml5.info/geolocation.html
// jeffrey greenberg, inventivity.com

function getLocation()
{
	navigator.geolocation.getCurrentPosition(
		gotLocation_cb, 		/* success function */
		gotLocationError_cb,	/* error function */
		/* options: two cases quick and slow. Use quick when trying to induce the FF failure,
		 * then once FF keeps failing with a timeout error (3), restart test with slow option
		 * to see how FF keeps asking for location permission but doesn't call either callback
		 * until the timeout time is hit
		 * */
		{maximumAge: 3000, timeout: 4000, enableHighAccuracy: true }	/* options:  fast default mode*/
		/*{maximumAge: 35000, timeout: 40000, enableHighAccuracy: true }/* options: slow mode for when in failing mode */
		);
}
// success handler
function gotLocation_cb( p ) {
	// my real case does an async ajax call here using jquery... maybe the test needs this...
	// but try this for now
	console.log( "got it: " + p.coords.latititude + ", " + p.coords.longitude);
}
// fail handler
function gotLocationError_cb( e ) { console.log( e.code); }
 
Just run over and over and over ...
geoTask = setInterval( getLocation, 5000 );
Flags: needinfo?(jeffg)
Component: Untriaged → Geolocation
Product: Firefox → Core
most probably a dupe of 1283563
I was using timeout 10000 on my project - fired success, followed by failure in a few seconds
after removing the timeout setting from getCurrentPosition, everything seems to work just fine
Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.