react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Battery Drain Issue (IOS)

Open alihasan21987 opened this issue 1 year ago • 5 comments

Your Environment IOS

  • Plugin version: 4.9.5
  • Platform: iOS or Android IOS
  • OS version:17.5.1
  • Device manufacturer / model: IPhone 13
  • React Native version (react-native -v): 0.70.6
  • Plugin config
BackgroundGeolocation.ready({
    debug: false,
    locationAuthorizationRequest: 'Always',
    showsBackgroundLocationIndicator: false,
    logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
    desiredAccuracy: desiredAccuracy
      ? desiredAccuracy
      : BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
    distanceFilter: distanceFilter ? distanceFilter : 10,
    stopOnTerminate: false,
    disableMotionActivityUpdates: true,
    startOnBoot: true,
    heartbeatInterval: 10,
    enableHeadless: true,
    locationAuthorizationAlert: {
      titleWhenNotEnabled: t('title_when_not_enabled'),
      titleWhenOff: t('title_when_off'),
      instructions: t('location_auth_alert_instructions'),
      cancelButton: t('location_auth_alert_cancel'),
      settingsButton: t('location_auth_alert_settings'),
    },
    stopTimeout: 5,
    desiredOdometerAccuracy: 10,
    backgroundPermissionRationale: {
      title: 'Allow "App" to use your location?',
      message:
        'Please select "Change to Always Allow" below so App can access your location even when you are not using the app.',
      positiveAction: 'Change to "Always Allow"',
      negativeAction: 'Cancel',
    },
  })
    .then((state) => {
      if (!state.enabled) {
        return BackgroundGeolocation.start()
          .then(() => payload)
          .catch((error) => Promise.reject(JSON.stringify(error)));
      }
    })
    .catch((err) => {
      console.error('Background Geop Location  Error : ', err);
    });

Expected Behavior

Using above Config for Background Geolocation and still battery is consuming more on IOS Devices. I have build install on IOS Device IPhone 13, and it is draining a lot of battery even app is in background or terminated state.

Actual Behavior

How can I solve this problem as I have tried with above config but still it is draining too much battery even on background & terminated state on IOS.

Steps to Reproduce

Context

Debug logs

Logs
PASTE_YOUR_LOGS_HERE

alihasan21987 avatar Aug 08 '24 13:08 alihasan21987

Plugin version: 4.9.5

First-of-all, you’re using an old version. See the CHANGELOG.

https://github.com/transistorsoft/react-native-background-geolocation/blob/master/CHANGELOG.md

second, I’ve been running the demo app on my device for nearly 10 years and i don’t experience unusual battery drain.

IMG_1989

christocracy avatar Aug 08 '24 13:08 christocracy

Plugin version: 4.16.5 Platform: iOS or Android IOS OS version:17.5.1 Device manufacturer / model: IPhone 13 React Native version (react-native -v): 0.70.6 Plugin config

BackgroundGeolocation.ready({ debug: false, locationAuthorizationRequest: 'Always', showsBackgroundLocationIndicator: false, logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE, desiredAccuracy: desiredAccuracy ? desiredAccuracy : BackgroundGeolocation.DESIRED_ACCURACY_HIGH, distanceFilter: distanceFilter ? distanceFilter : 10, stopOnTerminate: false, disableMotionActivityUpdates: true, startOnBoot: true, heartbeatInterval: 10, enableHeadless: true, locationAuthorizationAlert: { titleWhenNotEnabled: t('title_when_not_enabled'), titleWhenOff: t('title_when_off'), instructions: t('location_auth_alert_instructions'), cancelButton: t('location_auth_alert_cancel'), settingsButton: t('location_auth_alert_settings'), }, stopTimeout: 5, desiredOdometerAccuracy: 10, backgroundPermissionRationale: { title: 'Allow "App" to use your location?', message: 'Please select "Change to Always Allow" below so App can access your location even when you are not using the app.', positiveAction: 'Change to "Always Allow"', negativeAction: 'Cancel', }, }) .then((state) => { if (!state.enabled) { return BackgroundGeolocation.start() .then(() => payload) .catch((error) => Promise.reject(JSON.stringify(error))); } }) .catch((err) => { console.error('Background Geop Location Error : ', err); });

  • How much battery % should be used when the app is on driving mode, for an hour with above settings & we are using socket.io to send the real-time location to server? Why the device is heating up in with new library version ? How can we reduce the battery drain?

alihasan21987 avatar Aug 12 '24 12:08 alihasan21987

showsBackgroundLocationIndicator: false,

I suggest you set that to true.

How mush battery % should be used when the app is on driving mode, for an hour with above settings & we are using socket.io to send the real-time location to server?

I have no idea. I do not experience anything unusual with the demo app I've been running on my device for nearly 10 years.

I suggest you disable your socket.io code and compare performance without it.

christocracy avatar Aug 12 '24 14:08 christocracy

@christocracy Could you please answer the above questions?

1- How much battery % should be used when the app is on driving mode, for an hour with above settings & we are using socket.io to send the real-time location to server? Please provide some stats or numbers?

2- Why is the device heating up with the new library version ?

3- How can we reduce the battery drain?

mshehzad1 avatar Aug 13 '24 08:08 mshehzad1

I have no idea. I do not experience anything unusual with the demo app I've been running on my device for nearly 10 years.

I suggest you disable your socket.io code and compare performance without it.

christocracy avatar Aug 13 '24 09:08 christocracy

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

github-actions[bot] avatar Sep 13 '24 02:09 github-actions[bot]

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

github-actions[bot] avatar Sep 27 '24 02:09 github-actions[bot]