ANR Broadcast of Intent
I have in my app a BroadcastReceiver which is called each X seconds by an ALARM_SERVICE. This BroadcastReceiver calls to another service which is run by an AsyncTask (to try to avoid to block the main thread) but I have received some ANRs from my users and the log that google provide me I'm not able to read it if I'm honest.
Can someone help me to understand the log and to solve the issue?
This is 1 of 11 pages of the log that Google provide me:
DALVIK THREADS: (mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 obj=0x418c8578 self=0x4179e1c0
| sysTid=24081 nice=0 sched=0/0 cgrp=apps handle=1074630652
| state=S schedstat=( 0 0 0 ) utm=1049 stm=265 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x418c8978> (a java.lang.VMThread) held by tid=1 (main)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:159)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:810)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:843)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1173)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:183)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:259)
at android.view.SurfaceView.updateWindow(SurfaceView.java:499)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
"Thread-7562" prio=5 tid=25 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x426ab1b0 self=0x58b6f030
| sysTid=26080 nice=0 sched=0/0 cgrp=apps handle=1488405504
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x426ab370> (a java.lang.VMThread) held by tid=25 (Thread-7562)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7561" prio=5 tid=24 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42a3b5a0 self=0x4177f188
| sysTid=26079 nice=0 sched=0/0 cgrp=apps handle=1488942696
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42a3b6e0> (a java.lang.VMThread) held by tid=24 (Thread-7561)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7514" prio=5 tid=23 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42f6d0b0 self=0x57af4b48
| sysTid=25583 nice=0 sched=0/0 cgrp=apps handle=1471220936
| state=S schedstat=( 0 0 0 ) utm=2825 stm=1344 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42680658> (a java.lang.VMThread) held by tid=23 (Thread-7514)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.android.map.VRMapSurfaceView$VRMapSurfaceViewDrawThread.run(VRMapSurfaceView.java:152)
"Thread-7513" prio=5 tid=21 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42f6cf90 self=0x5190eb28
| sysTid=25582 nice=0 sched=0/0 cgrp=apps handle=1373146856
| state=S schedstat=( 0 0 0 ) utm=0 stm=1 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421dfbc0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:364)
at com.package.packagename.map.VRMapController.waitForNextLoadRequest(VRMapController.java:233)
at com.package.packagename.map.VRMapImageLoader.run(VRMapImageLoader.java:44)
"Timer-11" prio=5 tid=22 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42209970 self=0x58dc5440
| sysTid=25579 nice=0 sched=0/0 cgrp=apps handle=1494663176
| state=S schedstat=( 0 0 0 ) utm=30 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42209970> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:401)
at java.util.Timer$TimerImpl.run(Timer.java:238)
"Thread-7494" prio=5 tid=20 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42b4fe40 self=0x4179adc8
| sysTid=25563 nice=0 sched=0/0 cgrp=apps handle=1099057424
| state=S schedstat=( 0 0 0 ) utm=235 stm=33 core=1
at java.lang.VMThread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1013)
at java.lang.Thread.sleep(Thread.java:995)
at com.package.packagename.map.VRMapView$LongTasksThread.run(VRMapView.java:2806)
"Thread-7449" prio=5 tid=18 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42b4da70 self=0x591612b8
| sysTid=25446 nice=0 sched=0/0 cgrp=apps handle=1494619912
| state=S schedstat=( 0 0 0 ) utm=579 stm=400 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42b4db70> (a java.lang.VMThread) held by tid=18 (Thread-7449)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7354" prio=5 tid=19 WAIT
| group="main" sCount=1 dsCount=0 obj=0x421f0330 self=0x51d8c7e0
| sysTid=24637 nice=0 sched=0/0 cgrp=apps handle=1074503688
| state=S schedstat=( 0 0 0 ) utm=24 stm=3 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421f04a0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:364)
at com.package.packagename.map.VRHeightMapLoadThread.run(VRHeightMapLoadThread.java:113)
"Binder_3" prio=5 tid=17 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x421ecb00 self=0x51d868b0
| sysTid=24493 nice=0 sched=0/0 cgrp=apps handle=1074208152
| state=S schedstat=( 0 0 0 ) utm=139 stm=69 core=1
#00 pc 0001b300 /system/lib/libc.so (__ioctl+8)
#01 pc 0002b91b /system/lib/libc.so (ioctl+14)
#02 pc 0001b539 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001bcd7 /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001fae9 /system/lib/libbinder.so
#05 pc 00011a8d /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216)
#06 pc 0004b631 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+68)
#07 pc 00011581 /system/lib/libutils.so
#08 pc 0000ca58 /system/lib/libc.so (__thread_entry+72)
#09 pc 0000cbd4 /system/lib/libc.so (pthread_create+208)
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #5" prio=5 tid=16 WAIT
| group="main" sCount=1 dsCount=0 obj=0x421dacb8 self=0x51dd65c8
| sysTid=24481 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1373465112
| state=S schedstat=( 0 0 0 ) utm=3 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x421dae10> (a java.lang.VMThread) held by tid=16 (AsyncTask #5)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:159)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2019)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1013)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1073)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
"RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@4216db88"
daemon prio=5 tid=15 WAIT | group="main" sCount=1 dsCount=0 obj=0x4216e7e0 self=0x400b6a18 | sysTid=24414 nice=0 sched=0/0 cgrp=apps handle=1074723664 | state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1 at java.lang.Object.wait(Native Method) - waiting on <0x421b5820...
When alarm is fired then check that service is run or not. If it is running then skip or if not, Then do same work that you are working. Code for check service is run or not:
private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MyService.class.getName().equals(service.service.getClassName())) { return true; } } return false; }
May be, You are starting so many services.
I had the same issue, the problem occurs if you use two threads !:
First run from one thread (eg.: Asynctask):
And then try to use the dao from a other thread (eg.: UI-Thread) -> it will wait forever because of the missing restoreAutocommit from the first task -> this cause the ANR!
the solution is: add a finally to restoreAutocommit
example:
boolean prev = entityDao.disableAutoCommit();
try
{
entityDao.disableAutoCommit();
storeData(data);// if an Exception occurs -> finally is also called
}
finally
{
entityDao.restoreAutocommit(prev);
}
链接地址: http://www.djcxy.com/p/61980.html
下一篇: ANR意向广播