transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
651 stars 242 forks source link

Geofence Event is being repeated, even after new location reported #1291

Closed lloydelvt closed 4 months ago

lloydelvt commented 6 months ago

Your Environment


## Expected Behavior
The Android device should report the entrance of a geofence one time and then continue reporting new locations after the exit. 

## Actual Behavior
Instead the new locations are reported but the same geofence entrance event is being repeated over and over again with a different UUID and the same timestamp of the event itself. 

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. Create a geofence and enter the geofence
2. Ensure the geofence event is triggered
3. Continue away from the geofence 
4. Ensure new locations are being reported

## Context
We want to understand a couple of things:
What causes multiple reports with the exact same timestamp?
Does the UUID change if the same event is reported multiple times?
Why does the geofence.timestamp property change, but the location.timestamp does not change?
Why do we keep getting the same geofence ENTER events (with an identical timestamp to the previous duplicates) after the device has reported another location outside of the geofence radius?

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details>
    <summary>Logs</summary>

``` <!-- syntax-highligting:  DO NOT REMOVE -->
2024-05-06T11:35:01.926-07:00   [INFO] blueprint.user_blueprint : Flutter Location - Profile 2619, request_body: {'location': {'event': 'geofence', 'is_moving': True, 'uuid': '5295389c-d257-42e7-b230-db6fcff4c333', 'timestamp': '2024-05-06T16:27:04.519Z', 'age': 7677172, 'odometer': 24634.5, 'coords': {'latitude': 27.4611049, 'longitude': -80.3036392, 'accuracy': 11.5, 'speed': 0.04, 'speed_accuracy': 1.5, 'heading': -1, 'heading_accuracy': -1, 'altitude': -16.6, 'ellipsoidal_altitude': -16.6, 'altitude_accuracy': 1, 'age': 7677174}, 'activity': {'type': 'still', 'confidence': 100}, 'battery': {'is_charging': True, 'level': 0.83}, 'geofence': {'identifier': '855', 'action': 'ENTER', 'timestamp': '2024-05-06T18:35:01.692Z'}, 'extras': {}}, 'profile_id': '2619'}
2024-05-06T11:35:06.977-07:00   [INFO] blueprint.user_blueprint : Flutter Location - Profile 2619, request_body: {'location': {'event': 'geofence', 'is_moving': True, 'uuid': '4e0dd489-eb29-41b8-9760-d4057400c247', 'timestamp': '2024-05-06T16:27:04.519Z', 'age': 7682208, 'odometer': 24634.5, 'coords': {'latitude': 27.4611049, 'longitude': -80.3036392, 'accuracy': 11.5, 'speed': 0.04, 'speed_accuracy': 1.5, 'heading': -1, 'heading_accuracy': -1, 'altitude': -16.6, 'ellipsoidal_altitude': -16.6, 'altitude_accuracy': 1, 'age': 7682210}, 'activity': {'type': 'still', 'confidence': 100}, 'battery': {'is_charging': True, 'level': 0.83}, 'geofence': {'identifier': '855', 'action': 'ENTER', 'timestamp': '2024-05-06T18:35:06.728Z'}, 'extras': {}}, 'profile_id': '2619'}
2024-05-06T11:40:33.542-07:00   [INFO] blueprint.user_blueprint : Flutter Location - Profile 2619, request_body: {'location': {'event': 'geofence', 'is_moving': True, 'uuid': '2dfa4943-0db1-471e-b22d-7990c77f4f39', 'timestamp': '2024-05-06T16:27:04.519Z', 'age': 8008790, 'odometer': 26810.4, 'coords': {'latitude': 27.4611049, 'longitude': -80.3036392, 'accuracy': 11.5, 'speed': 0.04, 'speed_accuracy': 1.5, 'heading': -1, 'heading_accuracy': -1, 'altitude': -16.6, 'ellipsoidal_altitude': -16.6, 'altitude_accuracy': 1, 'age': 8008793}, 'activity': {'type': 'still', 'confidence': 100}, 'battery': {'is_charging': True, 'level': 0.82}, 'geofence': {'identifier': '855', 'action': 'ENTER', 'timestamp': '2024-05-06T18:40:33.311Z'}, 'extras': {}}, 'profile_id': '2619'}
2024-05-06T11:40:38.581-07:00   [INFO] blueprint.user_blueprint : Flutter Location - Profile 2619, request_body: {'location': {'event': 'geofence', 'is_moving': True, 'uuid': '7eba1552-db60-4659-8dab-fd2d2a1c097b', 'timestamp': '2024-05-06T16:27:04.519Z', 'age': 8013833, 'odometer': 26810.4, 'coords': {'latitude': 27.4611049, 'longitude': -80.3036392, 'accuracy': 11.5, 'speed': 0.04, 'speed_accuracy': 1.5, 'heading': -1, 'heading_accuracy': -1, 'altitude': -16.6, 'ellipsoidal_altitude': -16.6, 'altitude_accuracy': 1, 'age': 8013835}, 'activity': {'type': 'still', 'confidence': 100}, 'battery': {'is_charging': True, 'level': 0.82}, 'geofence': {'identifier': '855', 'action': 'ENTER', 'timestamp': '2024-05-06T18:40:38.353Z'}, 'extras': {}}, 'profile_id': '2619'}
2024-05-06T11:40:53.688-07:00   [INFO] blueprint.user_blueprint : Flutter Location - Profile 2619, request_body: {'location': {'event': 'geofence', 'is_moving': True, 'uuid': '4a79f002-e8f2-4288-b228-ecd0e2a7778e', 'timestamp': '2024-05-06T16:27:04.519Z', 'age': 8028919, 'odometer': 26810.4, 'coords': {'latitude': 27.4611049, 'longitude': -80.3036392, 'accuracy': 11.5, 'speed': 0.04, 'speed_accuracy': 1.5, 'heading': -1, 'heading_accuracy': -1, 'altitude': -16.6, 'ellipsoidal_altitude': -16.6, 'altitude_accuracy': 1, 'age': 8028920}, 'activity': {'type': 'still', 'confidence': 100}, 'battery': {'is_charging': True, 'level': 0.82}, 'geofence': {'identifier': '855', 'action': 'ENTER', 'timestamp': '2024-05-06T18:40:53.439Z'}, 'extras': {}}, 'profile_id': '2619'}

christocracy commented 6 months ago

If the uuid is different, it’s a unique event.

Geofences are managed entirely by the OS. The plug-in is merely the “mailman”, delivering events reported by the OS.

lloydelvt commented 6 months ago

We are getting geofence entry events that are firing every second while a user is dwelling within the geofence. Is there any reason you can think this is happening. We are getting approximately 1500 unique geofence entry events over a 20 minute timeframe . Is there anything that you can think of that would cause that?

christocracy commented 6 months ago

Is there anything that you can think of that would cause that?

your code has a bug, repeatedly adding/removing geofences.

christocracy commented 6 months ago

See wiki “Debugging” and learn to fetch the plug-in’s log database using .emailLog.

zigapovhe commented 6 months ago

@christocracy I could easily reproduce this bug on A14 (using plugin version 4.15.3) by registering 6 geofences one by one using the bg.BackgroundGeolocation.addGeofence(geofence) function. A few seconds after that, I've received exactly 6 Geofence Events for the geofence I was in, and I'm 100% sure, that my code called .addGeofence() function only once for each of the 6 geofences.

@lloydelvt Try registering all geofences at once by using bg.BackgroundGeolocation.addGeofences(geofences);. This solved the issue for me.

zigapovhe commented 6 months ago

When reading the original bug report again, I'm not sure anymore if this is the same bug, but its worth investigating. If I need to create separate issue, notify me.

christocracy commented 6 months ago

I doubt this is the same issue. I suggest you post a new issue and provide detailed logs showing these events firing, as well as the specific attributes of these geofences.

github-actions[bot] commented 5 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.