Skip to content

Commit f613da0

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Simplify the consume before traversal heuristic." into jb-dev
2 parents 263d044 + 330314c commit f613da0

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ void scheduleTraversals() {
947947
mTraversalBarrier = mHandler.getLooper().postSyncBarrier();
948948
mChoreographer.postCallback(
949949
Choreographer.CALLBACK_TRAVERSAL, mTraversalRunnable, null);
950+
scheduleConsumeBatchedInput();
950951
}
951952
}
952953

@@ -964,9 +965,6 @@ void doTraversal() {
964965
mTraversalScheduled = false;
965966
mHandler.getLooper().removeSyncBarrier(mTraversalBarrier);
966967

967-
doConsumeBatchedInput(false);
968-
doProcessInputEvents();
969-
970968
if (mProfile) {
971969
Debug.startMethodTracing("ViewAncestor");
972970
}
@@ -4206,20 +4204,13 @@ void unscheduleConsumeBatchedInput() {
42064204
}
42074205
}
42084206

4209-
void doConsumeBatchedInput(boolean callback) {
4207+
void doConsumeBatchedInput() {
42104208
if (mConsumeBatchedInputScheduled) {
42114209
mConsumeBatchedInputScheduled = false;
4212-
if (!callback) {
4213-
mChoreographer.removeCallbacks(Choreographer.CALLBACK_INPUT,
4214-
mConsumedBatchedInputRunnable, null);
4210+
if (mInputEventReceiver != null) {
4211+
mInputEventReceiver.consumeBatchedInputEvents();
42154212
}
4216-
}
4217-
4218-
// Always consume batched input events even if not scheduled, because there
4219-
// might be new input there waiting for us that we have no noticed yet because
4220-
// the Looper has not had a chance to run again.
4221-
if (mInputEventReceiver != null) {
4222-
mInputEventReceiver.consumeBatchedInputEvents();
4213+
doProcessInputEvents();
42234214
}
42244215
}
42254216

@@ -4257,8 +4248,7 @@ public void dispose() {
42574248
final class ConsumeBatchedInputRunnable implements Runnable {
42584249
@Override
42594250
public void run() {
4260-
doConsumeBatchedInput(true);
4261-
doProcessInputEvents();
4251+
doConsumeBatchedInput();
42624252
}
42634253
}
42644254
final ConsumeBatchedInputRunnable mConsumedBatchedInputRunnable =

0 commit comments

Comments
 (0)