Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geofencing Event Issues: Missing Logs and Configuration Inquiry #1302

Open
abbasv0786 opened this issue May 30, 2024 · 12 comments
Open

Geofencing Event Issues: Missing Logs and Configuration Inquiry #1302

abbasv0786 opened this issue May 30, 2024 · 12 comments
Labels

Comments

@abbasv0786
Copy link

Your Environment

  • Plugin version: 4.15.2
  • Platform: iOS
  • OS version: 17.4.1
  • Device manufacturer / model: iPhone 15 Pro
  • Flutter info (flutter doctor): Channel stable, 3.19.5, on macOS 14.5 23F79 darwin-x64, locale en-GB
  • Plugin config:
    var config = Config(
      autoSync: true,
      batchSync: true,
      maxBatchSize: 50,
      locationsOrderDirection: "DESC",
      maxDaysToPersist: 14,
      geofenceModeHighAccuracy: true,
      stopOnTerminate: false,
      showsBackgroundLocationIndicator: false,
      desiredAccuracy: Platform.isIOS
          ? Config.DESIRED_ACCURACY_NAVIGATION
          : Config.DESIRED_ACCURACY_HIGH,
      distanceFilter: 10.0,
      enableHeadless: true,
      stationaryRadius: 10,
      pausesLocationUpdatesAutomatically: false,
      locationAuthorizationRequest: 'Always',
      geofenceProximityRadius: Platform.isAndroid ? 200 : 50,
      startOnBoot: true,
      disableElasticity: true,
      allowIdenticalLocations: true,
      preventSuspend: true,
      foregroundService: true,
      logLevel: bg.Config.LOG_LEVEL_VERBOSE,
      debug: false,
      disableMotionActivityUpdates: true,
      notification: bg.Notification(
        sticky: true,
        priority: Config.NOTIFICATION_PRIORITY_MAX,
      ),
    );

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
Copy link
Member

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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

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

@christocracy
Copy link
Member

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
Copy link
Author

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
Copy link
Author

abbasv0786 commented May 30, 2024

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
Copy link
Member

christocracy commented May 30, 2024

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
Copy link
Author

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
Copy link
Member

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.

Copy link

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

@github-actions github-actions bot added the stale label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants