openfoodfacts / smooth-app

The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart

Home Page:https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Enhancement] Improving background tasks

g123k opened this issue · comments

Hi everyone,

We get many complaints from users who don't understand why the application is acting weirdly.
Very often, the root cause is a long list of background tasks that hasn't been able to run.

In a way, background tasks are interesting for longer requests such as photos, but for "simple text", it's more questionable.

What I'd like to enable is the following algorithm on "simple" fields:

  1. Try to send the request immediately with a short timeout
  2. If this doesn't work, transform it into a background task.

Some examples of "simple" fields: update country, website…

Hi @g123k!

The way background tasks work:

  • immediately setting the local product with the new changes
  • immediately giving back to the user the control of the app
  • putting a task in a queue, which is re-run on specific common events (e.g. opening a product page)

I don't know the "weird problems" you're talking about: could you please be more specific?

  • If it's that the server isn't updated at the same time as the app, that's not a bug, that's a feature: we can update products offline or when the server is down.
  • If it's that local data seems to change, it happens if the server doesn't change the data itself, cf. #5394: the user changes the local data, the user sees the changed data locally, the server is called but doesn't change the data, the app downloads the unchanged data, the local data reverts to the value before the user change.

Would it be worth to let users know a bit about background tasks, with a sort of access to the current queue? Definitely. I'm pretty sure most of them have already downloaded a file and seen the download progress.

Some solutions to have more active processes:

  • splitting into several queues - e.g. one queue for the "simple" background tasks and one queue dedicated to heavy stuff like photo upload
  • calling BackgrounsTaskManager.run() in more cases