-
Notifications
You must be signed in to change notification settings - Fork 394
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
How to Use Hivedb with WorkManager #676
Comments
Hive does not works well when running on multiple isolates. I would suggest system APIs like shared preferences or secure storage for storing data that's used on background. |
So Can i Use, Hive Simultaneously, Because Hive made literally 80% of the Workspace, it will not be healthy for my Application to bear the baggage. and can you explain the above ones @themisir |
Dart doesn't support sharing memory between isolates. And hive relies on memory after you've opened the box. Due to that limitation on dart (not being able to share memory) Hive box could be get damaged when both isolates are trying to write to it same time. What you can do is:
|
Duplicate of #444 |
@themisir What is the issue exactly? |
Issue is when you open same box on 2 different isolate and make changes isolates can't let each other know that data is changed, so when you write something else on other isolate changes made by first isolate will be overwritten. |
@themisir I could live with data being overwritten my main issue is that the box become corrupted and then all data is lost do you know which specific scenario cause this? |
When multiple un-synced isolates tries to update data on disk they might write different data on same time causing box file to corrupt. Actually I think there's quite low chance of this happening (both writes have to happen at same time), but I can't guarantee, real life use-cases usually far more complex. Also have you tried upgrading hive to |
@themisir thanks for the answers I didn't I'm on |
Yeah, it kinda sucks we haven't found a way to properly solve this issue. The main "system-level" problem is dart doesn't supports shared memory space. So we can't make sure hive instances to talk with each other. We're currently researching ways to implement a "fix" to this issue (#922). |
@themisir Yeah I saw it but I don't have proper input for it I was tempted to check on the |
close the box of the isolates after modifying them (update, create or delete). So :quotesBox.close(); |
Question
I am Not Able to Run HiveDb with WorkManager,
workmanager: ^0.4.0
I am always thankful for the opensource plugin that you have made,
This is very important for all of us developers of flutter to make things work in the background and respect++...
My Issue
In My App,
It is Giving me an Error that .clear() is Called null..
I am Using HiveDB.
I am Using WorkManager
When I am running everything normally, everything is running well and
clearing well, but when I am using work manager it is showing the error,
Version
I am Using Android,
Latest Version of Hive
And WorkManager
The text was updated successfully, but these errors were encountered: