From 786dccf9f5ee9ae04f5431b7ddbad173a81da8c7 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 17 Oct 2013 19:40:40 -0700 Subject: [PATCH] Fix issues catching up to touch events after a short pause. When the app spends more than half a second responding to a touch event, the input dispatch eventually decides to stop sending it events until it catches up. (This is when the ANR clock starts.) However, due to a bug in the timing logic, if the app eventually does respond again we would resume delivery but only send one event at a time until the queue was completely drained again. This meant it could take a long time to catch up and process all events. The problem is that we were comparing the current time with the waiting event time. So when events became older than half a second, we would simply stop streaming and end up serialized. This change fixes the timing logic such that the streaming timeout is based on the delivery time of the waiting event rather than the event time itself. Now we only stop streaming when it has been over half a second since the waiting event was delivered so we resume streaming immediately as soon as some waiting events are handled. Bug: 11278743 Change-Id: Ic8c68ee372a07f7caa4168eefcabf9b8a8ad5d87 --- services/input/InputDispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp index 274009fc50784..10a639e7aaad9 100644 --- a/services/input/InputDispatcher.cpp +++ b/services/input/InputDispatcher.cpp @@ -1699,7 +1699,7 @@ bool InputDispatcher::isWindowReadyForMoreInputLocked(nsecs_t currentTime, // up with lots of events because the application is not responding. // This condition ensures that ANRs are detected reliably. if (!connection->waitQueue.isEmpty() - && currentTime >= connection->waitQueue.head->eventEntry->eventTime + && currentTime >= connection->waitQueue.head->deliveryTime + STREAM_AHEAD_EVENT_TIMEOUT) { return false; }