Stuart-campbell / RushOrm

Object-relational mapping for Android
http://www.rushorm.co.uk/
Other
172 stars 19 forks source link

ANR in AndroidRushQueProvider.blockForNextQue #92

Open fabsimilian opened 8 years ago

fabsimilian commented 8 years ago

We have some ANRs in our Project due to rush queue:

DALVIK THREADS (38):
"main" prio=5 tid=1 Waiting
  | group="main" sCount=1 dsCount=0 obj=0x759306c8 self=0xb4f07800
  | sysTid=17679 nice=0 cgrp=apps sched=0/0 handle=0xb6fa1ec8
  | state=S schedstat=( 0 0 0 ) utm=310 stm=39 core=0 HZ=100
  | stack=0xbe1e7000-0xbe1e9000 stackSize=8MB
  | held mutexes=
  at java.lang.Object.wait!(Native method)
  - waiting on <0x10a7e948> (a java.lang.Object)
  at co.uk.rushorm.android.AndroidRushQueProvider.blockForNextQue(AndroidRushQueProvider.java:26)
  - locked <0x10a7e948> (a java.lang.Object)
  at co.uk.rushorm.core.RushCore.load(RushCore.java:256)
  at co.uk.rushorm.core.RushSearch.find(RushSearch.java:41)

Any ideas how to fix this?

Stuart-campbell commented 8 years ago

Looks like you might need to use the async methods for saves and loads.

Async save is done by calling

object.save(new RushCallback() {
    @Override
    public void complete() {
        /* Callback is on the thread objects where saved on, 
            not thread that called save */
    }
});

You can use a null callback if you don't care about the response.

There is also an async load method on RushSearch. Just need to watch as the callback is not in the main thread.

Cheers