Merge "Add presentTime to FrameInfo" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
554afe2691
@@ -213,8 +213,7 @@ public final class FrameMetrics {
|
|||||||
Index.FRAME_TIMELINE_VSYNC_ID,
|
Index.FRAME_TIMELINE_VSYNC_ID,
|
||||||
Index.INTENDED_VSYNC,
|
Index.INTENDED_VSYNC,
|
||||||
Index.VSYNC,
|
Index.VSYNC,
|
||||||
Index.OLDEST_INPUT_EVENT,
|
Index.INPUT_EVENT_ID,
|
||||||
Index.NEWEST_INPUT_EVENT,
|
|
||||||
Index.HANDLE_INPUT_START,
|
Index.HANDLE_INPUT_START,
|
||||||
Index.ANIMATION_START,
|
Index.ANIMATION_START,
|
||||||
Index.PERFORM_TRAVERSALS_START,
|
Index.PERFORM_TRAVERSALS_START,
|
||||||
@@ -225,8 +224,11 @@ public final class FrameMetrics {
|
|||||||
Index.ISSUE_DRAW_COMMANDS_START,
|
Index.ISSUE_DRAW_COMMANDS_START,
|
||||||
Index.SWAP_BUFFERS,
|
Index.SWAP_BUFFERS,
|
||||||
Index.FRAME_COMPLETED,
|
Index.FRAME_COMPLETED,
|
||||||
|
Index.DEQUEUE_BUFFER_DURATION,
|
||||||
|
Index.QUEUE_BUFFER_DURATION,
|
||||||
Index.GPU_COMPLETED,
|
Index.GPU_COMPLETED,
|
||||||
Index.SWAP_BUFFERS_COMPLETED
|
Index.SWAP_BUFFERS_COMPLETED,
|
||||||
|
Index.DISPLAY_PRESENT_TIME,
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface Index {
|
public @interface Index {
|
||||||
@@ -234,20 +236,22 @@ public final class FrameMetrics {
|
|||||||
int FRAME_TIMELINE_VSYNC_ID = 1;
|
int FRAME_TIMELINE_VSYNC_ID = 1;
|
||||||
int INTENDED_VSYNC = 2;
|
int INTENDED_VSYNC = 2;
|
||||||
int VSYNC = 3;
|
int VSYNC = 3;
|
||||||
int OLDEST_INPUT_EVENT = 4;
|
int INPUT_EVENT_ID = 4;
|
||||||
int NEWEST_INPUT_EVENT = 5;
|
int HANDLE_INPUT_START = 5;
|
||||||
int HANDLE_INPUT_START = 6;
|
int ANIMATION_START = 6;
|
||||||
int ANIMATION_START = 7;
|
int PERFORM_TRAVERSALS_START = 7;
|
||||||
int PERFORM_TRAVERSALS_START = 8;
|
int DRAW_START = 8;
|
||||||
int DRAW_START = 9;
|
int FRAME_DEADLINE = 9;
|
||||||
int FRAME_DEADLINE = 10;
|
int SYNC_QUEUED = 10;
|
||||||
int SYNC_QUEUED = 11;
|
int SYNC_START = 11;
|
||||||
int SYNC_START = 12;
|
int ISSUE_DRAW_COMMANDS_START = 12;
|
||||||
int ISSUE_DRAW_COMMANDS_START = 13;
|
int SWAP_BUFFERS = 13;
|
||||||
int SWAP_BUFFERS = 14;
|
int FRAME_COMPLETED = 14;
|
||||||
int FRAME_COMPLETED = 15;
|
int DEQUEUE_BUFFER_DURATION = 15;
|
||||||
int GPU_COMPLETED = 18;
|
int QUEUE_BUFFER_DURATION = 16;
|
||||||
int SWAP_BUFFERS_COMPLETED = 19;
|
int GPU_COMPLETED = 17;
|
||||||
|
int SWAP_BUFFERS_COMPLETED = 18;
|
||||||
|
int DISPLAY_PRESENT_TIME = 19;
|
||||||
|
|
||||||
int FRAME_STATS_COUNT = 20; // must always be last and in sync with
|
int FRAME_STATS_COUNT = 20; // must always be last and in sync with
|
||||||
// FrameInfoIndex::NumIndexes in libs/hwui/FrameInfo.h
|
// FrameInfoIndex::NumIndexes in libs/hwui/FrameInfo.h
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ public class ViewFrameInfo {
|
|||||||
public void populateFrameInfo(FrameInfo frameInfo) {
|
public void populateFrameInfo(FrameInfo frameInfo) {
|
||||||
frameInfo.frameInfo[FrameInfo.FLAGS] |= flags;
|
frameInfo.frameInfo[FrameInfo.FLAGS] |= flags;
|
||||||
frameInfo.frameInfo[FrameInfo.DRAW_START] = drawStart;
|
frameInfo.frameInfo[FrameInfo.DRAW_START] = drawStart;
|
||||||
frameInfo.frameInfo[FrameInfo.OLDEST_INPUT_EVENT] = oldestInputEventTime;
|
// TODO(b/169866723): Use InputEventAssigner
|
||||||
frameInfo.frameInfo[FrameInfo.NEWEST_INPUT_EVENT] = newestInputEventTime;
|
frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID] = newestInputEventTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,28 +69,26 @@ public final class FrameInfo {
|
|||||||
// animation & drawing system
|
// animation & drawing system
|
||||||
public static final int VSYNC = 3;
|
public static final int VSYNC = 3;
|
||||||
|
|
||||||
// The time of the oldest input event
|
// The id of the input event that caused the current frame
|
||||||
public static final int OLDEST_INPUT_EVENT = 4;
|
public static final int INPUT_EVENT_ID = 4;
|
||||||
|
|
||||||
// The time of the newest input event
|
|
||||||
public static final int NEWEST_INPUT_EVENT = 5;
|
|
||||||
|
|
||||||
// When input event handling started
|
// When input event handling started
|
||||||
public static final int HANDLE_INPUT_START = 6;
|
public static final int HANDLE_INPUT_START = 5;
|
||||||
|
|
||||||
// When animation evaluations started
|
// When animation evaluations started
|
||||||
public static final int ANIMATION_START = 7;
|
public static final int ANIMATION_START = 6;
|
||||||
|
|
||||||
// When ViewRootImpl#performTraversals() started
|
// When ViewRootImpl#performTraversals() started
|
||||||
public static final int PERFORM_TRAVERSALS_START = 8;
|
public static final int PERFORM_TRAVERSALS_START = 7;
|
||||||
|
|
||||||
// When View:draw() started
|
// When View:draw() started
|
||||||
public static final int DRAW_START = 9;
|
public static final int DRAW_START = 8;
|
||||||
|
|
||||||
// When the frame needs to be ready by
|
// When the frame needs to be ready by
|
||||||
public static final int FRAME_DEADLINE = 10;
|
public static final int FRAME_DEADLINE = 9;
|
||||||
|
|
||||||
// Must be the last one
|
// Must be the last one
|
||||||
|
// This value must be in sync with `UI_THREAD_FRAME_INFO_SIZE` in FrameInfo.h
|
||||||
private static final int FRAME_INFO_SIZE = FRAME_DEADLINE + 1;
|
private static final int FRAME_INFO_SIZE = FRAME_DEADLINE + 1;
|
||||||
|
|
||||||
/** checkstyle */
|
/** checkstyle */
|
||||||
|
|||||||
@@ -20,13 +20,12 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
namespace uirenderer {
|
namespace uirenderer {
|
||||||
|
|
||||||
const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> FrameInfoNames = {
|
const std::array FrameInfoNames{
|
||||||
"Flags",
|
"Flags",
|
||||||
"FrameTimelineVsyncId",
|
"FrameTimelineVsyncId",
|
||||||
"IntendedVsync",
|
"IntendedVsync",
|
||||||
"Vsync",
|
"Vsync",
|
||||||
"OldestInputEvent",
|
"InputEventId",
|
||||||
"NewestInputEvent",
|
|
||||||
"HandleInputStart",
|
"HandleInputStart",
|
||||||
"AnimationStart",
|
"AnimationStart",
|
||||||
"PerformTraversalsStart",
|
"PerformTraversalsStart",
|
||||||
@@ -40,7 +39,8 @@ const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> Fram
|
|||||||
"DequeueBufferDuration",
|
"DequeueBufferDuration",
|
||||||
"QueueBufferDuration",
|
"QueueBufferDuration",
|
||||||
"GpuCompleted",
|
"GpuCompleted",
|
||||||
"SwapBuffersCompleted"
|
"SwapBuffersCompleted",
|
||||||
|
"DisplayPresentTime",
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 20,
|
static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 20,
|
||||||
|
|||||||
@@ -28,15 +28,14 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
namespace uirenderer {
|
namespace uirenderer {
|
||||||
|
|
||||||
#define UI_THREAD_FRAME_INFO_SIZE 11
|
static constexpr size_t UI_THREAD_FRAME_INFO_SIZE = 10;
|
||||||
|
|
||||||
enum class FrameInfoIndex {
|
enum class FrameInfoIndex {
|
||||||
Flags = 0,
|
Flags = 0,
|
||||||
FrameTimelineVsyncId,
|
FrameTimelineVsyncId,
|
||||||
IntendedVsync,
|
IntendedVsync,
|
||||||
Vsync,
|
Vsync,
|
||||||
OldestInputEvent,
|
InputEventId,
|
||||||
NewestInputEvent,
|
|
||||||
HandleInputStart,
|
HandleInputStart,
|
||||||
AnimationStart,
|
AnimationStart,
|
||||||
PerformTraversalsStart,
|
PerformTraversalsStart,
|
||||||
@@ -56,13 +55,14 @@ enum class FrameInfoIndex {
|
|||||||
|
|
||||||
GpuCompleted,
|
GpuCompleted,
|
||||||
SwapBuffersCompleted,
|
SwapBuffersCompleted,
|
||||||
|
DisplayPresentTime,
|
||||||
|
|
||||||
// Must be the last value!
|
// Must be the last value!
|
||||||
// Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT
|
// Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT
|
||||||
NumIndexes
|
NumIndexes
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> FrameInfoNames;
|
extern const std::array<const char*, static_cast<int>(FrameInfoIndex::NumIndexes)> FrameInfoNames;
|
||||||
|
|
||||||
namespace FrameInfoFlags {
|
namespace FrameInfoFlags {
|
||||||
enum {
|
enum {
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ void JankTracker::dumpData(int fd, const ProfileDataDescription* description,
|
|||||||
void JankTracker::dumpFrames(int fd) {
|
void JankTracker::dumpFrames(int fd) {
|
||||||
dprintf(fd, "\n\n---PROFILEDATA---\n");
|
dprintf(fd, "\n\n---PROFILEDATA---\n");
|
||||||
for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) {
|
for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) {
|
||||||
dprintf(fd, "%s", FrameInfoNames[i].c_str());
|
dprintf(fd, "%s", FrameInfoNames[i]);
|
||||||
dprintf(fd, ",");
|
dprintf(fd, ",");
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < mFrames.size(); i++) {
|
for (size_t i = 0; i < mFrames.size(); i++) {
|
||||||
|
|||||||
@@ -240,8 +240,8 @@ static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject
|
|||||||
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
|
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
|
||||||
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
|
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
|
||||||
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
|
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
|
||||||
"Mismatched size expectations, given %d expected %d",
|
"Mismatched size expectations, given %d expected %zu", frameInfoSize,
|
||||||
frameInfoSize, UI_THREAD_FRAME_INFO_SIZE);
|
UI_THREAD_FRAME_INFO_SIZE);
|
||||||
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
|
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
|
||||||
env->GetLongArrayRegion(frameInfo, 0, frameInfoSize, proxy->frameInfo());
|
env->GetLongArrayRegion(frameInfo, 0, frameInfoSize, proxy->frameInfo());
|
||||||
return proxy->syncAndDrawFrame();
|
return proxy->syncAndDrawFrame();
|
||||||
|
|||||||
@@ -484,7 +484,8 @@ void CanvasContext::draw() {
|
|||||||
// TODO(b/165985262): measure performance impact
|
// TODO(b/165985262): measure performance impact
|
||||||
const auto vsyncId = mCurrentFrameInfo->get(FrameInfoIndex::FrameTimelineVsyncId);
|
const auto vsyncId = mCurrentFrameInfo->get(FrameInfoIndex::FrameTimelineVsyncId);
|
||||||
if (vsyncId != UiFrameInfoBuilder::INVALID_VSYNC_ID) {
|
if (vsyncId != UiFrameInfoBuilder::INVALID_VSYNC_ID) {
|
||||||
const auto inputEventId = mCurrentFrameInfo->get(FrameInfoIndex::NewestInputEvent);
|
const auto inputEventId =
|
||||||
|
static_cast<int32_t>(mCurrentFrameInfo->get(FrameInfoIndex::InputEventId));
|
||||||
native_window_set_frame_timeline_info(mNativeSurface->getNativeWindow(), vsyncId,
|
native_window_set_frame_timeline_info(mNativeSurface->getNativeWindow(), vsyncId,
|
||||||
inputEventId);
|
inputEventId);
|
||||||
}
|
}
|
||||||
@@ -591,7 +592,6 @@ void CanvasContext::draw() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CanvasContext::finishFrame(FrameInfo* frameInfo) {
|
void CanvasContext::finishFrame(FrameInfo* frameInfo) {
|
||||||
|
|
||||||
// TODO (b/169858044): Consolidate this into a single call.
|
// TODO (b/169858044): Consolidate this into a single call.
|
||||||
mJankTracker.finishFrame(*frameInfo);
|
mJankTracker.finishFrame(*frameInfo);
|
||||||
mJankTracker.finishGpuDraw(*frameInfo);
|
mJankTracker.finishGpuDraw(*frameInfo);
|
||||||
|
|||||||
@@ -62,15 +62,12 @@ class ViewFrameInfoTest {
|
|||||||
fun testUpdateFrameInfoFromViewFrameInfo() {
|
fun testUpdateFrameInfoFromViewFrameInfo() {
|
||||||
val frameInfo = FrameInfo()
|
val frameInfo = FrameInfo()
|
||||||
// By default, all values should be zero
|
// By default, all values should be zero
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.OLDEST_INPUT_EVENT]).isEqualTo(0)
|
// TODO(b/169866723): Use InputEventAssigner and assert INPUT_EVENT_ID
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.NEWEST_INPUT_EVENT]).isEqualTo(0)
|
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(0)
|
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(0)
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isEqualTo(0)
|
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isEqualTo(0)
|
||||||
|
|
||||||
// The values inside FrameInfo should match those from ViewFrameInfo after we update them
|
// The values inside FrameInfo should match those from ViewFrameInfo after we update them
|
||||||
mViewFrameInfo.populateFrameInfo(frameInfo)
|
mViewFrameInfo.populateFrameInfo(frameInfo)
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.OLDEST_INPUT_EVENT]).isEqualTo(10)
|
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.NEWEST_INPUT_EVENT]).isEqualTo(20)
|
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(
|
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(
|
||||||
FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
|
FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
|
||||||
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isGreaterThan(mTimeStarted)
|
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isGreaterThan(mTimeStarted)
|
||||||
|
|||||||
Reference in New Issue
Block a user