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

High-Frequency Background Events and Invalid Battery Level on Specific Samsung Devices #298

Open
tanuj-g opened this issue Dec 9, 2024 · 4 comments

Comments

@tanuj-g
Copy link

tanuj-g commented Dec 9, 2024

Your Environment

  • Plugin version: 6.0.3

  • Platform: Android

  • Device OS version: 12

  • Device manufacturer/model:

    • Samsung Galaxy A50s (SM-A5070)
    • Samsung Galaxy A53 5G (SM-A536E)
    • Samsung Galaxy S22 5G (SM-S901E)
    • Samsung Galaxy S20 FE 5G (SM-G7810)
    • Samsung Galaxy S10 SM (SM-G973F)
    • Samsung Galaxy A80 (SM-A805N)
    • Samsung Galaxy A90 5G (SM-A908N)
    • Samsung Galaxy S10 5G (SM-G977B)
  • XCode version: Not applicable (issue on Android)

  • Capacitor info
    Latest Dependencies @capacitor/cli: 6.2.0 @capacitor/core: 6.2.0 @capacitor/android: 6.2.0 @capacitor/ios: 6.2.0

Installed Dependencies: @capacitor/cli: 6.1.1 @capacitor/core: 6.1.1 @capacitor/android: 6.1.1 @capacitor/ios: 6.1.1

  • Plugin config provided to #ready:
await BackgroundGeolocation.ready({
      autoSync: true, // <-- Auto start tracking when device is powered-up.
      backgroundPermissionRationale: {
        
      debug: false,
      desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
      disableLocationAuthorizationAlert: true,
      distanceFilter: 300,
      elasticityMultiplier: 4,
      extras: {
        androidSDKVersion
        appVersion
        batteryLevel
        connectionType
        deviceID
        deviceManufacturer
        deviceModel
        deviceName
        deviceOS
        deviceOSVersion
        devicePlatform
        iOSVersion
        isDeviceCharging
        isDeviceVirtual
        isNetworkConnected
        languageCode
      },
      fastestLocationUpdateInterval: 300000,
      headers: {
        ContentType: 'application/json'
      },
      isMoving: true,
      logLevel: BackgroundGeolocation.LOG_LEVEL_ERROR,
      reset: false,
      showsBackgroundLocationIndicator: false,
      startOnBoot: true,
      stationaryRadius: 200,
      stopOnTerminate: false,
      stopTimeout: 5,
      URL: API_URL,
      useSignificantChangesOnly: true
    });

Expected Behavior

Devices should send background events (e.g., providerchange, motionchange, location) at reasonable intervals, no more than the configured rate (e.g., 30 updates per hour). The battery level should report valid values between 0 and 1.

Actual Behavior

The following Samsung devices are sending background events (providerchange, motionchange, location) excessively, at a rate of 4-5 updates per second. Additionally, these devices report an invalid battery level of -21474836 in the battery.level field.

Affected devices:

  • Samsung Galaxy A50s (SM-A5070)
  • Samsung Galaxy A53 5G (SM-A536E)
  • Samsung Galaxy S22 5G (SM-S901E)
  • Samsung Galaxy S20 FE 5G (SM-G7810)
  • Samsung Galaxy S10 SM (SM-G973F)
  • Samsung Galaxy A80 (SM-A805N)
  • Samsung Galaxy A90 5G (SM-A908N)
  • Samsung Galaxy S10 5G (SM-G977B)

Steps to Reproduce

  1. Configure the plugin with the above configuration.
  2. Run the app on the affected devices.
  3. Observe the frequency of background events and the reported battery level.

Context

I am using the plugin to track location updates in the background. The high-frequency events and invalid battery levels are overloading the server and causing incorrect behavior.

I am using the plugin to track background location updates in my app, with a maximum expectation of 40 updates/hour from genuine devices. However, the mentioned Samsung devices are sending background events excessively, sometimes 4-5 times per second. This behaviour is observed across multiple event types, including:

  • providerchange
  • motionchange
  • location

Note: Additionally, the battery.level field consistently reports an invalid value of -21474836 on these devices.

Debug logs

Logs
{
  "location": {
    "event": "providerchange",
    "provider": {
      "network": false,
      "gps": false,
      "enabled": false,
      "status": 3,
      "accuracyAuthorization": 0,
      "airplane": false
    },
    "is_moving": false,
    "uuid": "c6e4a17f-1b76-4371-a382-07f95d7832ea",
    "timestamp": "2024-12-09T07:47:38.662Z",
    "age": 0,
    "odometer": 7604130,
    "coords": {
      "latitude": 41.727572120215434,
      "longitude": -107.73333670011573,
      "accuracy": 5.2,
      "speed": 0,
      "speed_accuracy": 0.1,
      "heading": 198.6,
      "heading_accuracy": 1,
      "altitude": 175.76,
      "ellipsoidal_altitude": 175.76,
      "altitude_accuracy": 4.7,
      "age": 2
    },
    "activity": {
      "type": "still",
      "confidence": 100
    },
    "battery": {
      "is_charging": false,
      "level": -21474836
    },
    "extras": {
      "androidSDKVersion": 32,
      "appVersion": "3.4.3",
      "batteryLevel": 0.8199999928474426,
      "connectionType": "wifi",
      "deviceID": "4bd04d0b55ce8343",
      "deviceManufacturer": "Samsung",
      "deviceModel": "SM-A5070",
      "deviceName": "SM-A536E",
      "deviceOS": "android",
      "deviceOSVersion": "12",
      "devicePlatform": "android",
      "iOSVersion": null,
      "isDeviceCharging": true,
      "isDeviceVirtual": false,
      "isNetworkConnected": true,
      "languageCode": "en",
    }
  }
}

@tanuj-g
Copy link
Author

tanuj-g commented Dec 9, 2024

@christocracy

Hi, I wanted to add a few queries to help with diagnosing the issue:

  1. Is there a way to enforce stricter limits on the frequency of background events at the plugin level? For example, throttling or debouncing events like providerchange, motionchange, and location to avoid excessive updates.

  2. What could cause the battery.level to report -21474836? Could it be a plugin-side bug, or is it specific to certain devices or firmware versions?

  3. Are there known issues with Samsung devices (e.g., the models listed in the issue) causing excessive background events or invalid battery data?

  4. Can you recommend any configuration changes to minimize redundant events, particularly providerchange triggered by network or GPS toggling?

  5. What additional debug steps would you recommend to gather more insights into this behavior?

  6. Are there updates in a newer version of the plugin that might address these issues?

Let me know if you need further information or specific logs to assist with debugging. I'm happy to provide more details as needed.

@christocracy
Copy link
Member

excessively, at a rate of 4-5 updates per second

It sounds like you’ve created an infinite loop somewhere.

show your code.

@tanuj-g
Copy link
Author

tanuj-g commented Dec 10, 2024

@christocracy

If this were due to an infinite loop, the issue would likely occur across all devices.

Our app has been downloaded 19.8K times on the Google Play Store and 6K times on the Apple App Store, with around 5K monthly active users. Despite this, the problem is only observed on the specific devices mentioned in the issue. This leads me to believe that the behaviour is specific to those particular device models, potentially due to a hardware, firmware, or configuration-related issue.

To clarify further:

  1. Could there be something in the plugin’s handling of background events (providerchange, motionchange, location) that interacts differently with these specific devices?
  2. Is there a known configuration or parameter that could be adjusted to minimize redundant events for these models?
  3. Could the invalid battery level (-21474836) be related to how the plugin retrieves data from these devices?

Let me know if additional logs or configurations are required to debug this further.

@tanuj-g
Copy link
Author

tanuj-g commented Dec 11, 2024

Hello @christocracy

I just wanted to share one more detail that might help you give some suggestions. For all the problematic updates where battery.level is -21474836, the activity field always shows:

"activity": { "type": "still", "confidence": 100 }

Could this indicate anything specific, or do you have any suggestions on what might be causing this behaviour? Your guidance would be greatly appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants