transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.54k stars 424 forks source link

Getting inconsistent behavior regarding activity regocnition #1988

Closed andreydiskin closed 1 month ago

andreydiskin commented 1 month ago

Your Environment

Expected Behavior

Correctly update activity and speed

Actual Behavior

So the behavior I'm getting is flaky - sometimes activity fails to update, getting stuck on "still" or "walking". This is solved by phone restart, what makes me think about cleanup related things.

Steps to Reproduce

No clear reproduction steps - flaky behavior. Can happen also mobile device restart

Context

Creating an app that monitors driving, depending on speed and activity monitor

Debug logs

Logs ``` PASTE_YOUR_LOGS_HERE ```

package usage lifecycle

  1. Calling BackgroundGeolocation.ready() once, on app initial load
  2. holding a flag that indicates success .ready() invocation
  3. calling BackgroundGeolocation.start() when we know .ready() finished successfully
  4. registering a listener to onActivityChange
    BackgroundGeolocation.onActivityChange(async (event) => {
            setCurrentActivity(event.activity);
          });
  5. calling BackgroundGeolocation.watchPosition() and getting location, speed, and activity. I have to say coordinates are always correct
christocracy commented 1 month ago

The Motion api is provided by Google Play Services. It is a black box with only an “on/off” switch. It has no configuration; it cannot be fine-tuned. It depends completely upon the quality of sensors on the device (accelerometer, gyroscope and magnetometer).

andreydiskin commented 1 month ago

@christocracy I think that issue is not in the sensors, since when it works it is accurate. I thought it might be to initialization/cleanup. Is there a way to forcefully cleanup background tasks the package performs and start fresh?

christocracy commented 1 month ago

Is there a way to forcefully cleanup background tasks the package performs and start fresh?

No

andreydiskin commented 1 month ago

@christocracy Is there anything wrong this my usage of the package? What's mentioned in package usage lifecycle

Is this a known issue?

christocracy commented 1 month ago

If you’re getting “unusual results” from the ActivityRecognition api, there’s nothing you can do. There is no config option for the plug-in that affects this. The Motion api is either ON or OFF — that’s it.