Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geolocation API in Safari 8 and 7.1 keeps asking permission

I've built the Geolocation API into my webapp and all browsers are working fine. Except Safari 8 and 7.1. The browser keeps asking for permission after allowing or not allowing it and ends up in an infinite loop making the browser (tab) unusable. It's easily reproducible by just going to http://html5demos.com/geo in Safari.

Is there any fix for this or is this just a bug in Safari? I searched but couldn't find anything related.

enter image description here

like image 998
Gregory Bolkenstijn Avatar asked Nov 26 '14 13:11

Gregory Bolkenstijn


2 Answers

Our team saw this too. At first we thought we might have been stuck inside some kind of loop that the other browsers ignored, so we instrumented the code and confirmed that the call was only happening once. We suspended JavaScript by forcing a breakpoint and the alerts kept coming (and coming, and coming...). At this point we were pretty sure the issue was not in our code.

On a whim I placed the call to the GeoLocation API inside a setTimeout (to allow the call stack to empty) and the problem went away. No idea why that would fix the issue. . .

Edit

Per request, I put up an example @ https://jsfiddle.net/r8hst2zp/1/

like image 165
Chris Camaratta Avatar answered Oct 22 '22 18:10

Chris Camaratta


i don't think it is a bug in safari, you can try the following example, it worked fine for me:

http://www.w3schools.com/html/html5_geolocation.asp

like image 42
MeMTn Avatar answered Oct 22 '22 20:10

MeMTn