Live Query blocking UI thread

Hi jens | priya,

@priya.rajagopal as per our disccusion this should be fixed by associate db instance with background thread but it’s not. I have updated couchbase lite 2.5.0. Thanks for early release.

Couchbase Lite 2’s query listener implementation runs the queries on the database’s default thread.
Not agree as per code queries always run on DefaultExecutor. and DefaultExecutor uses main looper(Looper.getMainLooper()) which makes queries run inside main thread(UI thread).
If we want to run query listener implementation in database’s default thread then we have to use current thread looper (Looper.getMyLooper()). please correct me if I am wrong.

Workaround is to use a db instance that’s associated with a background thread.
I have checked by associating db instance to a background thread, but still UI freeze( running inside UI thread).

Suggestion

  1. DefaultExecutor implementation change, we can use Looper.getMyLooper() in place of Looper.getMainLooper() which always run queries in DB associated thread.
  2. Inject executor in Start() method of LiveQuery class. It will fix our problem.
  3. Change DefaultExecutor to a new single thread executor.

Please suggest us better approach from them or other work around.
@priya.rajagopal I apologize for the urgency, but could you provide us solution as soon as possible.

Thanks!