Mark first frames in metrics properly
Such that we only set the flag in case window visibility actually changes. There are a lot of other cases where we need to do a window relayout which can lead to visible jank. Test: FrameMetricsListenerTest, manual Bug: 185902609 Change-Id: Ia09ce640f3a89bf9dd4ff0f4e4469e88a513709a
This commit is contained in:
parent
30de424ddf
commit
9516605d63
@ -16,6 +16,8 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import static android.graphics.FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
@ -172,8 +174,6 @@ public final class FrameMetrics {
|
||||
**/
|
||||
public static final int DEADLINE = 13;
|
||||
|
||||
private static final int FRAME_INFO_FLAG_FIRST_DRAW = 1 << 0;
|
||||
|
||||
/**
|
||||
* Identifiers for metrics available for each frame.
|
||||
*
|
||||
@ -343,7 +343,7 @@ public final class FrameMetrics {
|
||||
}
|
||||
|
||||
if (id == FIRST_DRAW_FRAME) {
|
||||
return (mTimingData[Index.FLAGS] & FRAME_INFO_FLAG_FIRST_DRAW) != 0 ? 1 : 0;
|
||||
return (mTimingData[Index.FLAGS] & FLAG_WINDOW_VISIBILITY_CHANGED) != 0 ? 1 : 0;
|
||||
} else if (id == INTENDED_VSYNC_TIMESTAMP) {
|
||||
return mTimingData[Index.INTENDED_VSYNC];
|
||||
} else if (id == VSYNC_TIMESTAMP) {
|
||||
|
@ -2764,7 +2764,9 @@ public final class ViewRootImpl implements ViewParent,
|
||||
// to resume them
|
||||
mDirty.set(0, 0, mWidth, mHeight);
|
||||
}
|
||||
mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED;
|
||||
}
|
||||
if (mFirst || viewVisibilityChanged) {
|
||||
mViewFrameInfo.flags |= FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED;
|
||||
}
|
||||
relayoutResult = relayoutWindow(params, viewVisibility, insetsPending);
|
||||
final boolean freeformResizing = (relayoutResult
|
||||
|
@ -46,7 +46,7 @@ public final class FrameInfo {
|
||||
public static final int FLAGS = 0;
|
||||
|
||||
// Is this the first-draw following a window layout?
|
||||
public static final long FLAG_WINDOW_LAYOUT_CHANGED = 1;
|
||||
public static final long FLAG_WINDOW_VISIBILITY_CHANGED = 1;
|
||||
|
||||
// A renderer associated with just a Surface, not with a ViewRootImpl instance.
|
||||
public static final long FLAG_SURFACE_CANVAS = 1 << 2;
|
||||
@ -56,7 +56,7 @@ public final class FrameInfo {
|
||||
public static final long INVALID_VSYNC_ID = -1;
|
||||
|
||||
@LongDef(flag = true, value = {
|
||||
FLAG_WINDOW_LAYOUT_CHANGED, FLAG_SURFACE_CANVAS })
|
||||
FLAG_WINDOW_VISIBILITY_CHANGED, FLAG_SURFACE_CANVAS })
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FrameInfoFlags {}
|
||||
|
||||
|
@ -68,7 +68,7 @@ extern const std::array<const char*, static_cast<int>(FrameInfoIndex::NumIndexes
|
||||
|
||||
namespace FrameInfoFlags {
|
||||
enum {
|
||||
WindowLayoutChanged = 1 << 0,
|
||||
WindowVisibilityChanged = 1 << 0,
|
||||
RTAnimation = 1 << 1,
|
||||
SurfaceCanvas = 1 << 2,
|
||||
SkippedFrame = 1 << 3,
|
||||
|
@ -35,7 +35,7 @@ class ViewFrameInfoTest {
|
||||
fun setUp() {
|
||||
mViewFrameInfo.reset()
|
||||
mViewFrameInfo.setInputEvent(139)
|
||||
mViewFrameInfo.flags = mViewFrameInfo.flags or FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED
|
||||
mViewFrameInfo.flags = mViewFrameInfo.flags or FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED
|
||||
mTimeStarted = SystemClock.uptimeNanos()
|
||||
mViewFrameInfo.markDrawStart()
|
||||
}
|
||||
@ -43,7 +43,7 @@ class ViewFrameInfoTest {
|
||||
@Test
|
||||
fun testPopulateFields() {
|
||||
assertThat(mViewFrameInfo.drawStart).isGreaterThan(mTimeStarted)
|
||||
assertThat(mViewFrameInfo.flags).isEqualTo(FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
|
||||
assertThat(mViewFrameInfo.flags).isEqualTo(FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED)
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -66,7 +66,7 @@ class ViewFrameInfoTest {
|
||||
mViewFrameInfo.populateFrameInfo(frameInfo)
|
||||
assertThat(frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID]).isEqualTo(139)
|
||||
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(
|
||||
FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
|
||||
FrameInfo.FLAG_WINDOW_VISIBILITY_CHANGED)
|
||||
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isGreaterThan(mTimeStarted)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user