Merge "Add presentTime to FrameInfo" into sc-dev

This commit is contained in:
Siarhei Vishniakou
2021-02-24 20:38:17 +00:00
committed by Android (Google) Code Review
9 changed files with 45 additions and 46 deletions

View File

@@ -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

View File

@@ -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;
}
/**

View File

@@ -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 */

View File

@@ -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,

View File

@@ -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 {

View File

@@ -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++) {

View File

@@ -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();

View File

@@ -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);

View File

@@ -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)