04-22 10:49:36.222646 1270 1376 I InputDispatcher: Application is not responding: AppWindowToken{e4f7c16 token=Token{8a1cd31 ActivityRecord{21295d8 u0 com.android.PACKAGE/.PACKAGE_Activity t10}}}. It has been 5008.2ms since event, 5005.5ms 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. 04-22 10:49:36.342164 1270 1407 E TAG : 82 Tanet ...... 04-22 10:49:41.347174 1270 1376 I InputDispatcher: Dropped event because it is stale.
system log:
1 2 3 4 5
04-22 10:49:31.216699 1270 1376 D PowerManagerService: getScreenOffTimeoutLocked: isTestFlag = false 04-22 10:49:31.216986 1270 1376 W WindowManager: Failed looking up window callers=com.android.server.wm.InputManagerCallback.interceptKeyBeforeDispatching:182 com.android.server.input.InputManagerService.interceptKeyBeforeDispatching:1839 <bottom of call stack> 04-22 10:49:36.224611 1270 1376 I WindowManager: Input event dispatching timed out . Reason: Waiting because no window has focus but there is a focused application that may eventually add a window when it finishes starting up. 04-22 10:49:36.341180 1270 1407 W InputManager: Input event injection from pid 6143 timed out. 04-22 10:49:36.342467 1270 1376 W WindowManager: Failed looking up window callers=com.android.server.wm.InputManagerCallback.interceptKeyBeforeDispatching:182
int32_tInputDispatcher::findFocusedWindowTargetsLocked(nsecs_t currentTime, const EventEntry* entry, std::vector<InputTarget>& inputTargets, nsecs_t* nextWakeupTime){ ...... // If there is no currently focused window and no focused application // then drop the event. if (focusedWindowHandle == nullptr) { if (focusedApplicationHandle != nullptr) { //monkey test的时候经常遇到类似log的ANR。典型的无窗口,有应用的ANR问题,这里我们就需要了解Android应用的启动流程了,一般此类问题都是Android应用首次启动时会发生此类问题,此时我们应用本身需要检查一下我们的Android应用重写的Application onCreate方法,Android应用的启动界面是否在onCreate onStart方法中是否存在耗时操作。当然不排除系统原因造成的启动慢,直接导致ANR问题发生的情况 injectionResult = handleTargetsNotReadyLocked(currentTime, entry, focusedApplicationHandle, nullptr, nextWakeupTime, "Waiting because no window has focus but there is a " "focused application that may eventually add a window " "when it finishes starting up."); goto Unresponsive; } ....
// Force poll loop to wake up immediately on next iteration once we get the // ANR response back from the policy. *nextWakeupTime = LONG_LONG_MIN; return INPUT_EVENT_INJECTION_PENDING; }