DataMonitor icon indicating copy to clipboard operation
DataMonitor copied to clipboard

Incorrect data rollover computation in Smart Data Allocation

Open lfos opened this issue 1 year ago • 5 comments

Checklist

  • [X] I am able to reproduce the bug with the latest version.
  • [X] I made sure that there are no existing issues - open or closed.
  • [X] I have taken the time to fill in all the required details in an appropriate descriptive way. I understand that the bug report will be dismissed otherwise.
  • [X] This issue contains only one bug.

Affected app version

v2.4.0

Steps to reproduce the bug

  • Enable Smart Data Allocation with Custom Plan. (I am not yet sure whether or not using a Custom Plan matters.)
  • For a few days, use no/little data (i.e., significantly below daily quota) and let data roll over.

Expected behavior

Data gracefully rolls over at the end of day, keeping daily quota always below remaining data left.

Actual behavior

Daily quota seems to grow much more than expected, after a few days even exceeding total available data on plan.

Screenshots/Screen recordings

Screenshot_20240401-141743~2

Logs

No response

Affected Android/Custom ROM version

Android 14

Affected device model

Pixel 7

Additional context

Let me know if there's more information that'd be useful to have for troubleshooting.

lfos avatar Apr 01 '24 08:04 lfos

Next day after the screenshot in the original report was taken, and daily quota is now at 19.6GB. Note that this is rougly a doubling from yesterday's quota. Could there be a bug where the current quota is accidentally added to the daily rollover?

lfos avatar Apr 02 '24 05:04 lfos

Next day after the screenshot in the original report was taken, and daily quota is now at 19.6GB. Note that this is rougly a doubling from yesterday's quota. Could there be a bug where the current quota is accidentally added to the daily rollover?

Looking at the code, this guess seems to be correct; new quota is currently computed as 2 * dailyQuota - dataUsage in DataRolloverHelper, leading to the observed exponential quota growth. One way to address this is to separate "original" daily quota and current rollover amount:

  1. Original daily quota is computed once, when Smart Data Allocation is enabled, and never modified (unless the plan or Smart Data Allocation settings are changed). Computation spreads available data evenly across remaining days; optionally with the enhancement proposed in issue #235.
  2. At the end of a day, new rollover amount is computed as current rollover amount + original daily quota - daily data usage.
  3. Actual (displayed and enforced) daily quota is original daily quota + current rollover amount.

As a bonus, with these changes issue #236 becomes quite simple to implement: After adding the option, all that's needed is to omit addition of current rollover amount in step 3 above.

lfos avatar Apr 02 '24 05:04 lfos

@lfos Thanks for your input. Indeed, this particular behaviour seems to be caused due to the rollover of the remaining data entirely to the following day, causing a large accumulation over time. New quota is currently calculated by adding / subtracting the remaining / excess data as per the use case. Will have to implement some checks in place to fix the behaviour. Thanks again for suggestion.

itsdrnoob avatar Apr 02 '24 15:04 itsdrnoob

@itsdrnoob - Thanks! A small nit: Rollover of the entierty of remaining data does not seem to be the issue. The problem is that DataMonitor "forgets" what the proper quota of the "next day" should be, and assumes it's the same as the current day's quota (which includes "original quota" and rollover, thus doubling the rollover amount). Thus the proposal above to keep track of both "original quota" and rollover amount separately.

lfos avatar Apr 07 '24 06:04 lfos