aneonex / BitcoinChecker

Bitcoin Checker data module (v2)
MIT License
67 stars 23 forks source link

Global update interval is not working in time #169

Closed e6a6 closed 2 years ago

e6a6 commented 2 years ago
  1. Version : 2.49.3
  2. Phone model and Android version : Samsung Galaxy Z Fold 3, Android 12

Hello, I updated to Android 12 today from Android 11. But I found that global update is not working in time. I set the global update interval to 5 minutes. In Android 11, after the system booting was completed and bitcoinchecker was run, it was updated every 5 minutes with near-second accuracy. However, in Android 12, the actual update interval is very irregular. such as 7.x minutes, 2.x minutes, 5.x minutes, so on. I changed the global update interval to 1 minutes for test, the actual update interval was irregular from tens of seconds to 3 minutes.

Can't update at the exact specified time? (for example, update every HH:00:00, HH:05:00, HH:10:00, HH:15:00, HH:20:00, HH:25:00.... if the interval set to 5 minutes)

aneonex commented 2 years ago

What is the state of the battery optimization in the app settings ("Sleep mode behavior" section)? It looks like battery optimization is on, so Android blocks the app from waking up at the exact time. Turning off battery optimization should solve the problem.

e6a6 commented 2 years ago

I just checked the app settings. Sleep mode or battery optimization was already turned off. I've rebooted my phone several times but it didn't solve the problem.

Settings2

Settings1

aneonex commented 2 years ago

Unfortunately I was unable to reproduce the issue on standard Android 12 from Google. Updating the price with an interval 1 minute works correctly.

Possible reason 1 (more likely). Samsung has its own "restrictions system" in addition to the standard Android. Perhaps in Android 12, Samsung added even more battery restrictions to apps.

Try to remove battery/sleep restrictions like described here: https://dontkillmyapp.com/samsung#android-11 Link about Samsung with Android 11, but I suppose for the Android 12 something similar.

Possible reason 2. Also, an unstable update interval can be associated with a slow network, as a result, the price physically does not have time to update on time.

e6a6 commented 2 years ago

Thank you for your effort. I did a few more tests. I am in a good network condition. The same problem occurs on home/office WiFi and mobile networks(4G). So it's probably not a network issue.

I checked again, but all restrictions on bitcoinchecker were already turned off. (It was the same with the previous Android 11.) Interestingly, this issue also occurs when the app is running in the foreground. For testing, I changed the interval to 1 minute and observed with the app running in the foreground. For the first few minutes, updates were performed exactly every minute.

However, within 5 to 15 minutes (irregular) the update interval starts to deviate. For example, it was initially updated every 11:00:01, 11:01:01, 11:02:01... At some point, the update interval is deviated once, and it is updated every 11:10:25, 11:11:25, 11:12:25... And as time passes, the interval is deviated again, and it is updated every 11:15:40, 11:16:40, 11:17:40... For this reason, when the update interval is 1 minute, the effective interval feels like 30s to 1m30s (irregular).

As in the example, if the interval is 1 minute, there is a slight time error, but there is no big problem. However, when the interval is long, such as 5 minutes, this repeated deviation leads to a fairly large error. The effective interval feels like 2m30s to 7m30s (irregular).

As you said, it only seems to be the influence of Samsung's own "restrictions system" that the user has no control over. (or maybe the task scheduler specification in Android 12 has changed, I'm not an Android developer, so I'm not sure.) Fortunately, for me, this issue is not too annoying and is quite acceptable. Because, I rarely check prices. actually. I look forward to future updates from Android or Samsung. Thank you.

FrediIrwantoAgus commented 2 years ago

Ok

aneonex commented 2 years ago

@e6a6 Thanks for your detailed feedback.

Slight deviations in the interval are possible due to OS limitations/optimizations, performance, and battery savings. Over time, the shift is accumulated relative to the beginning, but not relative to the previous triggering.

I close the issue.