transistorsoft / flutter_background_geolocation

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

Geofencing Event Issues: Missing Logs and Configuration Inquiry #1302

Open abbasv0786 opened 1 month ago

abbasv0786 commented 1 month ago

Your Environment

Expected Behavior

The application should consistently receive geofencing enter and exit events from the SDK.

Actual Behavior

Sometimes, the app works correctly and we receive the expected geofencing events. However, at other times, these events are missing. Additionally, there are periods where all logs are absent, and in some logs, the geofencing events do not appear.

Steps to Reproduce

  1. Initialize geofencing with the specified radius for iOS and Android.
  2. Run the application on various devices and observe the geofencing events.
  3. Do various field testing.
  4. Check the logs for the occurrence and absence of geofencing events.
  5. Note any missing logs or events.

Context

We are trying to ensure consistent geofencing functionality across both iOS and Android platforms, using a paid API key.

Debug logs

Logs ``` Please find the attached files for the logs. ```

background-geolocation (2).log.gz background-geolocation (3).log.gz background-geolocation (4).log.gz

christocracy commented 1 month ago

What specific timestamps in these 3 logs files are your interested in me looking at?

Initialize geofencing with the specified radius for iOS and Android.

You've not provided any geofence information. I have no idea what radius you're using.

geofenceProximityRadius: Platform.isAndroid ? 200 : 50,

I don't think you understand what this Config option is. This is NOT the geofence radius and the plugin forces a minimum value here of 2000 so that you don't "shoot yourself in the foot", as you would be doing here. This option is only used for the "infinite geofencing mode", where you've registered more than 18 geofences for iOS and > 98 for android.

If you don't know what this Config option is, just delete it from your Config.

abbasv0786 commented 1 month ago

Hi Please find the geofencing registration code.

      var geofence = Geofence(
        identifier: GeoFencingConfig.fencingIdentifierHome,
        radius: GeoFencingConfig.radius.toDouble(), // Radius in meters.
        latitude: latitude ?? 0,
        longitude: longitude ?? 0,
        notifyOnEntry: GeoFencingConfig.notifyOnEntry,
        notifyOnExit: GeoFencingConfig.notifyOnExit,
        loiteringDelay: 0,
      );
      await BackgroundGeolocation.addGeofence(geofence);
abbasv0786 commented 1 month ago
class GeoFencingConfig {
  static int get radius => Platform.isAndroid ? 200 : 60;
  static String get inMessage => "Welcome back!";
  static String get outMessage => "Stay safe!";
  static String get fencingIdentifierHome => "Home";
  static bool get notifyOnEntry => true;
  static bool get notifyOnExit => true;
}
abbasv0786 commented 1 month ago

background-geolocation (2).log (1).gz

I have noticed missing logs between the following timestamps:

2024-05-24 17:38:57.543 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

2024-05-24 19:07:01.434 ℹ️-[PolygonGeofencingService setLocation:] Already updating location <IGNORED>

The application is operating in the EST time zone. Please investigate the cause of these missing logs.

Thank you.

christocracy commented 1 month ago

static int get radius => Platform.isAndroid ? 200 : 60;

The minimum reliable geofence radius for both iOS and Android is 200 meters.

christocracy commented 1 month ago

2024-05-24 17:38:57.543 ℹ️-[PolygonGeofencingService setLocation:] Already updating location

If you're not using polygon geofences, you can ignore this.

I've been testing a set of geofences in my neighbourhood on my devices for over 5 years. I test them almost daily. They never fail.

Screenshot 2024-05-30 at 12 26 58 PM
abbasv0786 commented 1 month ago

A user reported that they were out of their home on 2024-05-24 at 16:44:00 EST. Upon reviewing the logs, I found the following entry in the SDK:

2024-05-24 16:44:00.515 EST - 📢 EXIT Geofence: Home

This indicates that the exit event was executed successfully.

The user also mentioned that they returned around 18:10:00 EST. However, when I checked the SDK logs for that time, I found that the logs are missing.

Please investigate the cause of these missing logs and advise on the next steps.

abbasv0786 commented 1 month ago

I aim to implement a feature that tracks the duration a user is away from or at home by starting a timer when the user exits or enters a geofencing radius. This helps us monitor how long a user is away from home or at home.

Currently, the process is as follows:

  1. The SDK sends enter/exit geofencing events.
  2. These events trigger a Firebase Cloud Function.
  3. The Cloud Function sends an HTTP request to our server to start or stop the timer accordingly.

However, we've encountered an issue where the SDK occasionally fails to log these geofencing events. This inconsistency results in incorrect timer tracking, causing situations where the away timer continues to run even when the user is back home.

Please advise on how we can ensure reliable tracking of geofencing events to address this inconsistency.

christocracy commented 1 month ago

Geofences are completely managed by the OS. The only thing the plugin does is register those geofences. After that, it's completely up to the OS to fire geofence events.

It does not matter of the app is terminated or device rebooted. Once a geofence is registered with the OS, it is registered forever until you tell the plugin to .stop() or call .removeGeofences().

You should always ensure your geofence radius are >= 200 meters.

abbasv0786 commented 1 month ago

I am currently testing the logs with a 200-meter radius for geofencing. I will review the results and provide further feedback if I notice any issues or missing entries.

Thank you

christocracy commented 1 month ago

A user reported

Your user is in Manhattan, a dense city full of obstacles. Both iOS and Android use Wifi signals to passively monitor geofences. The plugin is not at all involved in evaluating geofences. That's purely up to the OS.

github-actions[bot] commented 2 days ago

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