跑Monkey过程中出现的ANR问题分析

 

1.【压力测试】Monkey跑全模块,com.android.documentsui 出现ANR问题

查看trace并没有发现什么异常,mainlog中显示CPU使用:
101% 227/mobile_log_d: 16% user + 84% kernel / faults: 69 minor
55% TOTAL: 21% user + 33% kernel + 1% iowait
根据Eventlog中显示ANR的发生时间点是51秒
01-04 09:27:51.027 760 775 I am_anr : [0,26870,com.android.documentsui,952680005,Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)]
查看对应的进程26870启动只和报ANR的时间点相差1秒
01-04 09:27:50.049971 760 23012 I ActivityManager: AMS: *** Start proc 26870:com.android.documentsui/u0a9 for activity com.android.documentsui/.FilesActivity
1秒的时间间隔应该是不会出现ANR问题,继续查找在此之前还启动了一个documentsui进程26802但是随即已经被杀死
01-04 09:27:42.375031 760 3603 I ActivityManager: AMS: *** Start proc 26802:com.android.documentsui/u0a9 for activity com.android.documentsui/.LauncherActivity
01-04 09:27:42.902997 760 2026 I ActivityManager: Process com.android.documentsui (pid 26802) has died
查看进程的启动到完成的时间是间隔了十秒
01-04 09:27:42.308526 760 8789 I ActivityManager: START u0

{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.documentsui/.LauncherActivity}
from uid 2000 on display 0
01-04 09:27:42.646926 760 15852 I ActivityManager: START u0

{dat=//com.android.documentsui.launchControl flg=0x10200000 cmp=com.android.documentsui/.FilesActivity (has extras)}
from uid 10009 on display 0
01-04 09:27:53.391940 760 783 I ActivityManager: Displayed com.android.documentsui/.FilesActivity: +10s715ms (total +11s42ms)
这个启动时间和26802进程与26870进程启动的间隔几乎相等,怀疑和AMS有关
分析log发现:
01-04 09:27:42.375 760 3603 I ActivityManager: AMS: *** Start proc 26802:com.android.documentsui/u0a9 for activity com.android.documentsui/.LauncherActivity
01-04 09:27:42.903 760 2026 D ActivityManager: handleAppDiedLocked: app = ProcessRecord

{c686e1e 26802:com.android.documentsui/u0a9}
, app.pid = 26802
01-04 09:27:42.903 760 2026 D ActivityManager: cleanUpApplicationRecord – 26802
从出生到结束的时间很短。
期间:
01-04 09:27:42.803 760 5544 D ActivityManager: AMS: doLMKCrazyClean (3) Normal start {{{{
也就是说LMKCrazyClean杀死了他,导致他的触摸事件没来得及处理,导致ANR。

由于手机为低内存,Monkey启动了太多应用,优先级低的就可能被杀死。
解决方式,让LMKCrazyClean添加白名单,或者下载模块添加临时优先级保护。
出现anr的问题原因如下:
在09:27:42时间点附近启动了FilesActivity,并将焦点切换到了此app上
01-04 09:27:42.653413 760 15852 I am_create_activity: [0,220999959,4820,com.android.documentsui/.FilesActivity,NULL,NULL,//com.android.documentsui.launchControl,271056896]
01-04 09:27:42.665296 760 15852 I am_focused_activity: [0,com.android.documentsui/.FilesActivity,startedActivity]
在此之后,documentsui进程被杀了
01-04 09:27:42.903073 760 2026 I am_proc_died: [0,26802,com.android.documentsui]
因为前台进程被杀,所以重启了前台进程的activity,开始了下一轮start proc for activity
01-04 09:27:50.049805 760 23012 I am_proc_start: [0,26870,10009,com.android.documentsui,activity,com.android.documentsui/.FilesActivity]
进程刚启动,activity的启动暂未完成,因焦点仍在该app上,但是activity没有绘制完成,有焦点app没有焦点activity, 所以发生了anr
01-04 09:27:51.027798 760 775 I am_anr : [0,26870,com.android.documentsui,952680005,Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)]

现在有2个问题:
1,怎么died的?
对应的时间段的kernel.log丢失了,无法确认是否是lmk杀死进程,但是查看anr时间点的memory dump发现当前的内存状态非常的紧张
Total RAM: 987,940K (status critical)
Free RAM: 186,208K ( 0K cached pss + 127,824K cached kernel + 53,552K free + 4,832K ion cached + 0K gpu cached)
Used RAM: 993,954K ( 852,482K used pss + 134,960K kernel + 28K trace buffer + 6,484K ion disp + 0K cma usage)
Lost RAM: -26,430K
ZRAM: 82,216K physical used for 310,504K in swap ( 493,968K total swap)
Tuning: 128 (large 256), oom 225,280K, restore limit 37,546K (high-end-gfx)
另外进程被杀时间点前后出现了频繁的doLMKCrazyClean, kill次数超过4次,每次kill时间间隔不超过1s,包含了2次deep kill
综上所诉,怀疑此次died是低内存杀进程导致,查看系统当时存在的进程,发现B类service仍然存在在系统中
22,359K: B Services
9,385K: com.android.mms (pid 26647)
8,278K: com.google.android.apps.translate:copydrop (pid 26093)
4,696K: com.mediatek.FMRadio (pid 27218)
B类service的adj为8,其实比较低了,可以考虑杀掉,降低系统内存压力
2,为什么前台进程的死掉和重启之间等待了7s?
在activity重启的过程中47s左右出现了动画切换超时问题app_transition_timeout
01-04 09:27:47.654253 760 783 V WindowManager: *** APP TRANSITION TIMEOUT. isTransitionSet()=true mOpeningApps.size()=1 mClosingApps.size()=3
APP TRANSITION TIMEOUT消息是在prepareAppTransition中设置的,在activity resume完成后会进行执行切换动画操作,并将timeout message移除出队列,出现该log说明当前系统进行activity启动调度缓慢,超过了5s的时间activity仍然没有完成resume操作
查看此时间段内的sys_log以及main_log发现在此时间内系统关键服务log极少,一秒就一行log,kernel.log缺失,anr出现后实际上系统已经开始正常的执行activity启动调度,吞吐Log也很正常,打印的trace无法说明出现问题时间段的系统信息,因缺失log,无法确定当前系统状态,无法分析

如上分析,建议针对低内存进行优化,避免出现前台进程被杀导致anr问题的存在

2.Monkey全模块出现// ANR in system:ui

从traces_2.txt的trace分析,应该是在启动ResolverActivity过程中,system:ui进程会通过binder调用WindowManagerService的relayoutWindow方法。但是此时WindowManagerService正在做screenshotApplicationsInner(截屏)处理。在做截屏处理的过程中,会给mWindowMap加锁。而relayoutWindow的调用,也需要这把锁。由于screenshotApplicationsInner过程被SurfaceFlinger阻塞,导致relayoutWindow的调用无法返回,进而导致system:ui进程阻塞从而发生ANR。

但是SurfaceFlinger的native trace log中没有找到。

从log中找到了ResolverActivity启动过程中的时间戳:

mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3791:04-12 08:34:37.045  1045  1190 I am_create_task: [0,4237]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3792:04-12 08:34:37.045  1045  1190 I am_create_activity: [0,154909728,4237,android/com.android.internal.app.ResolverActivity,android.intent.action.MAIN,NULL,NULL,276824064]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3793:04-12 08:34:37.048  1045  1190 I wm_task_created: [4237,1]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3794:04-12 08:34:37.049  1045  1190 I wm_task_moved: [4237,1,35]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3795:04-12 08:34:37.050  1045  1190 I wm_task_moved: [4237,1,35]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3796:04-12 08:34:37.060  1045  1190 I am_focused_activity: [0,android/com.android.internal.app.ResolverActivity,startedActivity]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3797:04-12 08:34:37.061  1045  1190 I am_pause_activity: [0,223171573,com.gy.cy/com.gangyun.makeup.gallery3d.makeup.MakeUpActivity]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3798:04-12 08:34:37.064 32357 32357 I am_on_paused_called: [0,com.gangyun.makeup.gallery3d.makeup.MakeUpActivity,handlePauseActivity]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3802:04-12 08:34:37.118  1045  2094 I am_proc_start: [0,32408,1000,system:ui,activity,android/com.android.internal.app.ResolverActivity]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3838:04-12 08:34:37.208  1045 32344 I am_proc_bound: [0,32408,system:ui]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3839:04-12 08:34:37.227  1045 32344 I am_restart_activity: [0,154909728,4237,android/com.android.internal.app.ResolverActivity]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3844:04-12 08:34:45.201 32408 32408 I am_on_resume_called: [0,com.android.internal.app.ResolverActivity,LAUNCH_ACTIVITY]
mtklog/aee_exp/db.03.ANR/20170418_115652_097/db.03.ANR.dbg.DEC/SYS_ANDROID_EVENT_LOG:3845:04-12 08:34:45.243  1045  1099 I am_anr  : [0,32408,system:ui,952679945,Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)]

ResolverActivity的启动时序如下:

  • 08:34:37.045 am_create_activity 表示 调用了startActivity;
  • 08:34:37.118 am_proc_start 表示创建system:ui进程成功;
  • 08:34:37.208 am_proc_bound 表示system:ui attachAppicaiton成功;
  • 08:34:37.227am_restart_activity 表示AMS发起handleLaunchActivity的调用
  • 08:34:45.201 am_on_resume_called 表示ResolverActivity的onResume被调用

从am_restart_activity到am_on_resume_called,这期间花费了将近8秒的时间。

而在mtklog/aee_exp/db.03.ANR/20170418_115732_148/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG中,可以发现system:ui加载资源是发生在04-12 08:34:37.276,说明am_restart_activity很及时的得到了处理。

SYS_ANDROID_LOG

SYS_ANDROID_LOG:5626:04-12 08:34:37.262 32408 32408 W asset   : AssetManager-->addDefaultAssets isok4 is true
SYS_ANDROID_LOG:5638:04-12 08:34:37.276 32408 32408 I LoadedApk: No resource references to update in package com.transsion.theme.icon

所以,真正的ANR原因,应该可能出在ResolverActivity的onCreate,onStart,onResume过程中消耗的时间时间过多。耗时过多的原因可能为:

  • 在onCreate,onResume过程中做了耗时的操作
  • 没有抢占到cpu,system:ui进程出于freeze状态

分析了ResolverActivity的代码,在上述过程中,并不存在耗时的操作。唯一可能导致耗时的操作是ResolverActivity中存在和system_server进程中的AMS,PMS的交互。根据发生ANR的时候,系统的cpu usage为70%,但是system:ui的使用率居然为0,这点不是很正常。加上system_server过高的使用率,推测此ANR是由于system:ui抢占不到cpu或者是在onCreate的过程中,与AMS和PMS的交互花费了较长时间,导致ANR的发生。

monkey.txt中log如下:

ANR in system:ui (android/com.android.internal.app.ResolverActivity), time=68980227
Reason: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)
Load: 13.37 / 10.24 / 8.67
Android time :[2017-04-12 08:34:48.93] [68983.977]
CPU usage from 136564ms to 0ms ago (2017-04-12 08:32:28.625 to 2017-04-12 08:34:45.189):
  87% 1045/system_server: 70% user + 16% kernel / faults: 331683 minor 4694 major
  34% 315/surfaceflinger: 13% user + 20% kernel / faults: 19719 minor 126 major
  21% 1843/com.android.systemui: 16% user + 5.1% kernel / faults: 140832 minor 1179 major
  11% 207/exe_cq: 0% user + 11% kernel
  6.6% 16457/com.mediatek.FMRadio: 4.4% user + 2.1% kernel / faults: 39531 minor 1567 major
  6.4% 272/logd: 2.1% user + 4.3% kernel / faults: 2767 minor 85 major
  5.5% 323/mobile_log_d: 3.1% user + 2.3% kernel / faults: 4406 minor 10 major
  0.2% 27544/com.android.inputmethod.latin: 0.1% user + 0% kernel / faults: 49039 minor 299 major
  2.8% 208/mmcqd/0: 0% user + 2.8% kernel
  3% 87/kswapd0: 0% user + 3% kernel
  0.5% 28083/kworker/u17:0: 0% user + 0.5% kernel
  2.3% 2047/com.android.phone: 1.7% user + 0.6% kernel / faults: 20033 minor 233 major
  2.3% 22717/kworker/u17:3: 0% user + 2.3% kernel
  2.2% 18369/com.android.commands.monkey: 1.5% user + 0.7% kernel / faults: 9515 minor 68 major
  0.1% 73/ion_mm_heap: 0% user + 0.1% kernel
  2% 314/servicemanager: 0.7% user + 1.2% kernel / faults: 447 minor 1 major
  0.8% 2651/com.transsion.phonemanager: 0.3% user + 0.4% kernel / faults: 19432 minor 2242 major
  0.3% 355/audioserver: 0.1% user + 0.1% kernel / faults: 3014 minor 236 major
  1.1% 2271/com.android.contacts: 0.6% user + 0.4% kernel / faults: 24650 minor 1424 major
  1.1% 3185/adbd: 0% user + 1% kernel / faults: 6593 minor
  0.3% 20109/com.google.android.gms.persistent: 0.1% user + 0.2% kernel / faults: 22811 minor 1158 major
  1.1% 328/aal: 0.2% user + 0.8% kernel / faults: 472 minor
  0% 27646/com.google.android.gms: 0% user + 0% kernel / faults: 28195 minor 719 major
  0% 16052/android.process.media: 0% user + 0% kernel / faults: 14802 minor 161 major
  0.9% 112/hps_main: 0% user + 0.9% kernel
  0.8% 353/zygote64: 0.1% user + 0.7% kernel / faults: 14044 minor 1 major
  0.7% 342/fuelgauged: 0% user + 0.7% kernel / faults: 358 minor 1 major
  0.6% 1829/sdcard: 0% user + 0.5% kernel / faults: 450 minor 25 major
  0% 2161/sdcard: 0% user + 0% kernel / faults: 328 minor 16 major
  0.3% 143/present_fence_w: 0% user + 0.3% kernel
  0.4% 220/bat_routine_thr: 0% user + 0.4% kernel
  0% 359/installd: 0% user + 0% kernel / faults: 289 minor 7 major
  0% 1//init: 0% user + 0% kernel / faults: 233 minor
  0.3% 10963/kworker/u16:1: 0% user + 0.3% kernel
  0.2% 7/rcu_preempt: 0% user + 0.2% kernel
  0.2% 10/migration/0: 0% user + 0.2% kernel
  0.1% 26703/kworker/u16:3: 0% user + 0.1% kernel
  0.2% 17173/com.google.android.youtube: 0.1% user + 0% kernel / faults: 5475 minor 91 major
  0% 16303/android.process.acore: 0% user + 0% kernel / faults: 5201 minor 229 major
  0.1% 27804/kworker/u16:4: 0% user + 0.1% kernel
  0.1% 22506/kworker/u16:2: 0% user + 0.1% kernel
  0.1% 23/migration/4: 0% user + 0.1% kernel
  0.1% 27/migration/5: 0% user + 0.1% kernel
  0.1% 2425/ged_srv: 0% user + 0.1% kernel / faults: 936 minor 11 major
  0.1% 31/migration/6: 0% user + 0.1% kernel
  0.1% 247/jbd2/mmcblk0p28: 0% user + 0.1% kernel
  0.1% 11/migration/1: 0% user + 0.1% kernel
  0% 35/migration/7: 0% user + 0% kernel
  0.1% 222/bat_update_thre: 0% user + 0.1% kernel
  0.1% 8/rcu_sched: 0% user + 0.1% kernel
  0% 330/media.codec: 0% user + 0% kernel / faults: 634 minor 246 major
  0.1% 329/vtservice: 0% user + 0% kernel / faults: 406 minor
  0% 15/migration/2: 0% user + 0% kernel
  0% 2062/com.rlk.powersavemanagement: 0% user + 0% kernel / faults: 5052 minor 167 major
  0% 2/kthreadd: 0% user + 0% kernel
  0% 313/lmkd: 0% user + 0% kernel / faults: 220 minor 1 major
  0% 365/netd: 0% user + 0% kernel / faults: 824 minor 8 major
  0% 197/kworker/5:1H: 0% user + 0% kernel
  0% 15670/kworker/4:0: 0% user + 0% kernel
  0% 72/cfinteractive: 0% user + 0% kernel
  0% 354/zygote: 0% user + 0% kernel / faults: 2833 minor 258 major
  0% 19/migration/3: 0% user + 0% kernel
  0% 113/pbm: 0% user + 0% kernel
  0% 216/kworker/4:1H: 0% user + 0% kernel
  0% 29727/com.mediatek.mtklogger: 0% user + 0% kernel / faults: 4772 minor 64 major
  0% 196/kworker/6:1H: 0% user + 0% kernel
  0% 160/btif_rxd: 0% user + 0% kernel
  0% 194/kworker/7:1H: 0% user + 0% kernel
  0% 32/ksoftirqd/6: 0% user + 0% kernel
  0% 141/display_check_a: 0% user + 0% kernel
  0% 217/mmcqd/1: 0% user + 0% kernel
  0% 2570/com.reallytek.weather: 0% user + 0% kernel / faults: 4510 minor 43 major
  0% 6949/kworker/5:1: 0% user + 0% kernel
  0% 22297/mtkmal: 0% user + 0% kernel / faults: 1871 minor 1 major
  0% 22572/mtkrild: 0% user + 0% kernel / faults: 1577 minor 5 major
  0% 223/mtk charger_hv_: 0% user + 0% kernel
  0% 10249/kworker/6:2: 0% user + 0% kernel
  0% 17773/com.android.gallery3d: 0% user + 0% kernel / faults: 2080 minor 83 major
  0% 24/ksoftirqd/4: 0% user + 0% kernel
  0% 28/ksoftirqd/5: 0% user + 0% kernel
  0% 137/disp_idlemgr: 0% user + 0% kernel
  0% 317/mtk_stp_psm: 0% user + 0% kernel
  0% 320/mtk_wmtd: 0% user + 0% kernel
  0% 362/media.extractor: 0% user + 0% kernel / faults: 430 minor 170 major
  0% 364/mediaserver: 0% user + 0% kernel / faults: 517 minor 166 major
  0% 22429/gsm0710muxd: 0% user + 0% kernel / faults: 478 minor 2 major
  0% 22668/rilproxy: 0% user + 0% kernel / faults: 1243 minor 9 major
  0% 27238/kworker/4:1: 0% user + 0% kernel
  0% 3/ksoftirqd/0: 0% user + 0% kernel
  0% 36/ksoftirqd/7: 0% user + 0% kernel
  0% 224/kworker/0:1H: 0% user + 0% kernel
  0% 225/ueventd: 0% user + 0% kernel / faults: 108 minor 40 major
  0% 5/kworker/0:0H: 0% user + 0% kernel
  0% 142/disp_delay_trig: 0% user + 0% kernel
  0% 340/thermal: 0% user + 0% kernel / faults: 451 minor
  0% 15419/kworker/0:2: 0% user + 0% kernel
  0% 16649/com.google.android.gms.feedback: 0% user + 0% kernel / faults: 3281 minor 297 major
  0% 12/ksoftirqd/1: 0% user + 0% kernel
  0% 18/kworker/2:0H: 0% user + 0% kernel
  0% 215/kworker/1:1H: 0% user + 0% kernel
  0% 663/kworker/2:2: 0% user + 0% kernel
  0% 12587/kworker/0:0: 0% user + 0% kernel
  0% 23729/kworker/3:2H: 0% user + 0% kernel
  0% 24220/kworker/0:3: 0% user + 0% kernel
  0% 13/kworker/1:0: 0% user + 0% kernel
  0% 14/kworker/1:0H: 0% user + 0% kernel
  0% 16/ksoftirqd/2: 0% user + 0% kernel
  0% 17/kworker/2:0: 0% user + 0% kernel
  0% 20/ksoftirqd/3: 0% user + 0% kernel
  0% 26/kworker/4:0H: 0% user + 0% kernel
  0% 34/kworker/6:0H: 0% user + 0% kernel
  0% 199/wdtk-0: 0% user + 0% kernel
  0% 201/wdtk-2: 0% user + 0% kernel
  0% 214/kworker/2:1H: 0% user + 0% kernel
  0% 221/kworker/2:1: 0% user + 0% kernel
  0% 287/vold: 0% user + 0% kernel / faults: 516 minor 56 major
  0% 304/healthd: 0% user + 0% kernel / faults: 12 minor 24 major
  0% 307/wmt_launcher: 0% user + 0% kernel / faults: 331 minor
  0% 346/batterywarning: 0% user + 0% kernel / faults: 223 minor 1 major
  0% 356/cameraserver: 0% user + 0% kernel / faults: 507 minor 99 major
  0% 357/drmserver: 0% user + 0% kernel / faults: 344 minor 39 major
  0% 368/program_binary_service: 0% user + 0% kernel / faults: 516 minor
  0% 487/kworker/1:1: 0% user + 0% kernel
  0% 2932/kworker/1:2: 0% user + 0% kernel
  0% 4492/debuggerd64: 0% user + 0% kernel / faults: 105 minor 29 major
  0% 15014/kworker/2:3: 0% user + 0% kernel
  0% 15557/kworker/4:2: 0% user + 0% kernel
  0% 16097/kworker/6:1: 0% user + 0% kernel
  0% 17003/kworker/5:2: 0% user + 0% kernel
 +0% 29655/kworker/u17:1: 0% user + 0% kernel
 +0% 29720/kworker/u17:2: 0% user + 0% kernel
 +0% 29721/kworker/7:2: 0% user + 0% kernel
 +0% 29784/com.afmobi.boomplayer: 0% user + 0% kernel
 +0% 29874/com.google.android.apps.photos:CameraShortcut: 0% user + 0% kernel
 +0% 30103/com.google.process.gapps: 0% user + 0% kernel
 +0% 30532/com.google.android.music:main: 0% user + 0% kernel
 +0% 30731/com.google.android.tts: 0% user + 0% kernel
 +0% 30758/kworker/u16:0: 0% user + 0% kernel
 +0% 31330/com.rlk.feedback: 0% user + 0% kernel
 +0% 31352/kbase_event: 0% user + 0% kernel
 +0% 31712/kworker/u17:4: 0% user + 0% kernel
 +0% 31889/com.android.settings: 0% user + 0% kernel
 +0% 31913/kbase_event: 0% user + 0% kernel
 +0% 31984/kworker/u16:5: 0% user + 0% kernel
 +0% 31995/com.google.android.gms.ui: 0% user + 0% kernel
 +0% 32022/com.android.defcontainer: 0% user + 0% kernel
 +0% 32044/kbase_event: 0% user + 0% kernel
 +0% 32326/debuggerd64: 0% user + 0% kernel
 +0% 32327/aee_dumpstate: 0% user + 0% kernel
 +0% 32357/com.gy.cy: 0% user + 0% kernel
 +0% 32383/kbase_event: 0% user + 0% kernel
 +0% 32408/system:ui: 0% user + 0% kernel
71% TOTAL: 40% user + 30% kernel + 1% iowait + 0% softirq

另外也有log证实,在发生anr期间,system_server处于非常繁忙的场景,不停的在进行垃圾回收,log见下:

mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5572:04-12 08:34:37.119  1045  2094 I ActivityManager: AMS: *** Start proc 32408:system:ui/1000 for activity android/com.android.internal.app.ResolverActivity
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5610:04-12 08:34:37.212  1045  1107 V WindowManager: Looking for focus: 30 = Window{dd22b3b u0 StatusBar}, flags=-2122055608, canReceive=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5611:04-12 08:34:37.213  1045  1107 V WindowManager: findFocusedWindow: Reached focused app=AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5612:04-12 08:34:37.219  1045 32344 D InputReader: InputReader:: getSwitchState lock 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5613:04-12 08:34:37.219  1045 32344 D InputReader: InputReader::getStateLocked:: return 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5615:04-12 08:34:37.228  1045 32344 I PPSWrapper: PPS onAfterActivityResumed.
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5616:04-12 08:34:37.228  1045  1769 I libPerfService: [perfNotifyAppState] foreground:android, pid:32408
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5617:04-12 08:34:37.228  1045  1769 I libPerfService: [switchSportsMode] enable:0
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5618:04-12 08:34:37.228  1045 32344 I PPS     : [PPSNotifyAppState] pack:android, com:com.android.internal.app.ResolverActivity, state:1,ActiveCount = 1
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5619:04-12 08:34:37.228  1045 32344 I PPS     : [PPSNotifyAppState] nPackNum:105, pack:android, com:com.android.internal.app.ResolverActivity, state:1, pid:32408, last_boost_tid:32408
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5620:04-12 08:34:37.229  1045 32344 I FreezeManager: In AMS appForeground:1000
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5623:04-12 08:34:37.236  1045  1769 I libPerfService: 2: set: 3, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5624:04-12 08:34:37.237  1045  1769 I libPerfService: 2: set freq: 1001000, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5637:04-12 08:34:37.276  1045  6954 W asset   : AssetManager-->addDefaultAssets isok4 is true
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5639:04-12 08:34:37.285  1045  6954 W ResourceType: Invalid package identifier when getting bag for resource number 0xffffffff
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5640:04-12 08:34:37.286  1045  6954 I WindowManager: Destroying surface Surface(name=VolumeDialog) called by com.android.server.wm.WindowStateAnimator.destroySurface:2134 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:947 com.android.server.wm.WindowState.removeLocked:1452 com.android.server.wm.WindowManagerService.removeWindowInnerLocked:2700 com.android.server.wm.WindowManagerService.removeWindowLocked:2648 com.android.server.wm.WindowManagerService.removeWindowLocked:2514 com.android.server.wm.WindowManagerService.removeWindow:2509 com.android.server.wm.Session.remove:196 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5644:04-12 08:34:37.290  1045  6954 V WindowManager: Looking for focus: 30 = Window{dd22b3b u0 StatusBar}, flags=-2122055608, canReceive=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5645:04-12 08:34:37.291  1045  6954 V WindowManager: findFocusedWindow: Reached focused app=AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5648:04-12 08:34:37.302  1045  5778 D PowerManagerNotifier: onUserActivity: event=0, uid=10029
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5649:04-12 08:34:37.302  1045  5778 D DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=5, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, useTwilight=false, waitForNegativeProximity=false, changed=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5651:04-12 08:34:37.303  1045  6950 V SettingsProvider: packageValueForCallResult, name = null, value : Bundle[{_track_generation=android.util.MemoryIntArray@5f, value=null, _generation_index=2, _generation=1084}]
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5696:04-12 08:34:37.495  1045  1743 V SettingsProvider: name : volume_alarm_speaker callingUid : 1000
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5697:04-12 08:34:37.508  1045  1743 V SettingsProvider: name : volume_alarm_speaker callingUid : 1000
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5699:04-12 08:34:37.626  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 44294(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.927ms total 49.727ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5712:04-12 08:34:37.699  1045  5059 V WindowManager: Looking for focus: 30 = Window{dd22b3b u0 StatusBar}, flags=-2122055608, canReceive=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5713:04-12 08:34:37.699  1045  5059 V WindowManager: findFocusedWindow: Reached focused app=AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5716:04-12 08:34:37.723  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 40888(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.475ms total 47.150ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5717:04-12 08:34:37.743  1045  1107 I WindowManager: Destroying surface Surface(name=com.gy.cy/com.gangyun.makeup.gallery3d.makeup.MakeUpActivity) called by com.android.server.wm.WindowStateAnimator.destroySurface:2134 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:947 com.android.server.wm.WindowState.destroyOrSaveSurface:2076 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.WindowStateAnimator.finishExit:586 com.android.server.wm.WindowStateAnimator.stepAnimationLocked:512 com.android.server.wm.WindowAnimator.updateWindowsLocked:311 com.android.server.wm.WindowAnimator.animateLocked:721 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5718:04-12 08:34:37.745  1045  1769 D PerfServiceManager: [PerfService] MESSAGE_TIMEOUT:107 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5719:04-12 08:34:37.746  1045  1769 I libPerfService: 7: set: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5720:04-12 08:34:37.746  1045  1769 I libPerfService: 7: set freq: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5721:04-12 08:34:37.747  1045  1769 D PerfServiceManager: [PerfService] set utilization:0.8 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5742:04-12 08:34:38.083  1045  2159 I libPerfService: 18: set max: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5743:04-12 08:34:38.083  1045  2159 I libPerfService: [perfScnEnable] scn:18, ppm mode:2
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5746:04-12 08:34:38.084  1045 13908 D PerfServiceManager: [PerfService] notifyDisplayType:2 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5747:04-12 08:34:38.084  1045 13908 I libPerfService: perfNotifyDisplayType - type:2
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5754:04-12 08:34:38.845  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 44198(5MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.222ms total 63.615ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5760:04-12 08:34:39.257  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 37494(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.946ms total 43.330ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5786:04-12 08:34:39.894  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 31607(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.595ms total 40.496ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5813:04-12 08:34:41.117  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33495(3MB) AllocSpace objects, 0(0B) LOS objects, 2% free, 78MB/80MB, paused 6.928ms total 65.358ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5817:04-12 08:34:41.203  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33501(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.263ms total 43.723ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5818:04-12 08:34:41.299  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 35386(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.245ms total 43.932ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5819:04-12 08:34:41.372  1045  1110 D DisplayPowerController: requestPowerState: policy=BRIGHT, useProximitySensor=false, screenBrightness=5, screenAutoBrightnessAdjustment=0.0, brightnessSetByUser=true, useAutoBrightness=false, blockScreenOn=false, lowPowerMode=false, boostScreenBrightness=false, dozeScreenBrightness=-1, dozeScreenState=UNKNOWN, useTwilight=false, waitForNegativeProximity=false, changed=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5820:04-12 08:34:41.375  1045  1110 D lights  : write_int open fd=-1
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5825:04-12 08:34:41.398  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33493(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 9.400ms total 48.319ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5826:04-12 08:34:41.490  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 34776(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.311ms total 43.827ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5827:04-12 08:34:41.584  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33287(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 6.093ms total 45.139ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5828:04-12 08:34:41.680  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33418(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 77MB/80MB, paused 5.357ms total 43.729ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5829:04-12 08:34:41.769  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 34366(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.263ms total 43.065ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5830:04-12 08:34:41.867  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33896(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.177ms total 44.342ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5833:04-12 08:34:41.960  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 33248(4MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.327ms total 43.419ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5834:04-12 08:34:42.055  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 32257(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 78MB/80MB, paused 5.200ms total 43.388ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5835:04-12 08:34:42.102  1045  1107 V WindowManager: *** APP TRANSITION TIMEOUT. isTransitionSet()=true mOpeningApps.size()=1 mClosingApps.size()=0
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5840:04-12 08:34:42.114  1045 26055 I libPerfService: [perfScnUpdate] scn:18
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5843:04-12 08:34:42.116  1045  2094 I libPerfService: [perfScnUpdate] scn:18
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5844:04-12 08:34:42.120  1045  1107 V WindowManager: Looking for focus: 29 = Window{dd22b3b u0 StatusBar}, flags=-2122055608, canReceive=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5845:04-12 08:34:42.120  1045  1107 V WindowManager: findFocusedWindow: Reached focused app=AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5846:04-12 08:34:42.120  1045  1107 D WindowManager: notifyActivityDrawnForKeyguard: waiting=false Callers=com.android.server.wm.WindowSurfacePlacer.handleAppTransitionReadyLocked:1227 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementInner:337 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacementLoop:235 com.android.server.wm.WindowSurfacePlacer.performSurfacePlacement:183 com.android.server.wm.WindowManagerService$H.handleMessage:8683 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5847:04-12 08:34:42.121  1045  1107 V WindowManager: Looking for focus: 29 = Window{dd22b3b u0 StatusBar}, flags=-2122055608, canReceive=false
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5848:04-12 08:34:42.121  1045  1107 V WindowManager: findFocusedWindow: Reached focused app=AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5850:04-12 08:34:42.143  1045  2094 I libPerfService: 18: set max: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5852:04-12 08:34:42.146  1045  1769 D PerfServiceManager: [PerfService] MESSAGE_USER_DISABLE: 18 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5853:04-12 08:34:42.147  1045  1769 I libPerfService: 18: set max: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5854:04-12 08:34:42.147  1045  1769 I libPerfService: 18: set: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5855:04-12 08:34:42.147  1045  1769 I libPerfService: 18: set freq: -1, -1, 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5856:04-12 08:34:42.147  1045  1769 I libPerfService: [perfScnDisable] scn:18, ppm mode:Performance
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5859:04-12 08:34:42.149  1045  3718 D PerfServiceManager: [PerfService] notifyDisplayType:1 
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5860:04-12 08:34:42.149  1045  3718 I libPerfService: perfNotifyDisplayType - type:1
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5861:04-12 08:34:42.158  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 32380(4MB) AllocSpace objects, 0(0B) LOS objects, 2% free, 78MB/80MB, paused 6.579ms total 55.619ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5895:04-12 08:34:43.571  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 60783(3MB) AllocSpace objects, 0(0B) LOS objects, 2% free, 78MB/80MB, paused 16.378ms total 112.284ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5898:04-12 08:34:44.062  1045  1054 I art     : Background sticky concurrent mark sweep GC freed 47477(3MB) AllocSpace objects, 0(0B) LOS objects, 2% free, 78MB/80MB, paused 5.582ms total 37.862ms
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5899:04-12 08:34:44.085  1045 13908 D ConnectivityService: getActiveNetworkInfo networkInfo = null
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5908:04-12 08:34:45.074  1045  2159 V ActivityManager: Broadcast sticky: Intent { act=android.intent.action.SIG_STR flg=0x20000010 (has extras) } ordered=false userid=-1 callerApp=ProcessRecord{c0c0a8f 1045:system/1000}
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5909:04-12 08:34:45.082  1045  1107 I Choreographer: Skipped 169 frames!  The application may be doing too much work on its main thread.
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5911:04-12 08:34:45.102  1045  1190 I InputDispatcher: Application is not responding: AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}.  It has been 8006.2ms since event, 8003.4ms since wait started.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5912:04-12 08:34:45.127  1045  1190 I WindowManager: Input event dispatching timed out sending to application AppWindowToken{807aa7f token=Token{28109d9 ActivityRecord{93bbc20 u0 android/com.android.internal.app.ResolverActivity t4237}}}.  Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5915:04-12 08:34:45.183  1045  1789 W InputManager: Input event injection from pid 18369 timed out.
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5916:04-12 08:34:45.186  1045 24784 D WindowManager: interceptKeyBeforeQueueing keyCode = 22
mtklog/aee_exp/db.03.ANR/20170426_100155_458/db.03.ANR.dbg.DEC/SYS_ANDROID_LOG:5918:04-12 08:34:45.188  1045  1099 I FreezeManager: App 1000 is not freezed, But ANR

 

发生anr的时候,可用内存为44,592K free

Free RAM:   253,539K (    9,091K cached pss +   199,856K cached kernel +    44,592K free +         0K ion cached +         0K gpu cached)

所以这个anr可能是由于内存不够导致内存抖动,cpu过高的用在了内存交换上面。

 

3.ANR com.android.contactsv24

Process: com.android.contacts
Flags: 0x38d8be4d
Package: com.android.contacts v24 (1.2)
Foreground: No
Activity: com.mediatek.camera/com.android.camera.CaptureActivity
Parent-Activity: com.android.contacts/.activities.PeopleActivity
Subject: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)

这是跑monkey出现的异常,界面切换导致的。
在两个应用页面之间切换的时候,这个临界点的时候,一个页面正在起来,另外一个页面已经"压栈",即失去焦点,并且在这个页面切换的时候快速点击返回back键,。按照目前android系统的约定是先判断是否有window获得focus,发送按键message必须要有有效的focus窗口来接收,否则input event消息将会在系统里面Block,一当Block,系统就开始计时(即timeout),时间一到即ANR

Log分析:
Package: com.android.contacts v24 (1.2)
Foreground: No
Activity: com.mediatek.camera/com.android.camera.CaptureActivity
Parent-Activity: com.android.contacts/.activities.PeopleActivity
Subject: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)

event log:

10-05 07:48:07.181 1045 3307 I wm_task_moved: [3903,0,0]
10-05 07:48:07.187 1045 3307 I am_pause_activity: [0,144872800,com.android.contacts/.activities.PeopleActivity]
10-05 07:48:07.204 1905 1905 I am_on_paused_called: [0,com.android.contacts.activities.PeopleActivity,handlePauseActivity] //contacts
10-05 07:48:07.251 1045 1057 I am_resume_activity: [0,123383463,864,com.mediatek.camera/com.android.camera.CaptureActivity] //camera
10-05 07:48:07.263 1045 1061 I sysui_count: [window_time_0,5]
10-05 07:48:15.745 1045 1061 I am_anr : [0,1905,com.android.contacts,953728589,Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)]

因此这个问题是monkey快速操作才会出现的,非app本身的问题。正常操作不会有。

3.板温太高 CPU过载

此ANR是当时测试时,手机的板温太高,导致thermal这边压cpu,cpu loading达到了100%,所以才会频繁出现这类问题。

  对于这种情况,建议查看一下当时的复现步骤,是否跟monkey或者其他压力测试有关?如果不是,用户操作过程中很容易就板温升高的话,建议修改硬件结构或者增加散热辅材,例如添加风冷的方式来缓解板温升高的情况。

从log来看,如下时间点发生了三次ANR,ANR的类型和发生进程都不相同:

11-09 16:20:20.434036 1064 1080 E ANRManager: ANR in com.android.systemui, time=156405952
11-09 16:20:20.434036 1064 1080 E ANRManager: Reason: 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: 9. Wait queue head age: 10596.7ms.)
11-09 16:20:44.538118 1064 1080 E ANRManager: ANR in com.evernote, time=156438060
11-09 16:20:44.538118 1064 1080 E ANRManager: Reason: Broadcast of Intent { act=com.google.firebase.INSTANCE_ID_EVENT flg=0x14 cmp=com.evernote/com.google.firebase.iid.FirebaseInstanceIdInternalReceiver (has extras) }
11-09 16:21:15.217680 1064 1080 E ANRManager: ANR in android.process.media, time=156468804
11-09 16:21:15.217680 1064 1080 E ANRManager: Reason: Broadcast of Intent { act=android.hardware.usb.action.USB_STATE flg=0x30000010 cmp=com.android.providers.media/.MtpReceiver (has extras) }

 

从kernel log来看,如下时间点,有发生了限频的动作:

11-09 16:18:42.055 <4>[156327.417218] (0)[23342:kworker/0:2][CPU_Thermal]set_adaptive_cpu_power_limit 1232 T=67300, 1365 T=63500, 1282 T=64100, 1219 T=66000, 0 T=58100

11-09 16:18:42.055 <4>[156327.417245] (0)[23342:kworker/0:2][Power/cpufreq] mt_cpufreq_thermal_protect(): limited_power = 1232

11-09 16:18:42.055 <7>[156327.417267] (0)[23342:kworker/0:2][name:mt_cpufreq&][Power/cpufreq] @mt_cpufreq_thermal_protect: found = 1, limited_power_idx = 1, limited_max_freq = 1027000, limited_max_ncpu = 4

11-09 16:18:42.055 <7>[156327.417500] (0)[23342:kworker/0:2][name:mt_cpufreq&][Power/cpufreq] @_mt_cpufreq_set_locked(): Vproc = 1125mv, freq = 1027000 KHz

....

//记录了和当前4次cpu power调节的温度和limit信息,总共会记录五次历史信息,

//当前5th调节,CPU温度为65度,设置的power limit为891,

//1th ,CPU温度为64.6度,设置Power limit为596

power limit 为0的话,表示不限制power

11-09 16:21:32.055 <4>[156497.417082] (0)[23342:kworker/0:2][CPU_Thermal]set_adaptive_cpu_power_limit 891 T=65000, 858 T=64600, 765 T=64400, 659 T=64100, 596 T=64600

查看但是手机板温,看起来有从50度开始持续升高,这个温度其实已经非常高了:

11-09 16:18:49.095 <7>[156334.457262] (1)[23759:kworker/1:1][name:mtk_ts_bts&][Power/BTS_Thermal] T_AP=50000

....

11-09 16:21:33.105 <7>[156498.467064] (1)[23759:kworker/1:1][name:mtk_ts_bts&][Power/BTS_Thermal] T_AP=53000

从cpu loading来看,这段时间cpu都是100%的情况:(4),(3)分别代表使用了4,3个核,(400),(300)满负荷工作

11-09 16:19:04.059 <4>[156349.420748] (0)[97:hps_main][HPS] (0008)(4)action end(400)

....

11-09 16:21:26.063 <4>[156491.424828] (0)[97:hps_main][HPS] (0020)(3)action end(300)

综上分析,看起来板子温度高才是此问题的症结所在,请保证板温的温度在合理范围之内.

4.界面切换焦点异常

 Monkey条件下,有些条件下CPU,IO,RAM都是在正常范围内

由于是 Input dispatching timed out类型的ANR 在android log 中可见:

Line 3638: 01-02 03:09:55.073 12546 12546 I Monkey : Sleeping for 500 milliseconds
Line 3640: 01-02 03:09:55.094 12546 15460 I Monkey : // Allowing start of Intent

{act=android.settings.AIRPLANE_MODE_SETTINGS cmp=com.android.settings/.Settings$NetworkDashboardActivity }

 

说明是在从SystemUI转跳到飞行模式设置界面的时候出现的问题,搜索WindowManager关键字:

Line 2690: 01-02 03:09:23.827 1030 5166 V WindowManager: Set focused app to: AppWindowToken{7a50ca9 token=Token{b67fed7 ActivityRecord

{ecd8e56 u0 com.google.android.googlequicksearchbox/com.google.android.apps.gsa.searchnow.SearchNowActivity t2340}

}} old focus=AppWindowToken{8f4e18 token=Token{65c9f00 ActivityRecord

{bf76183 u0 com.google.android.googlequicksearchbox/.SearchActivity t2352}

}} moveFocusNow=true

Line 2694: 01-02 03:09:25.835 1030 5166 D PowerManagerService: releaseWakeLockInternal: lock=117134316 [WindowManager], flags=0x0, totaltime=3770ms

Line 2695: 01-02 03:09:25.835 1030 5166 D PowerManagerNotifier: onWakeLockReleased: flags=536870922, tag="WindowManager", packageName=android, ownerUid=1000, ownerPid=1030, workSource=WorkSource

{10039}

Line 2699: 01-02 03:09:25.936 1030 9443 W WindowManager: Failed looking up window callers=com.android.server.wm.WindowManagerService.windowForClientLocked:5869 com.android.server.wm.WindowManagerService.removeWindow:1742 com.android.server.wm.Session.remove:223

Line 2713: 01-02 03:09:27.636 1030 1104 V WindowManager: *** APP TRANSITION TIMEOUT. isTransitionSet()=true mOpeningApps.size()=1 mClosingApps.size()=3

问题原因:发生ANR的时候Monkey触发ACTION_MOVE,该事件响应在了已经关闭的界面上导致需要响应的界面没有接收到事件导致ANR
解决方案:用户使用的时候很难出现这种现象,不做修改

另外一个问题

从打印的堆栈上看android/.accounts.ChooseTypeAndAccountActivity 这个界面处于Foreground: No非前台,而焦点界面还没起来。
原因在于焦点从应用A中,将要启动应用B,当A开始OnPause流程后,焦点应用是A,焦点窗口是null,接着zygote创建B,焦点应用是B,焦点窗口是null,应用B的OnResume流程完成后,焦点应用是B,焦点窗口是B(的某一个窗口)。此时如果焦点窗口处于null的阶段超过5秒,就报出ANR。从CPU和RAM负载都不高的情况下推测应该是由于切换速度太快导致的

Backtrace: 
Process: android:ui
PID: 8415
Flags: 0x30c8be09
Package: android v28 (9)
Foreground: No
Activity: android/.accounts.ChooseTypeAndAccountActivity
Subject: Input dispatching timed out (Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.)
Build: XXX/HXXXCD/XXX-XXX:9/PPR1.180610.011/CD-181129V31:user/release-keys

 

你可能感兴趣的:(跑Monkey过程中出现的ANR问题分析)