-
-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Background tasks freeze up the whole UI #5933
Comments
I think you're referring more specifically to massive downloads like language refresh.
No they don't. It's just that obviously we don't download the whole database in one shot: the servers wouldn't allow that many records (currently we download products with a standard "get products by barcode" query) and it's safer to split in case it crashes. Therefore, when a split background task ends, it calls the next split background task. Btw we're downloading from 4 servers now. The background task labels may not be explicit enough, I'll give you that.
They definitely shouldn't. They're not supposed to either. Worst case is when you have a very good connection: many background tasks being called rapidly in sequence.
Not that easy in flutter, probably using https://pub.dev/packages/workmanager, but that would demand many careful tests on android and on iOS. And different implementations on other platforms, if relevant.
Fair enough.
Fair enough. |
The app keeps freezing whenever I change languages |
A solution would be to say: after all, changing languages shouldn't be treated lightly, and instead of expecting background tasks to deal with that "in the background", we'd rather create a specific page that does the whole work, with a progression indicator. That would take 10 minutes (to process, not to code) and that would be done. |
it's not about the speed, it is about the UI freezing. It seems to me that preventing this is one of the main purposes of isolates: https://docs.flutter.dev/perf/isolates |
It's about something hidden in the background that prevents the foreground to work well.
We do use isolates in Smoothie, for a single case: image compression (i.e. for crops only). Reading again the isolate docs, it looks like the only potential case where we'd need isolates for language refresh is when we decode the received json (the rest being data download and saving data into the database, and none of them are "intense computations"). My hunch is rather that something fails again and again in the language refresh. So you'll take a step in my direction, and let me code a page where we actually track what the language refresh tasks do. |
This is fixed now in #6038 (the database queries were slow and blocking, and too many queries were called in vain), and anyway even with a good connection we're limited by the number of requests to the server per minute, so the whole process cannot be "too fast".
I've added the product type to the language refresh background task label.
It already works like that: each incremental action is "download the next 20 local products that don't have the current app language". |
What
Proposed solution
Screenshot/Mockup/Before-After
screen-20241125-164738.mp4
The text was updated successfully, but these errors were encountered: