1

Our game app has a few remaining ANRs that don't fall into the obvious "doing something heavy on the main thread" scenario, but it's still stopping the main thread servicing the input events.

Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 94. Wait queue head age: 5302.9ms.)

For example the main thread is:

  #00  pc 000000000005a7b8  /apex/com.android.runtime/lib/bionic/libc.so (syscall+28)
  #00  pc 00000000000e44e5  /apex/com.android.runtime/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+80)
  #00  pc 0000000000416681  /apex/com.android.runtime/lib/libart.so (art::GoToRunnable(art::Thread*) (.llvm.12260782946460364788)+324)
  #00  pc 0000000000416515  /apex/com.android.runtime/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8)
  at android.os.MessageQueue.nativePollOnce (Native method)
  at android.os.MessageQueue.next (MessageQueue.java:336)
  at android.os.Looper.loop (Looper.java:174)
  at android.app.ActivityThread.main (ActivityThread.java:7386)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:980)

As far as I can see, this is the standard looper response you would see if the main thread was idle, not blocking with work.

The only other game thread created is via the standard GLSurfaceView so has a GLThread, which is also waiting. The callstack indicates that the GLThread is also waiting before executing the C++ NativeTick() function.

Type"GLThread 42541" prio=5 tid=25 Native
  #00  pc 000000000005a7b8  /apex/com.android.runtime/lib/bionic/libc.so (syscall+28)
  #00  pc 00000000000e44e5  /apex/com.android.runtime/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+80)
  #00  pc 0000000000416681  /apex/com.android.runtime/lib/libart.so (art::GoToRunnable(art::Thread*) (.llvm.12260782946460364788)+324)
  #00  pc 0000000000416515  /apex/com.android.runtime/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8)
  at com.rubicon.dev.raz0r.RazorNativeActivity.NativeTick (Native method)
  at com.rubicon.dev.raz0r.Raz0rView.onDrawFrame
  at android.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1581)
  at android.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1280)

The lock is waiting for some work to be added to the looper. So why the ANR?

Is it possible another thread is stopping the main thread from being serviced even though all the other thread are of similar or lower priority?

Steven Haggerty
  • 308
  • 3
  • 15
  • Something is blocking the main thread. Without code we have no idea what. It could be another thread if there's a deadlock condition (another thread holds a resource and the main thread is blocking for it). – Gabe Sechan Sep 28 '21 at 17:55
  • (Post amended to include GLThread) All the other (standard android threads) appear to be to idle, and don't have any of my code in the callstacks. – Steven Haggerty Sep 28 '21 at 21:00

0 Answers0