Skip to content
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

Browser crashing using a large dataset #296

Open
yannisoo opened this issue Dec 11, 2021 · 1 comment
Open

Browser crashing using a large dataset #296

yannisoo opened this issue Dec 11, 2021 · 1 comment

Comments

@yannisoo
Copy link

Hi, I've been looking for a way to store large amount of data with flutter on a Web/iOS/Android app. For my project I need to use a large set of data (48mb) which I can get through either json or sqlite. I then want to store it within my flutter app. However when I try to store my data decoded from json my browser freezes without any error indicating something is going wrong. I tried with a "smaller" json (4.7mb) but nothing I'm facing the same issue. Is there any work around to this ? Thanks in advance!

@alextekartik
Copy link
Collaborator

I'm not sure what solution you are using currently to store your data. I'm assuming that you using sembast io (but I recommend sembast_sqflite) and sembast web.
Since sembast run on the UI thread a big map could indeed freeze during (sembast also encodes the data as json)

Storing a 48MB json as a single record won't work on sembast (with sqlite backend, records are limited to 1Mb on some platforms).

If you want to store raw json as a string, on mobile you could use compute to encode/decode map/list to/from string in a different isolate.
On the web, if you have json that freezes the UI when decoding/encoding there is nothing much we can do but to split the json in smaller parts stored separately.

You can then store the big string in indexed_db (web) or file system (io). fs_shim allow writing big data as a file on any platform or you can use any other key value database (hive).

If you can split your data in small records, sembast should work, see some recommendations

Maybe I misunderstood your question...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants