0

我们的游戏应用程序还有一些剩余的 ANR,它们不属于明显的“在主线程上做一些繁重的事情”场景,但它仍然停止服务输入事件的主线程。

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.)

例如主线程是:

  #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)

据我所知,如果主线程处于空闲状态,而不是阻塞工作,这是标准的循环器响应。

唯一的其他游戏线程是通过标准 GLSurfaceView 创建的,因此有一个 GLThread,它也在等待。调用堆栈表明 GLThread 在执行 C++ NativeTick() 函数之前也在等待。

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)

锁正在等待将一些工作添加到 looper。那么为什么是 ANR?

即使所有其他线程具有相似或较低的优先级,是否有可能另一个线程正在停止主线程的服务?

4

0 回答 0