forrestguice / NaturalHour

A roman timekeeping add-on for Suntimes.
GNU General Public License v3.0
33 stars 2 forks source link

The widget does not update #15

Closed Dambond closed 1 year ago

Dambond commented 2 years ago

The widget does not update automatically .I have to resize it or click on it.

forrestguice commented 2 years ago

Hi. Thanks for reporting there's a problem. Its possible there is a bug here (wouldn't be the first time), or it could be an issue with your specific device.

The widget is supposed to update once a minute. If you are able to access your devices logcat, there should be a message every time the widget is (re)scheduled. Something like..

05-10 07:47:01.829 6421-6421/com.forrestguice.suntimes.naturalhour D/NaturalHourWidget: saveNextSuggestedUpdate: 7:48 AM
05-10 07:47:01.829 6421-6421/com.forrestguice.suntimes.naturalhour D/NaturalHourWidget_3x2: getUpdateTimeMillis: next update is at: 1652194081591

A few questions.. 1) What version Android are you running? (different behaviors for each). 2) When you notice the widget hasn't been updated, how stale is the info? Is it 10-15 minutes out of date, or hours, or maybe back to when the widget was added (never updated)? 3) Do you experience this bug when using the Suntimes widgets? (very similar code).

I can think of a few reasons the widget may not be updating. Supposing the app was ever force closed, the updates are stopped too. Its also possible the updates are scheduled but the OS is batching them to save battery - the widget would update every 15 to 20 minutes instead. Some phones are worse than others (https://dontkillmyapp.com/), but disabling battery optimization for the app would fix the widget.

forrestguice commented 2 years ago

All of the widgets schedule their updates the same way (by registering a PendingIntent with AlarmManager), so anything that disrupts that API effectively kills the widgets. So the potential reasons for a stale widget are numerous :\

Dambond commented 2 years ago

I'm running android 9. the widget is stuck at the last update (the last time I resized it) I have not tried it yet with suntimes widjet. "but disabling battery optimization for the app would fix the widget." it was enable...

forrestguice commented 2 years ago

@Dambond Thanks for the information. I'll keep this on the list. Whatever is causing the issue, once a widget fails once, it also fails to schedule future updates (breaking a chain). So there might be something more that can be done to help stale widgets recover.

Opening Suntimes -> Settings -> Widgets should trigger all widgets (including NaturalHour), restoring future updates. Afterward, I'm guessing the widget will update normally for some period, before whatever is causing the problem stops it again.

"but disabling battery optimization for the app would fix the widget." it was enable...

imho the Android battery optimization UI is confusing. All apps start on the "optimized" list (enabled), so you must scroll through a list of all apps, and then find and whitelist the specific app you want to "disable". In this context "enabled" actually means the system might stop the app at any time to save battery (but what actually happens really depends on the specific device).

Dambond commented 2 years ago

I'm here with good news, it work now! Sorry for not thinking about optimization. Thank for your time!

Dambond commented 2 years ago

I'm here with good news, it work now! Sorry for not thinking about optimization. Thank for your time!

Hum... I was wrong problem is back

forrestguice commented 2 years ago

Yeah, I figured it might be too soon to celebrate. I think there might be an easy fix though, which I'll include in the next patch.

An unsigned debug build is available if you wanted to try it before then. From the green check mark next to the referenced commit click 'details', then 'summary' (left pane), then 'app' (under 'Artifacts').