两个apk,一个是home进程,一个是管理设定的进程。
home进程会通过aidl调用设定进程的接口。而发生anr时,是home发生了anr,原因是home Reason: keyDispatchingTimedOut key而在traces.txt中,home进程的anrlog却是没有的,停留在MessageQueue.next,
而有设定进程的SUSPENDED信息而在errorlog中,设定进程发生了OOM。问下,设定进程OOM了,如果此时home调用设定进程的接口,会导致Home发生anr吗

解决方案 »

  1.   

    会的,如果之前的进程oom了,之后的进程很有可能会不响应
      

  2.   

    官方的说明没找到,不过你可以用android profiler多做几次模拟,写在报告里面
      

  3.   

    嗯,那您觉得是什么原因导致ANR呢
    1.binder调用返回timeout?
    2.看了下log,anr ago CPU使用率不高,而anr later,CPU使用率在90%左右(主要都是设定进程占用),
    可以说明anr时,因为设定那个进程接近OOM了(还没有发生OOM,log中看anr之后的,10s后发生了OOM),CPU使用率过高,导致anr吗?
    3.其他原因?
      

  4.   

    出现anr的情况较多,比较常见的是
    The app is doing slow operations involving I/O on the main thread.
    The app is doing a long calculation on the main thread.
    The main thread is doing a synchronous binder call to another process, and that other process is taking a long time to return.
    The main thread is blocked waiting for a synchronized block for a long operation that is happening on another thread.
    The main thread is in a deadlock with another thread, either in your process or via a binder call. The main thread is not just waiting for a long operation to finish, but is in a deadlock situation. For more information, see Deadlock on Wikipedia.
    可以参考google文档 https://developer.android.com/topic/performance/vitals/anr.html
      

  5.   

    home Reason: keyDispatchingTimedOut key 明显输入事件分发超时类anr,你的管理设定的进程OOM,导致该进程挂掉,你的home进程需要发送信息和其通信,但是该进程已经挂掉,5秒超时没有应答,windowmanager 打印anr信息,报出anr发生事件。
      

  6.   


    其实我觉得和你的想法一致的,可以上汇报的时候,非要确凿的证据。但是home的traces.txt文件中,却没有具体的堆栈信息呢,仅仅是如下:
    main" prio=5 tid=1 NATIVE
      | group="main" sCount=1 dsCount=0 obj=0x410749a0 self=0x62201010
      | sysTid=3012 nice=0 sched=0/0 cgrp=apps handle=1075652060
      | state=S schedstat=( 0 0 0 ) utm=120607 stm=7038 core=1
      #00  pc 00017f30  /system/lib/libc.so (epoll_wait+12)
      #01  pc 00016041  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+96)
      #02  pc 000162b1  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+104)
      #03  pc 0006008b  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvi+22)
      #04  pc 0001e290  /system/lib/libdvm.so (dvmPlatformInvoke+112)
      #05  pc 0004d93d  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread+400)
      #06  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)
      at android.os.MessageQueue.nativePollOnce(Native Method)
      at android.os.MessageQueue.next(MessageQueue.java:125)
      at android.os.Looper.loop(Looper.java:124)
     。还有一点,在log中,home发生anr时,设定进程是在anr发生后10s左右才OOM的。
      

  7.   


    其实我觉得和你的想法一致的,可以上汇报的时候,非要确凿的证据。但是home的traces.txt文件中,却没有具体的堆栈信息呢,仅仅是如下:
    main" prio=5 tid=1 NATIVE
      | group="main" sCount=1 dsCount=0 obj=0x410749a0 self=0x62201010
      | sysTid=3012 nice=0 sched=0/0 cgrp=apps handle=1075652060
      | state=S schedstat=( 0 0 0 ) utm=120607 stm=7038 core=1
      #00  pc 00017f30  /system/lib/libc.so (epoll_wait+12)
      #01  pc 00016041  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+96)
      #02  pc 000162b1  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+104)
      #03  pc 0006008b  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvi+22)
      #04  pc 0001e290  /system/lib/libdvm.so (dvmPlatformInvoke+112)
      #05  pc 0004d93d  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread+400)
      #06  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)
      at android.os.MessageQueue.nativePollOnce(Native Method)
      at android.os.MessageQueue.next(MessageQueue.java:125)
      at android.os.Looper.loop(Looper.java:124)
     。还有一点,在log中,home发生anr时,设定进程是在anr发生后10s左右才OOM的。

    也不一定非要oom才发生anr,快oom时,内存资源已经非常紧张,cpu负载已经接近饱和,这是再来任务让cpu处理,由于资源非常紧张,获取不到cpu时间片,发生anr很正常。
      

  8.   


    其实我觉得和你的想法一致的,可以上汇报的时候,非要确凿的证据。但是home的traces.txt文件中,却没有具体的堆栈信息呢,仅仅是如下:
    main" prio=5 tid=1 NATIVE
      | group="main" sCount=1 dsCount=0 obj=0x410749a0 self=0x62201010
      | sysTid=3012 nice=0 sched=0/0 cgrp=apps handle=1075652060
      | state=S schedstat=( 0 0 0 ) utm=120607 stm=7038 core=1
      #00  pc 00017f30  /system/lib/libc.so (epoll_wait+12)
      #01  pc 00016041  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+96)
      #02  pc 000162b1  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+104)
      #03  pc 0006008b  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvi+22)
      #04  pc 0001e290  /system/lib/libdvm.so (dvmPlatformInvoke+112)
      #05  pc 0004d93d  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread+400)
      #06  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)
      at android.os.MessageQueue.nativePollOnce(Native Method)
      at android.os.MessageQueue.next(MessageQueue.java:125)
      at android.os.Looper.loop(Looper.java:124)
     。还有一点,在log中,home发生anr时,设定进程是在anr发生后10s左右才OOM的。

    也不一定非要oom才发生anr,快oom时,内存资源已经非常紧张,cpu负载已经接近饱和,这是再来任务让cpu处理,由于资源非常紧张,获取不到cpu时间片,发生anr很正常。说的有道理。
    但是在log中,anr的ago:cpu和IOWait都不是很高,也就是说anr之前,cpu负载和IO都不高的。而anr later:cpu负载在90%左右,主要是因为设定进程占用高。这样可以说明,发生anr中时,cpu负载高导致的吗?
      

  9.   


    其实我觉得和你的想法一致的,可以上汇报的时候,非要确凿的证据。但是home的traces.txt文件中,却没有具体的堆栈信息呢,仅仅是如下:
    main" prio=5 tid=1 NATIVE
      | group="main" sCount=1 dsCount=0 obj=0x410749a0 self=0x62201010
      | sysTid=3012 nice=0 sched=0/0 cgrp=apps handle=1075652060
      | state=S schedstat=( 0 0 0 ) utm=120607 stm=7038 core=1
      #00  pc 00017f30  /system/lib/libc.so (epoll_wait+12)
      #01  pc 00016041  /system/lib/libutils.so (_ZN7android6Looper9pollInnerEi+96)
      #02  pc 000162b1  /system/lib/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+104)
      #03  pc 0006008b  /system/lib/libandroid_runtime.so (_ZN7android18NativeMessageQueue8pollOnceEP7_JNIEnvi+22)
      #04  pc 0001e290  /system/lib/libdvm.so (dvmPlatformInvoke+112)
      #05  pc 0004d93d  /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread+400)
      #06  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)
      at android.os.MessageQueue.nativePollOnce(Native Method)
      at android.os.MessageQueue.next(MessageQueue.java:125)
      at android.os.Looper.loop(Looper.java:124)
     。还有一点,在log中,home发生anr时,设定进程是在anr发生后10s左右才OOM的。

    也不一定非要oom才发生anr,快oom时,内存资源已经非常紧张,cpu负载已经接近饱和,这是再来任务让cpu处理,由于资源非常紧张,获取不到cpu时间片,发生anr很正常。说的有道理。
    但是在log中,anr的ago:cpu和IOWait都不是很高,也就是说anr之前,cpu负载和IO都不高的。而anr later:cpu负载在90%左右,主要是因为设定进程占用高。这样可以说明,发生anr中时,cpu负载高导致的吗?
    anr发生后,会打印cpu消息,该消息为anr发生时的cpu状态信息