Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

Hi!

I am trying to use the GeoLocation Service - I have set the request parameters as follows :-
maximumAge: 3000
timeout: 5000
enableHighAccuracy: true
watchPosition: false

Those are default values.

If I invoke the service from Firefox (ver 48.0.2.6079 (Latest I think for windows)) then both onsuccess and onfail events are fired in most cases (!).

Google Maps run from the same browser and also my own app (another part of the app) looks up my Geo location without problems. So this is working fine.

But when I call the Geolocation service from my button (via Javascript) it fails to behave as expectet.

Why? I have also seen this problem happen in other browsers and also in a native app we have built.

How can a service fail and in the same time be successfull?
(onComplete event is not used here. Only onsuccess and onfail)

Maybe I should change the parameters for the service but what is recomended values in this scenario?

Best regards

Ole Henrik Oftedal
Timeflex Systemer AS
Norway
https://www.timeflex.no
http://www.timeflex.com

saurabh8122815
Posts: 0
Joined: Mon Mar 21, 2016 5:08 am

Geolocation bug? - both onsuccess and onfail events are executed

hi Ole Henrik Oftedal,

which js code you use on button click event.

Can u show screen shot so that make more clear your problem.

Thanks.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

Sure.

This is my Click event

serviceGeoExecute2(geolocationInn, StempleInnrestservice);

This is my Global function checking if a user switch is on or off:

function serviceGeoExecute2(geolocationservice, normalservice) {
//geolocationservice - services asking for GPS posisjon.
//normalservice service without GPS.
console.log("Localstorage GPSAllowed: " + localStorage.getItem('GPSallowed'));
if ( localStorage.getItem('GPSallowed')==="on") {
console.log("geolocationservice.execute...");
geolocationservice.execute({});
}
else {
console.log("Normal service is run ...");
normalservice.execute({});
}

}

This is StempleInnrestservice

Image

saurabh8122815
Posts: 0
Joined: Mon Mar 21, 2016 5:08 am

Geolocation bug? - both onsuccess and onfail events are executed

Hi Ole Henrik Oftedal.

Thanks for your information.

Can you clarify your function is called or not on Button's click event?

And also clarify that when you test your App on browser does it shows any message on console log that you have wrote here console.log("geolocationservice.execute...");?

You also need to check that your LSV containing any value or not.

Regards.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

Yes of course.

When button is clicked, I have doublechecked that it calls the correct part of the if statement in the javascript function. And that it is only executed once. I can easily view this in Firebug.

Image

I see now that my LSV is correct and my function i called correctly based on that.

I have two servicedefinition with different parameters. Only the one service with GPS coordinates should be called in this scenario. The other one should only be called if app is unable to get GPS position or perhaps timed out.

As you could see in the picture above both servicedefinitions are called. The GPS based first. The second seems to be called some few seconds later.

Maybe I should have a longer timeout in my Geolocation service?

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

I have now changed timeout to 54000 (from 3000). This is 54 seconds. Then I do the same stuff as described earlier.

The service gives success :-) I then start my stopwatch. After about 54 second later the fail event occurs (!).

Is this a bug? How can it both be success and at some time later it fails?

EDIT:
I changed now to this:

maximumAge: 34000
timeout: 54000

Im now testing and first test worked.

What is correct to use?

No :-(

It is not working

saurabh8122815
Posts: 0
Joined: Mon Mar 21, 2016 5:08 am

Geolocation bug? - both onsuccess and onfail events are executed

Hi Ole Henrik Oftedal.

Thanks for your details.

Can you please provides step by step information and also mention that how we can reproduce it.

Let me check by our side.

Regards.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

Aha. When I test my app its from http: and so Google says (when I try in Chrome) that it doesn't work anymore ????

Se picture:
Image

saurabh8122815
Posts: 0
Joined: Mon Mar 21, 2016 5:08 am

Geolocation bug? - both onsuccess and onfail events are executed

Hi Ole Henrik Oftedal.

Thanks for your information.

You need to test your app in firefox browser.

Geolocation service will not work on chrome anymore.

Regards.

Ole Henrik Oftedal
Posts: 0
Joined: Thu Apr 19, 2012 4:52 pm

Geolocation bug? - both onsuccess and onfail events are executed

Hi and sorry for the delay. I had to make a new demo for you.

This I have now shared with support. (user is ole-oft at online.no name of app is "geolocationbug")

How to use:

Start app and hit the button. A very simply service is run returning date time and name of database and so on. Each time you hit the button my gelocation1 service is run. If success I fire my service. If it fails it wil display error. Watch the time returned from the service when you hit the button. Every now and then then Geolocation service returns both success (you see the time is changing) and also failure as you get my alert made in javascript as seen in picture. Good luck :-)

Remark: Never mind the time. It is hardcoded to Geneva,Rome,Berlin time :-)

Image

Return to “Issues”