tekartik / sembast.dart

Simple io database
BSD 2-Clause "Simplified" License
780 stars 64 forks source link

[Web] Using CircularProgressIndicator stalls database transactions on slow machines #311

Open felix-ht opened 2 years ago

felix-ht commented 2 years ago

If one uses the CircularProgressIndicator all database inertaction are much slower. This is much more pronounced on slow machines and on the web. If large amounts of data are written to the db or the db is initially opened (with data stored), this can change response times from seconds to multiple minutes.

Might be related to this:

https://github.com/flutter/flutter/issues/73766

This is especially easy run into because showing a spinner while some interaction is running is pretty typical.

alextekartik commented 2 years ago

Thanks for the report, indeed sembast run in the main isolate so can be slow down if heavy UI is running (which is maybe the case for the circular progress indicator). I don't think it is related with the flutter bug you point too.

sembast has a weird concept of cooperator to allow heavy computation (sort, query, write) in the main isolate and let other pending ui task run using some timing and pauses

Some info:

What you can try is to disable the cooperator, the risk being that the UI may hang for heavy database operation or to tune the timing parameters (unfortunately I don't have good clue, the experiment was made using Chrome on Android).

felix-ht commented 2 years ago

Thanks I will test disabling the cooperator!