Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Rcjuk
Posts: 62
Registered: ‎04-29-2010
My Device: N/A

JavaScript execution exceeded timeout after geolocation error

Weird one this but I've knocked up a quick little app with a button. When press it goes through a loop 1000 times and console.logs the number so you can see it via web inspector. You can run this as many times as you want without fail and this will complete. Everything works fine until you throw geolocation into the mix.

 

Basically, when the page loads it sets up the watch (navigator.geolocation.watchPosition). Since I am inside this watch is failing to find my position and is producing an error which is handled by the error callback. As soon as this error is generated however, you rerun the loop code and it fails halfway through and produces "JavaScript execution exceeded timeout" as an error in the web inspector. 

 

Any body seen this?

 

<!DOCTYPE HTML>
<HTML>
<HEAD>
</HEAD>
<BODY onload="get_pos();">
<P>HELLO</P>
<button onclick="testfunc();">Run</button>
</BODY>
<SCRIPT>
var test='';

function geo_error(error)
{
	var errors = {
		1: 'Permission denied',
		2: 'Position unavailable',
		3: 'Request timeout'
	};
	console.log(error);
	navigator.geolocation.clearWatch(test);
}

function get_pos()
{
	try
	{
		test = navigator.geolocation.watchPosition(geo_success, geo_error, {
			enableHighAccuracy: true,
			maximumAge: 600000,
			timeout: 30000
		});
	}
	catch (err)
	{
		console.log(err);
	}
}

function geo_success(position)
{
	/*"use strict";*/
	try
	{
		lat = position.coords.latitude;
		longitude = position.coords.longitude;
	}
	catch (err)
	{
		console.log(err);
	}
}

	
function testfunc(){
	alert('step 1');
	var keycount=1000;
	for (var i=0; i<keycount; i++) {
		console.log(i);
	}
	alert('step 2');
}
</SCRIPT></HTML>

 

Please use plain text.
Developer
Rcjuk
Posts: 62
Registered: ‎04-29-2010
My Device: N/A

Re: JavaScript execution exceeded timeout after geolocation error

<!DOCTYPE HTML>
<HTML>
<HEAD>
</HEAD>
<BODY onload="">
<P>HELLO</P>
<button onclick="get_pos()">Run</button>
</BODY>
<SCRIPT>
function geo_error(error)
{
	console.log(error);
}

function get_pos()
{
		navigator.geolocation.getCurrentPosition(
			    geo_success,
			    geo_error,
			    {timeout: 5000, enableHighAccuracy: true}
		);
		setTimeout(get_pos, 10000);
}

function geo_success(position)
{
console.log(new Date()+': '+position.coords.latitude+','+position.coords.longitude);
}

</SCRIPT></HTML>

 Here's another little test app. If you fire this up and click run, the app will eventually crash out with no error after about ten minutes. Interestingly, if you set  "enableHighAccuracy: false" it works fine and never crashes. All these tests use a Curve 9360 on 7.1.

 

 

Please use plain text.
Developer
Rcjuk
Posts: 62
Registered: ‎04-29-2010
My Device: N/A

Re: JavaScript execution exceeded timeout after geolocation error

[ Edited ]

Same behaviour on a 7.1 9860 device for both of these issues.

Please use plain text.
New Developer
dpicky
Posts: 57
Registered: ‎08-08-2008
My Device: Not Specified

Re: JavaScript execution exceeded timeout after geolocation error

We have built this same app in Phonegap and it doesn't crash.  Begs the question, what is Phonegap doing differently to WebWorks?  It was my understanding that Phonegap uses WebWorks SDK, so could it be they use a different API for geolocation?

 

More investigation going on, but anyone elses feedback would be appreciated.

 

 

Please use plain text.
New Developer
dpicky
Posts: 57
Registered: ‎08-08-2008
My Device: Not Specified

Re: JavaScript execution exceeded timeout after geolocation error

Looking at the Phonegap source, it appears it implements it's own gelocation stuff via Java and doesn't use the browser/webkit HTML5 implementation of gelocation.  Therefore, it looks like the browser geolocation stuff is broke and will get it logged on the dev issue tracker.

Please use plain text.
Contributor
mikebevz
Posts: 17
Registered: ‎04-19-2012
My Device: Torch
My Carrier: Telenor Denmark

Re: JavaScript execution exceeded timeout after geolocation error

I've got same issue. Did you guys solve it somehow?

Please use plain text.
Developer
Rcjuk
Posts: 62
Registered: ‎04-29-2010
My Device: N/A

Re: JavaScript execution exceeded timeout after geolocation error

Not yet. We did some more testing with Phonegap and the issue is present there also. Basically, you set 'location on' on the blackberry and as soon as it errors when it can't get a location it starts to fail. This is a pretty big problem for us as there's no way of getting the location at the minute.
Please use plain text.
New Developer
dpicky
Posts: 57
Registered: ‎08-08-2008
My Device: Not Specified

Re: JavaScript execution exceeded timeout after geolocation error

Just to add I've logged on the development issue tracker, but not heard anything yet.

 

Come on RIM guys we need this to work.

Please use plain text.
Developer
Hithredin
Posts: 400
Registered: ‎06-03-2010
My Device: Z10 Red
My Carrier: Free

Re: JavaScript execution exceeded timeout after geolocation error

Can you provide a link to your tracker?

 

I got the same problem. I notice it happens only when the device do not find the geolocation: the timeout is somewhat not respected and it still runs.

That cause "Previous instance still running" pop-up even if my app is reality closed, and any webworks app that use geolocation will completly crash when starting geolocation.

Please use plain text.
New Developer
dpicky
Posts: 57
Registered: ‎08-08-2008
My Device: Not Specified

Re: JavaScript execution exceeded timeout after geolocation error

Please use plain text.