dimtion / Shaarlier

Simple Android app for sharing links on Shaarli.
GNU General Public License v3.0
97 stars 11 forks source link

Fails to share a link when marshmallow's battery saver is ON #22

Open jeekajoo opened 8 years ago

jeekajoo commented 8 years ago

Hi, When using battery saver, sharing does not work. As soon as I tell Android not to optimizeshaarlier, sharing works again. optim

If we can't get around it, I think it should be at least documented.

Rom: Omnirom Android: 6.0.1

Thanks J.

dimtion commented 8 years ago

Thanks for the report, I could reproduce the bug, I'm looking into it.

dimtion commented 8 years ago

It seems that the problem is coming from android "battery saving" system which refuses some connections from background services. According to the documentation, the app should wait for the right time to do network calls, in order to save battery life.

Temporary, "un-optimising" the application is a good solution. Because the app only makes one or two network calls (in order to post the link), it should have no effect on your battery life. But I understand that it is a suboptimal solution.

jeekajoo commented 8 years ago

I was trying to understand why Shaarlier is considered as a background app, and I found this:

When an app enters standby mode, network access is disabled, and syncs and scheduled jobs all get shut down. The app won't be able to run any background services. "Using" an app for the purposes of App Standby counts as the user opening the app, starting a foreground service or having its foreground service used by another app, or generating a notification. If none of those things happen, then the app is at risk of being put into standby. http://arstechnica.com/gadgets/2015/10/android-6-0-marshmallow-thoroughly-reviewed/9/

dimtion commented 8 years ago

Ok, so for the moment it will be a won't fix, if I want to keep the sharing in the background (in a non blocking way) I must use GCM and for this application I don't want to be too dependant on Google services.

The other workaround is to ask the user to "disable battery optimization", but for some reasons, Google remove apps asking for this request.

So, unless I find a way to do the web request in the foreground (I mean called from a foreground thread), the bug won't be fixed. I may document this issue to avoid future surprises from other users.