diff options
| author | 2024-03-22 22:16:10 +0000 | |
|---|---|---|
| committer | 2024-03-27 18:41:27 +0000 | |
| commit | be2bd817cc82712c23734259905f8f9968539d39 (patch) | |
| tree | 99c455a8342b198977ff8dbd3bf032e8c7e70e07 | |
| parent | 04b951c1ddf5bcb4d1a3845a2862e6d56ce339e6 (diff) | |
Add more context to Choreographer input callbacks
Bug: 330906135
Test: Take a perfetto trace with input and verify it shows tags
Change-Id: I28d87745b967d8f548a27c67a8b0d7469d337d42
Signed-off-by: Winson Chung <winsonc@google.com>
| -rw-r--r-- | core/java/android/view/BatchedInputEventReceiver.java | 9 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 19 |
2 files changed, 20 insertions, 8 deletions
diff --git a/core/java/android/view/BatchedInputEventReceiver.java b/core/java/android/view/BatchedInputEventReceiver.java index ca2e56d383e5..2e39f73f6233 100644 --- a/core/java/android/view/BatchedInputEventReceiver.java +++ b/core/java/android/view/BatchedInputEventReceiver.java @@ -29,6 +29,7 @@ public class BatchedInputEventReceiver extends InputEventReceiver { private Choreographer mChoreographer; private boolean mBatchingEnabled; private boolean mBatchedInputScheduled; + private final String mTag; private final Handler mHandler; private final Runnable mConsumeBatchedInputEvents = new Runnable() { @Override @@ -43,6 +44,7 @@ public class BatchedInputEventReceiver extends InputEventReceiver { super(inputChannel, looper); mChoreographer = choreographer; mBatchingEnabled = true; + mTag = inputChannel.getName(); traceBoolVariable("mBatchingEnabled", mBatchingEnabled); traceBoolVariable("mBatchedInputScheduled", mBatchedInputScheduled); mHandler = new Handler(looper); @@ -123,7 +125,12 @@ public class BatchedInputEventReceiver extends InputEventReceiver { private final class BatchedInputRunnable implements Runnable { @Override public void run() { - doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); + try { + Trace.traceBegin(Trace.TRACE_TAG_INPUT, mTag); + doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); + } finally { + Trace.traceEnd(Trace.TRACE_TAG_INPUT); + } } } private final BatchedInputRunnable mBatchedInputRunnable = new BatchedInputRunnable(); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index eb9be1817165..0f6995afcc5f 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -10166,13 +10166,18 @@ public final class ViewRootImpl implements ViewParent, final class ConsumeBatchedInputRunnable implements Runnable { @Override public void run() { - mConsumeBatchedInputScheduled = false; - if (doConsumeBatchedInput(mChoreographer.getFrameTimeNanos())) { - // If we consumed a batch here, we want to go ahead and schedule the - // consumption of batched input events on the next frame. Otherwise, we would - // wait until we have more input events pending and might get starved by other - // things occurring in the process. - scheduleConsumeBatchedInput(); + Trace.traceBegin(TRACE_TAG_VIEW, mTag); + try { + mConsumeBatchedInputScheduled = false; + if (doConsumeBatchedInput(mChoreographer.getFrameTimeNanos())) { + // If we consumed a batch here, we want to go ahead and schedule the + // consumption of batched input events on the next frame. Otherwise, we would + // wait until we have more input events pending and might get starved by other + // things occurring in the process. + scheduleConsumeBatchedInput(); + } + } finally { + Trace.traceEnd(TRACE_TAG_VIEW); } } } |