getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
702 stars 1.35k forks source link

Fix Database access ANRs #5838

Open seadowg opened 7 months ago

seadowg commented 7 months ago

An example was reported here.

Our forms and instances databases should not be accessed the UI thread. We can use StrictMode.noteSlowCall in our DatabaseConnection (on accessing a writable or readable DB) to detect these in debug builds and instrumented tests.

seadowg commented 5 months ago

After the work done in https://github.com/getodk/collect/pull/5867, the main focus to get this done is to be able to call StrictMode.noteSlowCall("Accessing readable DB") in DatabaseConnection instead of in the database backed repository implementations and have all tests passing.

seadowg commented 1 month ago

The goal here now will be to remove the strict parameter from DatabaseConnected (always call noteSlowCall on DB accesses).

seadowg commented 1 month ago

It looks like a significant rewrite (replacing InstanceChooserList most noteably) is required to make any more progress here so let's move it to the next release.