Skip to content

Commit e2d7f18

Browse files
author
Romain Guy
committed
Remove DEBUG_LATENCY flag
This flag was replaced with the more versatile and powerful systrace. Change-Id: I2267698f86fe9ba9e1102856795ca641001fecd5
1 parent 13b9073 commit e2d7f18

File tree

2 files changed

+0
-148
lines changed

2 files changed

+0
-148
lines changed

core/java/android/view/ViewDebug.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,6 @@ public class ViewDebug {
6868
*/
6969
public static final boolean DEBUG_DRAG = false;
7070

71-
/**
72-
* Enables logging of factors that affect the latency and responsiveness of an application.
73-
*
74-
* Logs the relative difference between the time an event was created and the time it
75-
* was delivered.
76-
*
77-
* Logs the time spent waiting for Surface.lockCanvas(), Surface.unlockCanvasAndPost()
78-
* or eglSwapBuffers(). This is time that the event loop spends blocked and unresponsive.
79-
* Ideally, drawing and animations should be perfectly synchronized with VSYNC so that
80-
* dequeuing and queueing buffers is instantaneous.
81-
*
82-
* Logs the time spent in ViewRoot.performTraversals() and ViewRoot.performDraw().
83-
* @hide
84-
*/
85-
public static final boolean DEBUG_LATENCY = false;
86-
87-
/** @hide */
88-
public static final String DEBUG_LATENCY_TAG = "ViewLatency";
89-
9071
/**
9172
* This annotation can be used to mark fields and methods to be dumped by
9273
* the view server. Only non-void methods with no arguments can be annotated

core/java/android/view/ViewRootImpl.java

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ public final class ViewRootImpl implements ViewParent,
217217

218218
boolean mTraversalScheduled;
219219
int mTraversalBarrier;
220-
long mLastTraversalFinishedTimeNanos;
221-
long mLastDrawFinishedTimeNanos;
222220
boolean mWillDrawSoon;
223221
boolean mFitSystemWindowsRequested;
224222
boolean mLayoutRequested;
@@ -986,33 +984,13 @@ void doTraversal() {
986984
Debug.startMethodTracing("ViewAncestor");
987985
}
988986

989-
final long traversalStartTime;
990-
if (ViewDebug.DEBUG_LATENCY) {
991-
traversalStartTime = System.nanoTime();
992-
if (mLastTraversalFinishedTimeNanos != 0) {
993-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "Starting performTraversals(); it has been "
994-
+ ((traversalStartTime - mLastTraversalFinishedTimeNanos) * 0.000001f)
995-
+ "ms since the last traversals finished.");
996-
} else {
997-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "Starting performTraversals().");
998-
}
999-
}
1000-
1001987
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "performTraversals");
1002988
try {
1003989
performTraversals();
1004990
} finally {
1005991
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
1006992
}
1007993

1008-
if (ViewDebug.DEBUG_LATENCY) {
1009-
long now = System.nanoTime();
1010-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "performTraversals() took "
1011-
+ ((now - traversalStartTime) * 0.000001f)
1012-
+ "ms.");
1013-
mLastTraversalFinishedTimeNanos = now;
1014-
}
1015-
1016994
if (mProfile) {
1017995
Debug.stopMethodTracing();
1018996
mProfile = false;
@@ -2013,18 +1991,6 @@ private void performDraw() {
20131991
return;
20141992
}
20151993

2016-
final long drawStartTime;
2017-
if (ViewDebug.DEBUG_LATENCY) {
2018-
drawStartTime = System.nanoTime();
2019-
if (mLastDrawFinishedTimeNanos != 0) {
2020-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "Starting draw(); it has been "
2021-
+ ((drawStartTime - mLastDrawFinishedTimeNanos) * 0.000001f)
2022-
+ "ms since the last draw finished.");
2023-
} else {
2024-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "Starting draw().");
2025-
}
2026-
}
2027-
20281994
final boolean fullRedrawNeeded = mFullRedrawNeeded;
20291995
mFullRedrawNeeded = false;
20301996

@@ -2037,14 +2003,6 @@ private void performDraw() {
20372003
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
20382004
}
20392005

2040-
if (ViewDebug.DEBUG_LATENCY) {
2041-
long now = System.nanoTime();
2042-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "performDraw() took "
2043-
+ ((now - drawStartTime) * 0.000001f)
2044-
+ "ms.");
2045-
mLastDrawFinishedTimeNanos = now;
2046-
}
2047-
20482006
if (mReportNextDraw) {
20492007
mReportNextDraw = false;
20502008

@@ -2208,19 +2166,8 @@ private boolean drawSoftware(Surface surface, AttachInfo attachInfo, int yoff,
22082166
int right = dirty.right;
22092167
int bottom = dirty.bottom;
22102168

2211-
final long lockCanvasStartTime;
2212-
if (ViewDebug.DEBUG_LATENCY) {
2213-
lockCanvasStartTime = System.nanoTime();
2214-
}
2215-
22162169
canvas = mSurface.lockCanvas(dirty);
22172170

2218-
if (ViewDebug.DEBUG_LATENCY) {
2219-
long now = System.nanoTime();
2220-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "- lockCanvas() took "
2221-
+ ((now - lockCanvasStartTime) * 0.000001f) + "ms");
2222-
}
2223-
22242171
if (left != dirty.left || top != dirty.top || right != dirty.right ||
22252172
bottom != dirty.bottom) {
22262173
attachInfo.mIgnoreDirtyState = true;
@@ -2287,32 +2234,16 @@ private boolean drawSoftware(Surface surface, AttachInfo attachInfo, int yoff,
22872234
? DisplayMetrics.DENSITY_DEVICE : 0);
22882235
attachInfo.mSetIgnoreDirtyState = false;
22892236

2290-
final long drawStartTime;
2291-
if (ViewDebug.DEBUG_LATENCY) {
2292-
drawStartTime = System.nanoTime();
2293-
}
2294-
22952237
mView.draw(canvas);
22962238

22972239
drawAccessibilityFocusedDrawableIfNeeded(canvas);
2298-
2299-
if (ViewDebug.DEBUG_LATENCY) {
2300-
long now = System.nanoTime();
2301-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "- draw() took "
2302-
+ ((now - drawStartTime) * 0.000001f) + "ms");
2303-
}
23042240
} finally {
23052241
if (!attachInfo.mSetIgnoreDirtyState) {
23062242
// Only clear the flag if it was not set during the mView.draw() call
23072243
attachInfo.mIgnoreDirtyState = false;
23082244
}
23092245
}
23102246
} finally {
2311-
final long unlockCanvasAndPostStartTime;
2312-
if (ViewDebug.DEBUG_LATENCY) {
2313-
unlockCanvasAndPostStartTime = System.nanoTime();
2314-
}
2315-
23162247
try {
23172248
surface.unlockCanvasAndPost(canvas);
23182249
} catch (IllegalArgumentException e) {
@@ -2322,12 +2253,6 @@ private boolean drawSoftware(Surface surface, AttachInfo attachInfo, int yoff,
23222253
return false;
23232254
}
23242255

2325-
if (ViewDebug.DEBUG_LATENCY) {
2326-
long now = System.nanoTime();
2327-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, "- unlockCanvasAndPost() took "
2328-
+ ((now - unlockCanvasAndPostStartTime) * 0.000001f) + "ms");
2329-
}
2330-
23312256
if (LOCAL_LOGV) {
23322257
Log.v(TAG, "Surface " + surface + " unlockCanvasAndPost");
23332258
}
@@ -3186,10 +3111,6 @@ private boolean leaveTouchMode() {
31863111
}
31873112

31883113
private void deliverInputEvent(QueuedInputEvent q) {
3189-
if (ViewDebug.DEBUG_LATENCY) {
3190-
q.mDeliverTimeNanos = System.nanoTime();
3191-
}
3192-
31933114
Trace.traceBegin(Trace.TRACE_TAG_VIEW, "deliverInputEvent");
31943115
try {
31953116
if (q.mEvent instanceof KeyEvent) {
@@ -3637,9 +3558,6 @@ void handleImeFinishedEvent(int seq, boolean handled) {
36373558

36383559
private void deliverKeyEventPostIme(QueuedInputEvent q) {
36393560
final KeyEvent event = (KeyEvent)q.mEvent;
3640-
if (ViewDebug.DEBUG_LATENCY) {
3641-
q.mDeliverPostImeTimeNanos = System.nanoTime();
3642-
}
36433561

36443562
// If the view went away, then the event will not be handled.
36453563
if (mView == null || !mAdded) {
@@ -4162,11 +4080,6 @@ private static final class QueuedInputEvent {
41624080
public InputEvent mEvent;
41634081
public InputEventReceiver mReceiver;
41644082
public int mFlags;
4165-
4166-
// Used for latency calculations.
4167-
public long mReceiveTimeNanos;
4168-
public long mDeliverTimeNanos;
4169-
public long mDeliverPostImeTimeNanos;
41704083
}
41714084

41724085
private QueuedInputEvent obtainQueuedInputEvent(InputEvent event,
@@ -4205,12 +4118,6 @@ void enqueueInputEvent(InputEvent event,
42054118
InputEventReceiver receiver, int flags, boolean processImmediately) {
42064119
QueuedInputEvent q = obtainQueuedInputEvent(event, receiver, flags);
42074120

4208-
if (ViewDebug.DEBUG_LATENCY) {
4209-
q.mReceiveTimeNanos = System.nanoTime();
4210-
q.mDeliverTimeNanos = 0;
4211-
q.mDeliverPostImeTimeNanos = 0;
4212-
}
4213-
42144121
// Always enqueue the input event in order, regardless of its time stamp.
42154122
// We do this because the application or the IME may inject key events
42164123
// in response to touch events and we want to ensure that the injected keys
@@ -4264,42 +4171,6 @@ private void finishInputEvent(QueuedInputEvent q, boolean handled) {
42644171
throw new IllegalStateException("finished input event out of order");
42654172
}
42664173

4267-
if (ViewDebug.DEBUG_LATENCY) {
4268-
final long now = System.nanoTime();
4269-
final long eventTime = q.mEvent.getEventTimeNano();
4270-
final StringBuilder msg = new StringBuilder();
4271-
msg.append("Spent ");
4272-
msg.append((now - q.mReceiveTimeNanos) * 0.000001f);
4273-
msg.append("ms processing ");
4274-
if (q.mEvent instanceof KeyEvent) {
4275-
final KeyEvent keyEvent = (KeyEvent)q.mEvent;
4276-
msg.append("key event, action=");
4277-
msg.append(KeyEvent.actionToString(keyEvent.getAction()));
4278-
} else {
4279-
final MotionEvent motionEvent = (MotionEvent)q.mEvent;
4280-
msg.append("motion event, action=");
4281-
msg.append(MotionEvent.actionToString(motionEvent.getAction()));
4282-
msg.append(", historySize=");
4283-
msg.append(motionEvent.getHistorySize());
4284-
}
4285-
msg.append(", handled=");
4286-
msg.append(handled);
4287-
msg.append(", received at +");
4288-
msg.append((q.mReceiveTimeNanos - eventTime) * 0.000001f);
4289-
if (q.mDeliverTimeNanos != 0) {
4290-
msg.append("ms, delivered at +");
4291-
msg.append((q.mDeliverTimeNanos - eventTime) * 0.000001f);
4292-
}
4293-
if (q.mDeliverPostImeTimeNanos != 0) {
4294-
msg.append("ms, delivered post IME at +");
4295-
msg.append((q.mDeliverPostImeTimeNanos - eventTime) * 0.000001f);
4296-
}
4297-
msg.append("ms, finished at +");
4298-
msg.append((now - eventTime) * 0.000001f);
4299-
msg.append("ms.");
4300-
Log.d(ViewDebug.DEBUG_LATENCY_TAG, msg.toString());
4301-
}
4302-
43034174
if (q.mReceiver != null) {
43044175
q.mReceiver.finishInputEvent(q.mEvent, handled);
43054176
} else {

0 commit comments

Comments
 (0)