在這裏的時候,應用主線程已經開始啓動咱們的目標窗口了,那確定是進到咱們應用當中了,那窗口爲何沒有呢?再聯繫一下trace.txt當中的調用棧信息,確定是咱們在Activity的onResume方法當中邏輯耗時過久,致使WindowManagerService沒有成功添加Activity的窗口,因此事件找不到目標,沒法分發,因此產生ANR了。好了,這是咱們的一個判斷,那咱們還須要找證據。事件分發,咱們找一下InputDispatcher關鍵字,能夠找到以下的信息:android
07-06 19:13:27.781 18431 19430 D SettingsInterface: from settings cache , name = sys_storage_threshold_max_bytes , value = null
07-06 19:13:27.813 18431 18597 I InputDispatcher: Application is not responding: AppWindowToken{34356a0 token=Token{8c7dc0f ActivityRecord{32a3d6e u0 com.google.android.apps.maps/com.google.android.maps.MapsActivity, isShadow:false t2134}}}. It has been 8004.7ms since event, 8002.9ms 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.
07-06 19:13:27.827 18431 18597 I WindowManager: Input event dispatching timed out sending to application AppWindowToken{34356a0 token=Token{8c7dc0f ActivityRecord{32a3d6e u0 com.google.android.apps.maps/com.google.android.maps.MapsActivity, isShadow:false t2134}}}. Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up.app
能夠明顯看到,在開始建立窗口,到大約6秒後,系統已經開始分發事件了,此時已經發現沒有目標窗口,系統此時已經提醒咱們一次了,固然後邊呢,目標窗口仍是沒有建立好,最終就致使ANR了,因此方法就很明確了,就是在咱們應用的onNewIntent方法啓動Activity時(Instrumentation.callActivityOnNewIntent),執行了耗時邏輯,最終致使了ANR的發生,由於這裏的應用是google地圖,沒有源碼,因此沒法往下分析,也只是給你們點個思路,你們之後若是有這樣的bug,能夠順着這個思路展開。
google