-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Every sixth request to persist data slowed UI #199
Comments
I tried sembast_sqflite and it’s seems to fix the problem. |
Thanks for the report. I'd like to see what is going wrong though in your initial issue. It seems that writing the file is causing the hanging. The cooperator is not doing its (lame) job. indeed sembast_sqflite won't have this issue:
If you can share your original source code, I would be glad to take a look as it is always a pain to try to reproduce a given case. If you cannot some info on how I could reproduce the issue would help:
Thanks! |
I can't provide full source code, but I can help to reproduce the issue. I think there is no need in redux, here is the sample of UI:
Store format: |
Unfortunately |
Indeed native sqlite has a 1MB cursor limit on Android that cannot be changed. sembast itself is not made for big records neither, just the json encoding of such a big record could hang the UI. Like for images and blob, one solution/recommendation is to use an external file for big records and store a reference in sembast. You could use an isolate for encoding and manipulating such file. Alternatively instead of having a list of 4000 maps in one record, a better alternative would be having 4000 map records. This might not fit your current design so maybe sembast is not the best solution here. |
UI hangs when I save a tiny map into neighbor record. Are you sure that lags appear because of untouched big record? |
I need to look at it. My fear is that a compact operation is happening causing the whole file to be written again. This could happen if you are deleting/replacing existing records (the more I know about your usage the better I can try to investigate). I need to tackle this (important) issue unfortunately it won't be in the short term (summertime, sorry...). If you cannot store each map as a record, I would likely go got a custom solution, creating a background isolate and manage the data in files in the isolate (which will likely be a pain). Otherwise you could try hive which is known for having good performance. |
Thanks for help! |
I'm using redux as a state management tool and sembast to persist redux state and to store initial data. When the redux state is changed I update respective records in sembast in middleware. The user is faced with a stack of cards, the state is changed regarding what button he pressed, and then cards change with animation, so the animation is going concurrently with the data persisting. Every sixth animation lags. It looks like sembast can't be used in the UI thread, but as far as I know, there is no way to use sembast in isolate. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: