fix(updates): fix update getting skipped for large number of available updates
Description
App Lounge was skipping updates for large number of apps, and user had to try "Update All" multiple times to complete updating of all apps.
Rik reported the behaviour here with the following screen record:
App Lounge only updated an X number of apps per time when I clicked "Update All", between 2 and 18, average about 8. I had 64 apps to update, it took me 8 times clicking "Update All" in total
This MR fixes the behaviour by introducing a chunk-based mechanism so that instead of trying to enqueue all the app updates at once, App Lounge now batches the updates and process them chunk by chunk.
Screenshots
Technical details
Problem
We introduced this buggy behaviour here few months ago.
A CoroutineWorker has 10 minutes for execution and returning a result. Failed to do so, it's signalled to stop which sets its isStopped property to true.
UpdatesWorker.startUpdateProcess() loops through a list of updates and tries to enqueue update one by one using appInstallProcessor.initAppInstall().
Every initAppInstall() call does many things under the hood and takes time to complete. That's why, for large number of apps, the 10-minute execution window for CoroutineWorker finishes and Android siganals it to stop which makes the isStopped to true.
Because of the isStopped check, the loop continues to run, but no app actually gets enqueued. From Rik's experience, after on average 8 apps, the CoroutineWorker would get a stop signal and skip the enqueueing.
Solution
Legend:
- Snapshot = frozen update list for one Update All run
- chainId = shared id across all workers in the same run
- Skip = harmless no-op, not a chain failure
Tests
Issues
https://gitlab.e.foundation/e/os/backlog/-/work_items/4235
https://gitlab.e.foundation/e/os/backlog/-/work_items/4289
