You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Kuan Yi Ming (JIRA)" <ji...@apache.org> on 2013/04/17 18:01:17 UTC

[jira] [Updated] (CB-3053) Geolocation API sometimes returns outdated GPS coordinates when called after resume event

     [ https://issues.apache.org/jira/browse/CB-3053?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kuan Yi Ming updated CB-3053:
-----------------------------

    Description: 
On iOS, calling getCurrentPosition after resuming the app from the background sometimes will return the old coordinates from an earlier getCurrentPosition call prior to backgrounding the app.

Tested on simulator and on an iPhone 4.

On the simulator, this happens all the time. On a physical device, it can be replicated the first handful of calls but not after that (may have something to do with not getting GPS satellite lock right away?)

This is probably only iOS specific as this can't be replicated whatsoever on a Galaxy Nexus with Location Services turned on, but GPS satellites are disabled.

Javascript code:
{quote}
function onBodyLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
    document.addEventListener("resume", onResume, false);
    navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
}
function onResume() {
    navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
}
function onGetFollowMeSuccess(position) {
    alert("Lat: " + position.coords.latitude + ", Long: " + position.coords.longitude);
}
function onGetFollowMeError() {
    alert("Whoops-a-daisy.");
}
{quote}

HTML code:
{quote}
<!DOCTYPE html>
<html>
    <head>
        <title>Geo Loco</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <meta charset="utf-8" />
        <script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script>
        
        <script type="text/javascript" charset="utf-8" src="main.js"></script>
    </head>
    
    <body onload="onBodyLoad()">
        Geo Loco
    </body>
</html>
{quote}

  was:
On iOS, calling getCurrentPosition after resuming the app from the background sometimes will return the old coordinates from an earlier getCurrentPosition call prior to backgrounding the app.

Tested on simulator and on an iPhone 4.

On the simulator, this happens all the time. On a physical device, it can be replicated the first handful of calls but not after that (may have something to do with not getting GPS satellite lock right away?)

This is probably iOS specific as this can't be replicated whatsoever on a Galaxy Nexus with Location Services turned on, but GPS satellites are disabled.

Javascript code:
{quote}
function onBodyLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
    document.addEventListener("resume", onResume, false);
    navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
}
function onResume() {
    navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
}
function onGetFollowMeSuccess(position) {
    alert("Lat: " + position.coords.latitude + ", Long: " + position.coords.longitude);
}
function onGetFollowMeError() {
    alert("Whoops-a-daisy.");
}
{quote}

HTML code:
{quote}
<!DOCTYPE html>
<html>
    <head>
        <title>Geo Loco</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <meta charset="utf-8" />
        <script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script>
        
        <script type="text/javascript" charset="utf-8" src="main.js"></script>
    </head>
    
    <body onload="onBodyLoad()">
        Geo Loco
    </body>
</html>
{quote}

    
> Geolocation API sometimes returns outdated GPS coordinates when called after resume event
> -----------------------------------------------------------------------------------------
>
>                 Key: CB-3053
>                 URL: https://issues.apache.org/jira/browse/CB-3053
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: 2.5.0, 2.6.0
>         Environment: iOS 6. Tested in simulator & iPhone 4
>            Reporter: Kuan Yi Ming
>            Assignee: Shazron Abdullah
>
> On iOS, calling getCurrentPosition after resuming the app from the background sometimes will return the old coordinates from an earlier getCurrentPosition call prior to backgrounding the app.
> Tested on simulator and on an iPhone 4.
> On the simulator, this happens all the time. On a physical device, it can be replicated the first handful of calls but not after that (may have something to do with not getting GPS satellite lock right away?)
> This is probably only iOS specific as this can't be replicated whatsoever on a Galaxy Nexus with Location Services turned on, but GPS satellites are disabled.
> Javascript code:
> {quote}
> function onBodyLoad() {
>     document.addEventListener("deviceready", onDeviceReady, false);
> }
> function onDeviceReady() {
>     document.addEventListener("resume", onResume, false);
>     navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
> }
> function onResume() {
>     navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess, onGetFollowMeError);
> }
> function onGetFollowMeSuccess(position) {
>     alert("Lat: " + position.coords.latitude + ", Long: " + position.coords.longitude);
> }
> function onGetFollowMeError() {
>     alert("Whoops-a-daisy.");
> }
> {quote}
> HTML code:
> {quote}
> <!DOCTYPE html>
> <html>
>     <head>
>         <title>Geo Loco</title>
>         <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
>         <meta charset="utf-8" />
>         <script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script>
>         
>         <script type="text/javascript" charset="utf-8" src="main.js"></script>
>     </head>
>     
>     <body onload="onBodyLoad()">
>         Geo Loco
>     </body>
> </html>
> {quote}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira