summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2021-02-17 06:19:36 +0000
committer Siarhei Vishniakou <svv@google.com> 2021-02-18 22:07:09 +0000
commit4bcbffd584755b90eb0b8690375f02fd3850ad79 (patch)
tree13b73038b57b1169f7c90bf9cac2bf0eeba97870
parentbe7698d68af250c156ae6b436528e4a3c610f78f (diff)
Add presentTime to FrameInfo
Present time is available to apps, but is not currently stored inside FrameInfo. In this CL, we add a location for storing the present time inside FrameInfo. Currently, the metrics reporter is triggered after the buffer is sent to SurfaceFlinger. That means, metrics for anything that happens after gpu draw completes are currently not available. In a future CL, we will populate the 'presentTime' field. In a future CL, we will register a metrics observer inside ViewRootImpl in order to send this data to InputDispatcher. This will enable end-to-end touch latency metrics collection. Bug: 169866723 Test: printed present time inside FrameTimeline.cpp (surfaceflinger side) and compared to the values printed inside a metrics observer registered in ViewRootImpl (not done in this CL) Test: atest ViewFrameInfoTest Change-Id: I7d0f8c5d7b5a2572abdc4e107123e8938a36f582
-rw-r--r--core/java/android/view/FrameMetrics.java38
-rw-r--r--core/java/android/view/ViewFrameInfo.java4
-rw-r--r--graphics/java/android/graphics/FrameInfo.java18
-rw-r--r--libs/hwui/FrameInfo.cpp8
-rw-r--r--libs/hwui/FrameInfo.h8
-rw-r--r--libs/hwui/JankTracker.cpp2
-rw-r--r--libs/hwui/jni/android_graphics_HardwareRenderer.cpp4
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp4
-rw-r--r--tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt5
9 files changed, 45 insertions, 46 deletions
diff --git a/core/java/android/view/FrameMetrics.java b/core/java/android/view/FrameMetrics.java
index 6543de15f969..eb49e52d5050 100644
--- a/core/java/android/view/FrameMetrics.java
+++ b/core/java/android/view/FrameMetrics.java
@@ -213,8 +213,7 @@ public final class FrameMetrics {
Index.FRAME_TIMELINE_VSYNC_ID,
Index.INTENDED_VSYNC,
Index.VSYNC,
- Index.OLDEST_INPUT_EVENT,
- Index.NEWEST_INPUT_EVENT,
+ Index.INPUT_EVENT_ID,
Index.HANDLE_INPUT_START,
Index.ANIMATION_START,
Index.PERFORM_TRAVERSALS_START,
@@ -225,8 +224,11 @@ public final class FrameMetrics {
Index.ISSUE_DRAW_COMMANDS_START,
Index.SWAP_BUFFERS,
Index.FRAME_COMPLETED,
+ Index.DEQUEUE_BUFFER_DURATION,
+ Index.QUEUE_BUFFER_DURATION,
Index.GPU_COMPLETED,
- Index.SWAP_BUFFERS_COMPLETED
+ Index.SWAP_BUFFERS_COMPLETED,
+ Index.DISPLAY_PRESENT_TIME,
})
@Retention(RetentionPolicy.SOURCE)
public @interface Index {
@@ -234,20 +236,22 @@ public final class FrameMetrics {
int FRAME_TIMELINE_VSYNC_ID = 1;
int INTENDED_VSYNC = 2;
int VSYNC = 3;
- int OLDEST_INPUT_EVENT = 4;
- int NEWEST_INPUT_EVENT = 5;
- int HANDLE_INPUT_START = 6;
- int ANIMATION_START = 7;
- int PERFORM_TRAVERSALS_START = 8;
- int DRAW_START = 9;
- int FRAME_DEADLINE = 10;
- int SYNC_QUEUED = 11;
- int SYNC_START = 12;
- int ISSUE_DRAW_COMMANDS_START = 13;
- int SWAP_BUFFERS = 14;
- int FRAME_COMPLETED = 15;
- int GPU_COMPLETED = 18;
- int SWAP_BUFFERS_COMPLETED = 19;
+ int INPUT_EVENT_ID = 4;
+ int HANDLE_INPUT_START = 5;
+ int ANIMATION_START = 6;
+ int PERFORM_TRAVERSALS_START = 7;
+ int DRAW_START = 8;
+ int FRAME_DEADLINE = 9;
+ int SYNC_QUEUED = 10;
+ int SYNC_START = 11;
+ int ISSUE_DRAW_COMMANDS_START = 12;
+ int SWAP_BUFFERS = 13;
+ int FRAME_COMPLETED = 14;
+ int DEQUEUE_BUFFER_DURATION = 15;
+ int QUEUE_BUFFER_DURATION = 16;
+ 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
// FrameInfoIndex::NumIndexes in libs/hwui/FrameInfo.h
diff --git a/core/java/android/view/ViewFrameInfo.java b/core/java/android/view/ViewFrameInfo.java
index 890d071f8090..d4aaa611f800 100644
--- a/core/java/android/view/ViewFrameInfo.java
+++ b/core/java/android/view/ViewFrameInfo.java
@@ -58,8 +58,8 @@ public class ViewFrameInfo {
public void populateFrameInfo(FrameInfo frameInfo) {
frameInfo.frameInfo[FrameInfo.FLAGS] |= flags;
frameInfo.frameInfo[FrameInfo.DRAW_START] = drawStart;
- frameInfo.frameInfo[FrameInfo.OLDEST_INPUT_EVENT] = oldestInputEventTime;
- frameInfo.frameInfo[FrameInfo.NEWEST_INPUT_EVENT] = newestInputEventTime;
+ // TODO(b/169866723): Use InputEventAssigner
+ frameInfo.frameInfo[FrameInfo.INPUT_EVENT_ID] = newestInputEventTime;
}
/**
diff --git a/graphics/java/android/graphics/FrameInfo.java b/graphics/java/android/graphics/FrameInfo.java
index d59abb5916a0..189be53a397f 100644
--- a/graphics/java/android/graphics/FrameInfo.java
+++ b/graphics/java/android/graphics/FrameInfo.java
@@ -69,28 +69,26 @@ public final class FrameInfo {
// animation & drawing system
public static final int VSYNC = 3;
- // The time of the oldest input event
- public static final int OLDEST_INPUT_EVENT = 4;
-
- // The time of the newest input event
- public static final int NEWEST_INPUT_EVENT = 5;
+ // The id of the input event that caused the current frame
+ public static final int INPUT_EVENT_ID = 4;
// 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
- public static final int ANIMATION_START = 7;
+ public static final int ANIMATION_START = 6;
// When ViewRootImpl#performTraversals() started
- public static final int PERFORM_TRAVERSALS_START = 8;
+ public static final int PERFORM_TRAVERSALS_START = 7;
// 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
- public static final int FRAME_DEADLINE = 10;
+ public static final int FRAME_DEADLINE = 9;
// 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;
/** checkstyle */
diff --git a/libs/hwui/FrameInfo.cpp b/libs/hwui/FrameInfo.cpp
index 5d3f6f2f28c9..2448cc904104 100644
--- a/libs/hwui/FrameInfo.cpp
+++ b/libs/hwui/FrameInfo.cpp
@@ -20,13 +20,12 @@
namespace android {
namespace uirenderer {
-const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> FrameInfoNames = {
+const std::array FrameInfoNames{
"Flags",
"FrameTimelineVsyncId",
"IntendedVsync",
"Vsync",
- "OldestInputEvent",
- "NewestInputEvent",
+ "InputEventId",
"HandleInputStart",
"AnimationStart",
"PerformTraversalsStart",
@@ -40,7 +39,8 @@ const std::array<std::string, static_cast<int>(FrameInfoIndex::NumIndexes)> Fram
"DequeueBufferDuration",
"QueueBufferDuration",
"GpuCompleted",
- "SwapBuffersCompleted"
+ "SwapBuffersCompleted",
+ "DisplayPresentTime",
};
static_assert(static_cast<int>(FrameInfoIndex::NumIndexes) == 20,
diff --git a/libs/hwui/FrameInfo.h b/libs/hwui/FrameInfo.h
index 45a367f525da..912d04c5d87d 100644
--- a/libs/hwui/FrameInfo.h
+++ b/libs/hwui/FrameInfo.h
@@ -28,15 +28,14 @@
namespace android {
namespace uirenderer {
-#define UI_THREAD_FRAME_INFO_SIZE 11
+static constexpr size_t UI_THREAD_FRAME_INFO_SIZE = 10;
enum class FrameInfoIndex {
Flags = 0,
FrameTimelineVsyncId,
IntendedVsync,
Vsync,
- OldestInputEvent,
- NewestInputEvent,
+ InputEventId,
HandleInputStart,
AnimationStart,
PerformTraversalsStart,
@@ -56,13 +55,14 @@ enum class FrameInfoIndex {
GpuCompleted,
SwapBuffersCompleted,
+ DisplayPresentTime,
// Must be the last value!
// Also must be kept in sync with FrameMetrics.java#FRAME_STATS_COUNT
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 {
enum {
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp
index 4a2e30dd38f2..714eb7b38d8b 100644
--- a/libs/hwui/JankTracker.cpp
+++ b/libs/hwui/JankTracker.cpp
@@ -219,7 +219,7 @@ void JankTracker::dumpData(int fd, const ProfileDataDescription* description,
void JankTracker::dumpFrames(int fd) {
dprintf(fd, "\n\n---PROFILEDATA---\n");
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, ",");
}
for (size_t i = 0; i < mFrames.size(); i++) {
diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
index df66981853bb..f24ba5c1c878 100644
--- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
@@ -240,8 +240,8 @@ static void android_view_ThreadedRenderer_setSdrWhitePoint(JNIEnv* env, jobject
static int android_view_ThreadedRenderer_syncAndDrawFrame(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlongArray frameInfo, jint frameInfoSize) {
LOG_ALWAYS_FATAL_IF(frameInfoSize != UI_THREAD_FRAME_INFO_SIZE,
- "Mismatched size expectations, given %d expected %d",
- frameInfoSize, UI_THREAD_FRAME_INFO_SIZE);
+ "Mismatched size expectations, given %d expected %zu", frameInfoSize,
+ UI_THREAD_FRAME_INFO_SIZE);
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
env->GetLongArrayRegion(frameInfo, 0, frameInfoSize, proxy->frameInfo());
return proxy->syncAndDrawFrame();
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index b760db287bcb..f69ddacf7ca1 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -484,7 +484,8 @@ void CanvasContext::draw() {
// TODO(b/165985262): measure performance impact
const auto vsyncId = mCurrentFrameInfo->get(FrameInfoIndex::FrameTimelineVsyncId);
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,
inputEventId);
}
@@ -591,7 +592,6 @@ void CanvasContext::draw() {
}
void CanvasContext::finishFrame(FrameInfo* frameInfo) {
-
// TODO (b/169858044): Consolidate this into a single call.
mJankTracker.finishFrame(*frameInfo);
mJankTracker.finishGpuDraw(*frameInfo);
diff --git a/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt b/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
index f919a3eaf271..c19e5cc34611 100644
--- a/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
+++ b/tests/Input/src/com/android/test/input/ViewFrameInfoTest.kt
@@ -62,15 +62,12 @@ class ViewFrameInfoTest {
fun testUpdateFrameInfoFromViewFrameInfo() {
val frameInfo = FrameInfo()
// By default, all values should be zero
- assertThat(frameInfo.frameInfo[FrameInfo.OLDEST_INPUT_EVENT]).isEqualTo(0)
- assertThat(frameInfo.frameInfo[FrameInfo.NEWEST_INPUT_EVENT]).isEqualTo(0)
+ // TODO(b/169866723): Use InputEventAssigner and assert INPUT_EVENT_ID
assertThat(frameInfo.frameInfo[FrameInfo.FLAGS]).isEqualTo(0)
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isEqualTo(0)
// The values inside FrameInfo should match those from ViewFrameInfo after we update them
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(
FrameInfo.FLAG_WINDOW_LAYOUT_CHANGED)
assertThat(frameInfo.frameInfo[FrameInfo.DRAW_START]).isGreaterThan(mTimeStarted)