datapartyjs / rfparty-mobile

Apache License 2.0
25 stars 5 forks source link

activity service crashing in production #36

Open sevenbitbyte opened 1 year ago

sevenbitbyte commented 1 year ago

For some reason we're seeing elevated rates of the activity service crashing

Impact

So far I've gotten one direct user report and the console appears to showed 2 total that users may have hit this crash.

Next moves

Screenshot from 2022-10-18 19-15-41

sevenbitbyte commented 1 year ago

This twitter post is similar and adds more context.

https://twitter.com/NZSmartie/status/1582556572454383616

Problem is we're currently using ACTIVITY_PROVIDER, which greatly improved gps quality.

https://github.com/datapartyjs/rfparty-mobile/blob/main/src/main-window.js#L574

We need to detect when activity recognition service is unavailable/crashing and downgrade to the raw GPS provider.

sevenbitbyte commented 1 year ago

Found a simple repro:

  1. Disallow "Activity Recognition"
  2. Open app
  3. Click at "Permissions Required"
  4. Crash. Fin.
sevenbitbyte commented 1 year ago

Merged a fix(#40) and releasing to google play.

sevenbitbyte commented 1 year ago

Hmm, looks like we're stuck on a very old version of cordova-background-geolocation-plugin

https://github.com/datapartyjs/rfparty-mobile/blob/main/package.json#L29

"cordova-background-geolocation-plugin": "^2.0.7",

Meanwhile geolocation is on v3.1.0

https://github.com/mauron85/cordova-plugin-background-geolocation/blob/master/package.json#L3

Can't remember if there was some good reason to be on an older version. Testing upgrading now.

sevenbitbyte commented 1 year ago

Oh, the package name changed to @mauron85/cordova-plugin-background-geolocation

sevenbitbyte commented 1 year ago

Hmm even v3.1.0 appears to still use a deprecated approach to activity provider

https://github.com/mauron85/background-geolocation-android/blob/2693e07587eea08746004bd3e72dde276b04b4d2/src/main/java/com/marianhello/bgloc/provider/ActivityRecognitionLocationProvider.java#L151

Deprecation notice ActivityRecognitionApi -> https://developers.google.com/android/reference/com/google/android/gms/location/ActivityRecognitionApi

Need to port to ActivityRecognitionClient -> https://developers.google.com/android/reference/com/google/android/gms/location/ActivityRecognitionClient