Is using findAll() safe on main thread in older version?

In the latest version of Realm doc, using findAll() on main thread is not recommended, disabled by default, and can possibly cause ANR for heavy read state in the doc (RealmQuery (Realm 10.10.1))

However, I’m using an older version of Realm and the older doc (RealmQuery (Realm 6.0.0)) doesn’t say that it would drop frame or create ANRs.

My questions are:

  1. Is it still safe to use findAll() on the main thread in an older version of Realm?
  2. What has changed with findAll() in the latest version that would possibly cause frame drop or ANRs? I’m really interested in the underneath mechanism of how Realm is loading data now. If possible, can you please attach the related issue/PR in Github.

Thanks a lot!


The problem has always existed. For small datasets, the queries are generally fast enough that you do not notice, but it is hard to give exact guidance as to when it becomes “too slow” as that depends on a lot of factors like the size of the data and what device you are running on.

It is for that reason we decided to disable it by default, it is safer, and for most cases, it should be a trivial refactor to change to findAllAsync().

If for some reason you still want the old behaviour you can just enable RealmConfiguration.allowQuriesOnUiThread() to get the old behaviour RealmConfiguration.Builder (Realm 10.10.1)