Random app freez on Android

Android app sometimes freez without any stable cause. It may happens on different Activities, during switch between Activity, scroll, click, nothing. We don't perfrom network/IO operations in UI thread, don't call long methods. It seems that problem like here: forums.xamarin.com/discussion/7011/random-rare-freezes-trying-to-figure-out-possible-causes, but i looked throught project and there is nothing UI call from background thread. I tried attach ANR WatchDog (https://github.com/SalomonBrys/ANR-WatchDog), it create background thread that peroidically send post() to main thread. I add log to every WatchDog iteration and see that when app freeze background watcher's thread freeze too.

In trace log one thread seems to be locked by himself (full log in attach, package "com.mypackage.myapp"):

"pool-1-thread-1" prio=5 tid=17 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x41c45ab0 self=0x72486840
  | sysTid=18053 nice=0 sched=0/0 cgrp=apps handle=1917349016
  | state=S schedstat=( 88740459 32261249 195 ) utm=5 stm=3 core=3
  at java.lang.Object.wait(Native Method)
  - waiting on <0x41c45bf8> (a java.lang.VMThread) held by tid=17 (pool-1-thread-1)
  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:157)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
  at java.lang.Thread.run(Thread.java:841)

In debugger (in Android Studio) i see all this threads, "main" and "ANR WatchDog" mark as "RUN", but really they freez.
Most often it happens after 1-5 seconds after detach usb cable. I have not idea how it can cause freeze.

Sign In or Register to comment.