pathsense / pathsense-samples-android

Sample Applications for the PathSense SDK
Other
26 stars 10 forks source link

Battery drain issue #11

Closed cpenbe closed 7 years ago

cpenbe commented 7 years ago

Hi again great team, your solution works perfect, thanks again.

But we face a battery problem with your geofence feature, it drains battery up to 35% alone. Is there anything we can do to decrease battery consumption while geofence feature is used? Your help will be really appreciated, thanks again.

Detail:

We use Pathsense library in our app within a service (our specific service) named "ChildService" And we defined API in this service as below: final PathsenseLocationProviderApi api = PathsenseLocationProviderApi.getInstance(ChildService.this);

Once we defined the API, Pathsense LocationEngineService begins to run. And when this service is run it drains battery needlessly although no geofence is added. We couldn't find a way to prevent this.

Also, if geofence is not added we used destroy() method of your API. And we defined API again when geofence is added as described above. But when we destroyed and redefined the API, geofences did not run properly.

Could you please help, thanks.

dyerjo commented 7 years ago

Hi,

Regarding the power drain issue, I have a few questions:

As for the issue with destroy(), this can occur if you attempt to use a destroyed instance of the PathsenseLocationProviderApi. If you are keeping a reference to the api:

PathsenseLocationProviderApi api = PathsenseLocationProviderApi.getInstance(ChildService.this); …

api.destroy(); … api.addGeofence

This will not work. Instead, get a new instance of the api:

PathsenseLocationProviderApi api = PathsenseLocationProviderApi.getInstance(ChildService.this); …

api.destroy(); api = PathsenseLocationProviderApi.getInstance(ChildService.this); … api.addGeofence

In fact, PathsenseLocationProviderApi.getInstance() will always return a non-destroyed singleton instance of the api, so there is no need to keep a reference to it.

Thank you, John Dyer

On May 15, 2017, at 4:41 AM, ozfloyd notifications@github.com wrote:

Hi again great team, your solution works perfect, thanks again.

But we face a battery problem with your geofence feature, it drains battery up to 35% alone. Is there anything we can do to decrease battery consumption while geofence feature is used? Your help will be really appreciated, thanks again.

Detail:

We use Pathsense library in our app within a service (our specific service) named "ChildService" And we defined API in this service as below: final PathsenseLocationProviderApi api = PathsenseLocationProviderApi.getInstance(ChildService.this);

Once we defined the API, Pathsense LocationEngineService begins to run. And when this service is run it drains battery needlessly although no geofence is added. We couldn't find a way to prevent this.

Also, if geofence is not added we used destroy() method of your API. And we defined API again when geofence is added as described above. But when we destroyed and redefined the API, geofences did not run properly.

Could you please help, thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/11, or mute the thread https://github.com/notifications/unsubscribe-auth/AJALSwxIX4n8kn_5GxLwKcTm6BwRBRlkks5r6DnkgaJpZM4NbBAj.

cpenbe commented 7 years ago

Hi John, destroy() issue is solved as per your great explanations, thank you very much! (though would be better if you've included it in the documentation.)

As per power drain issue, problem is highly solved (about 80%) when we do not use geofence but it remains while geofence is used. We have tested it by running only your LocationEngineService API in our app (closed other services) and it used ~20% of battery alone in about 8 hours (at night, phone was asleep and not used for any other purpose).

Is there any solution or workaround to decrease battery usage when we run LocationEngineService ?

Tested device was Sony Xperia, Android 6.0 but we have the same battery issue with other devices such as Samsung S5 mini, Android 6.0.1 and Samsung Galaxy Grand, Android 4.2.2.

dyerjo commented 7 years ago

Hi,

What version of the SDK are you using? Please, make sure that you are using the latest release (2.3.0.18).

To improve battery consumption, the SDK relies on certain wake-up sensors to come back alive after long periods of inactivity (i.e. laying on a table, overnight). Unfortunately, not all phones have this—particularly older phones. As a result, other--more power consuming methods—are used to keep the device running in the background. The ~20% increase in battery usage is what we would expect on these types of devices. For these devices, we are working on improving this, but no release date has yet been set.

Even under normal conditions, on devices that support wake-up sensors, we would expect ~10% increase in battery usage.

Thank you, John Dyer

On May 16, 2017, at 3:02 AM, ozfloyd notifications@github.com wrote:

Hi John, destroy() issue is solved as per your great explanations, thank you very much! (though would be better if you've included it in the documentation.)

As per power drain issue, problem is highly solved (about 80%) when we do not use geofence but it remains while geofence is used. We have tested it by running only your LocationEngineService API in our app (closed other services) and it used ~20% of battery alone in about 8 hours (at night, phone was asleep and not used for any other purpose).

Is there any solution or workaround to decrease battery usage when we run LocationEngineService ?

Tested device was Sony Xperia, Android 6.0 but we have the same battery issue with other devices such as Samsung S5 mini, Android 6.0.1 and Samsung Galaxy Grand, Android 4.2.2.

cpenbe commented 7 years ago

Hi John, thanks for your answer. Yes, we are using the latest release. Can you please let me know if we need to do anything to use those wake-up sensors you mentioned as devices we test are relatively newer ones? Or is there any other method in your API such as increasing time intervals to check the location in order to decrease power consumption? Thanks again.

dyerjo commented 7 years ago

Hi,

Why don’t we pull this conversation offline, so we can further discuss your issue.

Is there an email that I can reach you at?

Thank you, John Dyer

On May 16, 2017, at 11:55 AM, ozfloyd notifications@github.com wrote:

Hi John, thanks for your answer. Yes, we are using the latest release. Can you please let me know if we need to do anything to use those wake-up sensors you mentioned as devices we test are relatively newer ones? Or is there any other method in your API such as increasing time intervals to check the location in order to decrease power consumption? Thanks again.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/11#issuecomment-301880215, or mute the thread https://github.com/notifications/unsubscribe-auth/AJALSz-GN4n7ojrtqi5QK-0cT_US9Vkgks5r6fEQgaJpZM4NbBAj.

cpenbe commented 7 years ago

Hi John, I haven't received any mail from you, I can send you an email either if you drop it here. ps: I've tried your solution on Oneplus One with Geofence added and it consumed much power as well.

dyerjo commented 7 years ago

Hi,

I sent an email to the address you posted.

Please, let me know if you do not receive it.

Thank you, John Dyer

On May 17, 2017, at 1:10 AM, ozfloyd notifications@github.com wrote:

Hi John, I haven't received any mail from you, I can send you an email either if you drop it here. ps: I've tried your solution on Oneplus One with Geofence added and it consumed much power as well.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pathsense/pathsense-samples-android/issues/11#issuecomment-302018117, or mute the thread https://github.com/notifications/unsubscribe-auth/AJALS2LvTDcbe7Ml2LyJHZptDvrq7Dahks5r6qt-gaJpZM4NbBAj.

cpenbe commented 7 years ago

Thanks, replied now.

pablobaxter commented 7 years ago

Resolved internally.