javascriptsafarigeolocationw3c-geolocation

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


Solution

  • 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/