我刚刚收到了一个奇怪的 ANR 报告,看着涉及的 3 个线程,好像 transact() 方法阻塞了 UI!任何人都可以确认吗?
可能会产生误导,但 tid 23, line ~887 实际上是这种方法:
synchronized public void doSomething()
{
// No sync in here, no API calls either
}
为什么会这样?虚假报道?操作系统错误?应用程序错误?以后如何避免这种情况?
需要明确一点:主线程正在响应 android.app.Activity.finish() 处的后退按钮,但被 tid=21 阻止,tid=21 是一个调用 getApplicationInfo() -> transact() 的异步任务
以下是所涉及的 3 个线程的堆栈跟踪:
"main" prio=5 tid=1 MONITOR
| group="main" sCount=1 dsCount=0 obj=0x40aed9a0 self=0x1772cb0
| sysTid=30378 nice=0 sched=0/0 cgrp=apps handle=1074254812
| state=S schedstat=( 0 0 0 ) utm=537 stm=93 core=1
at android.app.Activity.finish(Activity.java:~4138)
- waiting to lock <0x40fa7008> (a my.app.package.activities.tm.at_process_tabs) held by tid=21 (AsyncTask #3)
at android.support.v4.app.FragmentActivity.onBackPressed(SourceFile:175)
at android.app.Activity.onKeyUp(Activity.java:2145)
at android.view.KeyEvent.dispatch(KeyEvent.java:2633)
"AsyncTask #4" prio=5 tid=23 MONITOR
| group="main" sCount=1 dsCount=0 obj=0x41364a68 self=0x1ca4ec0
| sysTid=30749 nice=-1 sched=0/0 cgrp=apps handle=28938832
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at my.app.package.activities.tm.at_process_tabs.a(SourceFile:~887)
- waiting to lock <0x40fa7008> (a my.app.package.activities.tm.at_process_tabs) held by tid=21 (AsyncTask #3)
at my.app.package.activities.tm.x.a(SourceFile:95)
at my.app.package.activities.tm.x.b(SourceFile:1)
at my.app.package.utils.android.d.call(SourceFile:203)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
"AsyncTask #3" prio=5 tid=21 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x41327370 self=0x1b982a0
| sysTid=30747 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=34484768
| state=S schedstat=( 0 0 0 ) utm=47 stm=5 core=0
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.getApplicationInfo(IPackageManager.j...