You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/05/24 14:07:05 UTC

[GitHub] [cordova-plugin-geolocation] ninaDeimos opened a new issue #155: Timestamp of getCurrentPosition wrong? (iOS 12)

ninaDeimos opened a new issue #155: Timestamp of getCurrentPosition wrong? (iOS 12)
URL: https://github.com/apache/cordova-plugin-geolocation/issues/155
 
 
   # Bug Report
   
   ## Problem
   
   When comparing the timestamps of the object returned by the geolocation plugin, we found that the timestamps are from **before** the call to the _getCurrentPosition_ function.
   We log 
   
   - the time when we make the request to _getCurrentPosition_
   
   - the timestamp returned by the geolocation.
   
   ### What is expected to happen?
   
   The timestamp of the geolocation-object should be **newer** than the timestamp that we log before the call to the plugin is made.
   
   ### What does actually happen?
   
   The timestamp of the geolocation-object is most of the times (not consistently) **older** than the timestamp that we log before the call to the plugin is made.
   Example:
   Timestamp_Call - Timestamp_GPS
   15:45:28.475 - 15:45:28.466
   
   The question is: Is the timestamp wrong or does the plugin return a value coming from an older call to _getCurrentPosition_?
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   
   Our options are:
   timeout: Infinity,
   maximumAge: 0,
   enableHighAccuracy: true
   
   I checked this on a trivial app containing no other plugins.
   In the browser we observe the expected behaviour with the timestamp of the GPS position being slightly newer than the timestamp of the call.
   Example:
   Timestamp_Call - Timestamp_GPS
   15:45:0.241 - 15:45:0.276
   
   I deployed it via Xcode and ran it directly on the device.
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   App component:
   `import { Component, ViewChild } from '@angular/core';
   import { Nav } from 'ionic-angular';
   
   @Component({
     templateUrl: 'app.html'
   })
   export class MyApp {
   
     @ViewChild(Nav) nav: Nav;
   
     private _timer;
     private readStartTimestamp;
     private log = [];
   
     ngOnInit() {
       this._startWatchingPosition();
   }
   
     _getCurrentPosition() {
         this.readStartTimestamp = new Date();
         navigator.geolocation.getCurrentPosition((position) => {
           (<any>position).gpsStartTimestamp = this.formatDate(this.readStartTimestamp);
           (<any>position).gpsTimestamp = this.formatDate(new Date(position.timestamp));
           this.log.push(position);
         }, (err) => {
           console.log("Error getting current location: " + err.message);
         }, {
             timeout: Infinity,
             maximumAge: 0,
             enableHighAccuracy: true
         });
     }
   
     _startWatchingPosition() {
         clearInterval(this._timer);
         this._getCurrentPosition();
         this._timer = setInterval(() => {
           this._getCurrentPosition();
         }, 5000);
         console.log("Watching position started");
     };
   
     private formatDate(date: Date) {
       return date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds() + '.' + date.getMilliseconds();
     }
   }
   `
   App template:
   `<ion-content>
   
     <h1>TESTAPP Geolocation Plugin</h1>
     <div style="padding: 10px;overflow: scroll; -webkit-overflow-scrolling: touch; user-select: text; -webkit-user-select: text" id="text">
         <ion-item *ngFor="let position of log.slice().reverse()">
             {{position.gpsStartTimestamp}} - {{position.gpsTimestamp}} - {{position.coords.longitude}} / {{position.coords.latitude}}
         </ion-item>
     </div>
   </ion-content>`
   
   If necessary, I can provide a sample project, but it really only consists of these two files + bootstrapping.
   
   cordova add platform ios
   cordova prepare ios
   Run with Xcode on iOS Device
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   
   I tested it on iOS 12.1 (iPhone) and 12.3 (iPad), both showing the mentioned behaviour.
   I didn't test it on Android.
   The browser does not show the mentioned behaviour, but behaves as expected.
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   cordova platform ls
   Installed platforms:
     ios 5.0.1
   
   cordova plugin ls
   cordova-plugin-geolocation 4.0.1 "Geolocation"
   
   cordova --version
   9.0.0 (cordova-lib@9.0.1)
   
   from package.json:
   "cordova-ios": "5.0.1",
   "cordova-plugin-geolocation": "4.0.1",
   "ionic-angular": "3.9.6"
   
   ionic --version
   4.10.2
   
   OSX 10.14.5
   Xcode 10.2.1
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org