summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/InputEventReceiver.java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2013-10-25 14:50:36 -0700
committerMichael Wright <michaelwr@google.com>2013-10-26 12:18:00 -0700
commit62ce65d6edbc2c34c63b0e2f2fef9cb08e28c783 (patch)
tree7b6584c178d38fe7392e0057e5f3b8b7fb271311 /core/java/android/view/InputEventReceiver.java
parent7c2a2ef2ee71d65ac43acf3dad95df1629dfc674 (diff)
downloadframeworks_base-62ce65d6edbc2c34c63b0e2f2fef9cb08e28c783.zip
frameworks_base-62ce65d6edbc2c34c63b0e2f2fef9cb08e28c783.tar.gz
frameworks_base-62ce65d6edbc2c34c63b0e2f2fef9cb08e28c783.tar.bz2
Speculatively schedule input consumption
With the new tuned vsync offset, vsyncs are likely to occur shortly after the input is received, meaning we will empty the input queue, and thus won't schedule input consumption until more input is received. If an application then speculatively posts draw commands to the main looper faster than 60 hz, it will eventually end up blocking in eglSwapBuffers. Since we're blocking in eglSwapBuffers, we won't even schedule consumption until after the current frame (8-16ms), and it's entirely likely we won't actually get around to consuming input until after the next frame (another 16 ms of latency). This means we can often go 16-32ms without processing any input events, causing very noticeable amounts of jank. Rather than waiting for the next input event to schedule input consumption, speculatively schedule it every frame as long as we've consumed some motion batch during this frame. Bug: 11398045 Change-Id: I25e46308e00e9f9de00a1d8906f6b0e0f2e845b4
Diffstat (limited to 'core/java/android/view/InputEventReceiver.java')
-rw-r--r--core/java/android/view/InputEventReceiver.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java
index f5ee7ed..25972e7 100644
--- a/core/java/android/view/InputEventReceiver.java
+++ b/core/java/android/view/InputEventReceiver.java
@@ -48,7 +48,7 @@ public abstract class InputEventReceiver {
InputChannel inputChannel, MessageQueue messageQueue);
private static native void nativeDispose(int receiverPtr);
private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled);
- private static native void nativeConsumeBatchedInputEvents(int receiverPtr,
+ private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr,
long frameTimeNanos);
/**
@@ -165,14 +165,17 @@ public abstract class InputEventReceiver {
*
* @param frameTimeNanos The time in the {@link System#nanoTime()} time base
* when the current display frame started rendering, or -1 if unknown.
+ *
+ * @return Whether a batch was consumed
*/
- public final void consumeBatchedInputEvents(long frameTimeNanos) {
+ public final boolean consumeBatchedInputEvents(long frameTimeNanos) {
if (mReceiverPtr == 0) {
Log.w(TAG, "Attempted to consume batched input events but the input event "
+ "receiver has already been disposed.");
} else {
- nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos);
+ return nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos);
}
+ return false;
}
// Called from native code.