Trace Window relayout reasons

Window relayouts (and subsequent binder calls) are common performance issues
and the reason for relayout can be hard to determine in Perfetto traces.

This adds reason for triggered window relayout to the trace
if View tracing is currently enabled.

Bug: 231121537
Test: Using perfetto, see https://screenshot.googleplex.com/AgsM2pfidDAav7j
Change-Id: Ib1d9b673517eb80b09c6bacedd34e26cb502877b
This commit is contained in:
Jernej Virag
2022-04-29 15:21:57 +00:00
parent ec9b0f949e
commit c48601b0af

View File

@@ -2895,6 +2895,14 @@ public final class ViewRootImpl implements ViewParent,
if (mFirst || windowShouldResize || viewVisibilityChanged || params != null
|| mForceNextWindowRelayout) {
if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
Trace.traceBegin(Trace.TRACE_TAG_VIEW,
TextUtils.formatSimple("relayoutWindow#"
+ "first=%b/resize=%b/vis=%b/params=%b/force=%b",
mFirst, windowShouldResize, viewVisibilityChanged, params != null,
mForceNextWindowRelayout));
}
mForceNextWindowRelayout = false;
// If this window is giving internal insets to the window manager, then we want to first
@@ -3085,6 +3093,10 @@ public final class ViewRootImpl implements ViewParent,
}
}
} catch (RemoteException e) {
} finally {
if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
}
}
if (DEBUG_ORIENTATION) Log.v(