The exception was thrown when I used

navigator.geolocation.watchPosition

 

Changed it to:

function getLocation() {
            navigator.geolocation.getCurrentPosition(updatePos, locationError, { enableHighAccuracy: true, timeout: 10000 });
        }

        var intervalID = window.setInterval(getLocation, 10000);

and then it worked