transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Debug version doesn't work? #957

Closed HarelM closed 4 years ago

HarelM commented 4 years ago

Your Environment

Expected Behavior

It should ask for GPS permissions and show GPS location or at least report an error

Actual Behavior

Nothing happens - the ready success callback is never called, nor the error callback...

Steps to Reproduce

  1. Basically use the code described in the manual

Context

I'm trying to figure out if it's worth the effort of migrating to this software in order to facilitate for background recording.

Debug logs

Not sure how to produce them

Code can be found here, this code is before the required migration: https://github.com/IsraelHikingMap/Site/blob/master/IsraelHiking.Web/sources/application/services/geo-location.service.ts I want to migrate the code to this library assuming it will solve the issue described here: https://github.com/IsraelHikingMap/Site/issues/1039

christocracy commented 4 years ago
$ cordova plugins
HarelM commented 4 years ago
cc.fovea.cordova.openwith 1.0.0 "OpenWith"
cordova-android-play-services-gradle-release 2.1.0 "cordova-android-play-services-gradle-release"
cordova-background-geolocation-lt 3.0.8 "BackgroundGeolocation"
cordova-plugin-background-fetch 5.5.0 "CDVBackgroundFetch"
cordova-plugin-camera 4.0.3 "Camera"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-inappbrowser 3.0.0 "InAppBrowser"
cordova-plugin-insomnia 4.3.0 "Insomnia (prevent screen sleep)"
cordova-plugin-ionic-webview 4.1.1 "cordova-plugin-ionic-webview"
cordova-plugin-whitelist 1.3.4 "Whitelist"
cordova-sqlite-ext 3.0.0 "Cordova sqlite storage plugin with extra features"

I have create a branch in case you would like to debug it: https://github.com/IsraelHikingMap/Site/tree/issue-1039 You can clone it, go to IsraelHiking.Web run: npm install npm run build:cordova-watch npm run add-android npm run run-android After the app loads click the cross-hairs icon on the left side... Let me know if I did something wrong... As I said in my comment above the relevant class is GeoLocationService.

christocracy commented 4 years ago
HarelM commented 4 years ago

Thanks for the quick reply! @christocracy it will be much more productive if you could make the branch I linked work locally on your PC and you'll have all the data you need...

HarelM commented 4 years ago

@christocracy any updates on this? Is this the lead time for support you're offering for paid customers as well?

christocracy commented 4 years ago

I asked you to provide logs, you’ve not done so.

HarelM commented 4 years ago

Below are the relevant files. but, as I said, I think you'll be better off running the app locally on your machine... project.properties.txt logcat.log.txt

christocracy commented 4 years ago

Get rid of that cordova-plugin-gradle-release plugin.

christocracy commented 4 years ago

Your app is loading an insufficient version of play-services-location

java.lang.NoClassDefFoundError: com.google.android.gms.location.ActivityTransitionEvent

cordova-plugin-gradle-release is probably messing it up.

You want to be importing 16.x

HarelM commented 4 years ago

Ok, I'll try and report back tomorrow, but I have added this plugin since without it I had a compilation issue, probably due to mismatch of versions of play services or something...

HarelM commented 4 years ago

I removed the gradle plugin and the compilation went OK, I hope it will succeed also on the CI server. Below is the debug-app, it takes some seconds to load. Also the logcat log. The initial GPS position is found and shown on the map but the position doesn't get updated and I don't get location. I also don't see an icon on the status bar indicating the app in running in the background. logcat.log.txt app-debug.zip Another log: logcat2.log.txt

HarelM commented 4 years ago

Reading the logs with the relevant tag seems like the stationary radius is 150 meter...? 08-13 16:55:14.891 15383 15383 D TSLocationManager: 🎾 Start monitoring stationary region (radius: 150.0 meters) Is this the default?

christocracy commented 4 years ago

I also don't see an icon on the status bar indicating the app in running in the background.

That's correct. Read this

Reading the logs with the relevant tag seems like the stationary radius is 150 mete

Android uses a geofence as a safety mechanism. It's primary triggering mechanism is Motion API. You cannot change this.

christocracy commented 4 years ago

You must need to go for a walk. You will see the foreground-service and its corresponding notification appear once motion is detected.

HarelM commented 4 years ago

I did went for a short walk - this is the second log. I also used the app now with distance filter of 0 and the only location I got is the initial one. The bottom line is that the app is not displaying my current position. I don't know if it's a configuration issue or something else. I really need an offline and background solution to location recording. This repository seems like the right place to buy this, but I can't pay for something that doesn't work...

HarelM commented 4 years ago

@christocracy Can you please assist me with this? I'm struggling to make this work. The above attached zip is the app I created using this plugin. When clicking on the left crosshairs the location is shown, but it doesn't get updated even though I walked for about 10 minutes a distance that is probably around 100 meters. You can start the app, start location tracking and click the red circle button in order to record - it should get accurate results, otherwise you won't be able to use the recording to update OSM data. I don't know what I'm doing wrong... Please, please, please, help me...

HarelM commented 4 years ago

Hi, sorry for nagging, here's my latest log in case it makes a difference: I took the app for a walk. I started waking at around 22:10, I kept the app open on the screen until 20:20 - the location was always the initial location and didn't change. at 20:20 I turned off the screen, opened it again at 22:25 for a moment and turned the screen off again. Opened the screen at around 22:30 - the location was the same and didn't changed. I then closed the app. The walk I did was for about 1 Km which should've exited any relevant geofence. From the log below it seems that the TSLocationManager is destroyed at around 22:11 which is very early, not sure what it mean though, can be an expected behavior:

08-13 22:11:22.479 28154 28154 D TSLocationManager: [c.t.l.service.TrackingService onDestroy] 
08-13 22:11:22.479 28154 28154 D TSLocationManager:   🔴  TrackingService destroyed

logcat.log.txt

christocracy commented 4 years ago

Clone and install the SampleApp onto your device.

HarelM commented 4 years ago

I have cloned the repo and installed a debug version, selected the simple app from the menu and clicked the blue button with the white arrow - same results: the first location is presented but is not updated. I took the car for a short ride this time. HarelM is the user I used. After a few minutes of diverging I tried to press some buttons and the location updated to the current position - provably due to restart of the service. I'll try the release version from the store see if it acts differently.

HarelM commented 4 years ago

I have also tried running the BG Geo cordova app from the play store and the results seems similar. Below is a screen shot. Step I made:

  1. Set name to HarelM-prod and selected the simple map.
  2. Click on lower right button which created a first point.
  3. Drove a bit and nothing changed so I clicked the top toggle button
  4. The route was drawn and a red circle appeared
  5. I drove further outside the circle and no change was made to the map or the route. Screenshot_2019-08-14-07-53-03-611_com transistorsoft backgroundgeolocation ionic2
christocracy commented 4 years ago

Problem is your device. What os version is this? See http://dontkillmyapp.com.

I test almost daily on 11 devices with the apps running untouched for weeks at a time. Only my Huawei gives trouble:

My Android Family

HarelM commented 4 years ago

My device is: XIAOMI Redmi 4X @ 7.1.2. I don't think the problem is my device, here's why:

  1. My device has other apps that are running and are able to show and record GPS position, further more, I'm using another cordova plugin which is able to show and record GPS position in the background but has its issues and I'm looking for something that works better.
  2. The application is not terminated as it is in the foreground for the above tests! so the link you sent is irrelevant.

Let's try and solve this issue instead of trying to ignore it. I would appreciate it if you can reopen this issue as well.

christocracy commented 4 years ago

Why didn't the Mauron85 version work for you on that device?

HarelM commented 4 years ago

It does work, but after a while in the background it stops...

christocracy commented 4 years ago

Your device has a problem with motion API not responding.

Install a Sensor Test app on your device, eg: https://play.google.com/store/apps/details?id=ru.andr7e.sensortest&hl=en

HarelM commented 4 years ago

I have installed the above app, but I'm not sure what to test there. I don't see a test for motion API not GPS position. In any case, I'll see if I can send my test app to be tested on other phones and see how they react, My wife has the same phone I do, I'll see if it's something with my phone or in that model... I'll keep you posted. Is there a way to disable the motion API in this plugin's configuration and use regular GPS recording - I mean some sort of fallback for cases like mine...?

christocracy commented 4 years ago

Motion API = acceleromter + gyroscope + magnetometer.

HarelM commented 4 years ago

Thanks @christocracy! you were right! I have used the app you mentioned to see that indeed the problem was with the gyroscope. After a reboot it started working again - I've seen it malfunction sometime when taking a photo and getting the wrong orientation, but I didn't thought it could cause this issue. I'll send the debug app to a few people and keep you posted on the results.

HarelM commented 4 years ago

Me again, I hope you didn't miss me :-) I took the debug version for a ride in my car. It mostly performed well except for a short period of time. The route can be seen here: https://israelhiking.osm.org.il/share/VDxpcSV5iQ The jump can be seen here (this was after I stopped driving for a few minutes): image The following are the log I'm writing:

2019-08-15T04:58:04.952Z | DEBUG | Valid position, updating: (31.8585636, 34.8171014)
2019-08-15T04:58:07.542Z | DEBUG | State was updated
2019-08-15T05:02:47.035Z | DEBUG | geo-location received, bg: false p: {"lat":31.8585835,"lng":34.8171489,"alt":70,"timestamp":"2019-08-15T05:02:47.000Z"}
2019-08-15T05:02:47.044Z | DEBUG | Rejecting position: {"lat":31.8585835,"lng":34.8171489,"alt":70,"timestamp":"2019-08-15T05:02:47.000Z"} reason:Time difference too high: 282
2019-08-15T05:04:52.114Z | DEBUG | geo-location received, bg: false p: {"lat":31.861777,"lng":34.81084,"alt":-1,"timestamp":"2019-08-15T05:04:51.122Z"}
2019-08-15T05:04:52.168Z | DEBUG | Rejecting position for rejected: {"coords":{"accuracy":1000,"altitude":-1,"latitude":31.861777,"longitude":34.81084,"speed":-1,"heading":-1},"timestamp":1565845491122} reason: Time difference too high: 124.122
2019-08-15T05:04:57.276Z | DEBUG | geo-location received, bg: false p: {"lat":31.8626962,"lng":34.8158754,"alt":72,"timestamp":"2019-08-15T05:04:57.188Z"}
2019-08-15T05:04:57.282Z | DEBUG | Rejecting position for rejected: {"coords":{"accuracy":13.7,"altitude":72,"latitude":31.8626962,"longitude":34.8158754,"speed":14.61,"heading":4},"timestamp":1565845497188} reason: Speed too high: 80.18535031720613
2019-08-15T05:05:03.202Z | DEBUG | geo-location received, bg: false p: {"lat":31.8626962,"lng":34.8158754,"alt":72,"timestamp":"2019-08-15T05:04:58.031Z"}
2019-08-15T05:05:03.208Z | DEBUG | Validating a rejected position: {"lat":31.8626962,"lng":34.8158754,"alt":72,"timestamp":"2019-08-15T05:04:58.031Z"}
2019-08-15T05:05:03.495Z | DEBUG | Adding a new point to the recording route.

It can be seen that there's no location received for about 4 minutes (which is probably where I stopped) and then another gap of two minutes... This is my app's log (it write time in ISO format so you'll need to add 3 hours to get the actual time): log_2019-08-15_05-28-00.357Z.txt The following is the logcat of the same time the app wokred: logcat.txt

Any help would be appreciated - if there's a configuration I need change please let me know.

HarelM commented 4 years ago

Do you want me to open a new issue for this?