From 2f0a514053b8b875dcbd8d581a7bcfdd2d5ef2af Mon Sep 17 00:00:00 2001 From: Ibrahim Yilmaz Date: Mon, 3 Jul 2023 20:52:38 +0000 Subject: [PATCH] Trace ImageFloatingTextView and NotificationToplineView There are binder calls in BigText style perfetto traces. They can be getLayoutDirection calls. In order to surface this and measure onMeasure perf of ImageFloatingTextView,this CL add traces for both onMeasure and getLayoutDirection. In addition to that, this CL adds tracing to onMeasure or NotificationTopLineView Bug: 288578300 Test: perfetto Change-Id: I08a2fa35d7e9c5bfe554b31b152a7d9835a66974 --- core/java/android/view/NotificationTopLineView.java | 3 +++ .../android/internal/widget/ImageFloatingTextView.java | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/NotificationTopLineView.java b/core/java/android/view/NotificationTopLineView.java index bd20f5bf82fdf..a2919f5bfd745 100644 --- a/core/java/android/view/NotificationTopLineView.java +++ b/core/java/android/view/NotificationTopLineView.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Rect; +import android.os.Trace; import android.util.AttributeSet; import android.widget.RemoteViews; @@ -106,6 +107,7 @@ public class NotificationTopLineView extends ViewGroup { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + Trace.beginSection("NotificationTopLineView#onMeasure"); final int givenWidth = MeasureSpec.getSize(widthMeasureSpec); final int givenHeight = MeasureSpec.getSize(heightMeasureSpec); final boolean wrapHeight = MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.AT_MOST; @@ -161,6 +163,7 @@ public class NotificationTopLineView extends ViewGroup { .finish(); } setMeasuredDimension(givenWidth, wrapHeight ? maxChildHeight : givenHeight); + Trace.endSection(); } @Override diff --git a/core/java/com/android/internal/widget/ImageFloatingTextView.java b/core/java/com/android/internal/widget/ImageFloatingTextView.java index 1ac5e1f12bfa3..de10bd2f47d7d 100644 --- a/core/java/com/android/internal/widget/ImageFloatingTextView.java +++ b/core/java/com/android/internal/widget/ImageFloatingTextView.java @@ -18,6 +18,7 @@ package com.android.internal.widget; import android.annotation.Nullable; import android.content.Context; +import android.os.Trace; import android.text.BoringLayout; import android.text.Layout; import android.text.StaticLayout; @@ -68,6 +69,7 @@ public class ImageFloatingTextView extends TextView { protected Layout makeSingleLayout(int wantWidth, BoringLayout.Metrics boring, int ellipsisWidth, Layout.Alignment alignment, boolean shouldEllipsize, TextUtils.TruncateAt effectiveEllipsize, boolean useSaved) { + Trace.beginSection("ImageFloatingTextView#makeSingleLayout"); TransformationMethod transformationMethod = getTransformationMethod(); CharSequence text = getText(); if (transformationMethod != null) { @@ -110,7 +112,9 @@ public class ImageFloatingTextView extends TextView { builder.setIndents(null, margins); } - return builder.build(); + final StaticLayout result = builder.build(); + Trace.endSection(); + return result; } /** @@ -135,6 +139,7 @@ public class ImageFloatingTextView extends TextView { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + Trace.beginSection("ImageFloatingTextView#onMeasure"); int availableHeight = MeasureSpec.getSize(heightMeasureSpec) - mPaddingTop - mPaddingBottom; if (getLayout() != null && getLayout().getHeight() != availableHeight) { // We've been measured before and the new size is different than before, lets make sure @@ -161,6 +166,7 @@ public class ImageFloatingTextView extends TextView { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } + Trace.endSection(); } @Override