summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2021-01-12 20:45:29 -1000
committer Siarhei Vishniakou <svv@google.com> 2021-01-29 18:41:08 +0000
commitd11f38f6c5b4c2f9f8cdbcb2a0871bd83415bb52 (patch)
tree2b6845f4274f3898cbf99d2ac50273c9ea2d8959
parentdd56fa93f65b38f47883e88300aacb53902b8857 (diff)
Send input event id to SurfaceFlinger
The application receives input events and produces graphic buffers in response. We are interested in measuring the total time that the input event takes to process, from the moment it's received on the device, to the moment that the image is displayed on the screen. To do this, we need to understand which input event produced a specific buffer. In this CL, we are sending the input event id from FrameInfo to SurfaceFlinger. This event id will later be used to identify a specific frame, and provide the frame timing information to inputflinger. Inputflinger will be able to use this information to reconstruct the complete event timeline, and record metrics on the duration of each input / graphics processing stage. This will allow us to optimize end-to-end touch latency. In the current CL, we are using 'NewestInputEvent' as the inputEventId. That's not quite correct. Today, this field contains the timestamp of the input event. Therefore, we will simply pass the truncated timestamp instead of proper input event id. We will fix this in a separate CL by providing input event id to FrameInfo. Design doc: https://docs.google.com/document/d/1G3bLaZYSmbe6AKcL-6ZChvrw_B_LXEz29Z6Ed9QoYXY/edit# Bug: 169866723 Test: printed input event id at the site of SurfaceFrame creation in FrameTimeline.cpp Change-Id: Ia90337bb2f000e9c93a4db04d9dd6ea9ea153520
-rw-r--r--PREUPLOAD.cfg1
-rw-r--r--core/jni/android_view_SurfaceControl.cpp4
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp8
3 files changed, 9 insertions, 4 deletions
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
index cdf5df6c6bd3..30ed7de92614 100644
--- a/PREUPLOAD.cfg
+++ b/PREUPLOAD.cfg
@@ -8,6 +8,7 @@ clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
cmds/input/
cmds/uinput/
core/jni/
+ libs/hwui/
libs/input/
native/
services/core/jni/
diff --git a/core/jni/android_view_SurfaceControl.cpp b/core/jni/android_view_SurfaceControl.cpp
index 4ef63ae93016..522e1422a4bb 100644
--- a/core/jni/android_view_SurfaceControl.cpp
+++ b/core/jni/android_view_SurfaceControl.cpp
@@ -27,6 +27,7 @@
#include <android-base/chrono_utils.h>
#include <android/graphics/region.h>
#include <android/gui/BnScreenCaptureListener.h>
+#include <android/os/IInputConstants.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
#include <android_runtime/android_view_Surface.h>
@@ -1619,7 +1620,8 @@ static void nativeSetFrameTimelineVsync(JNIEnv* env, jclass clazz, jlong transac
jlong frameTimelineVsyncId) {
auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
- transaction->setFrameTimelineVsync(frameTimelineVsyncId);
+ transaction->setFrameTimelineInfo(
+ {frameTimelineVsyncId, android::os::IInputConstants::INVALID_INPUT_EVENT_ID});
}
class JankDataListenerWrapper : public JankDataListener {
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index eacabfd1dbf9..633f21ceba07 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -490,9 +490,11 @@ void CanvasContext::draw() {
if (mNativeSurface) {
// TODO(b/165985262): measure performance impact
- if (const auto vsyncId = mCurrentFrameInfo->get(FrameInfoIndex::FrameTimelineVsyncId);
- vsyncId != UiFrameInfoBuilder::INVALID_VSYNC_ID) {
- native_window_set_frame_timeline_vsync(mNativeSurface->getNativeWindow(), vsyncId);
+ const auto vsyncId = mCurrentFrameInfo->get(FrameInfoIndex::FrameTimelineVsyncId);
+ if (vsyncId != UiFrameInfoBuilder::INVALID_VSYNC_ID) {
+ const auto inputEventId = mCurrentFrameInfo->get(FrameInfoIndex::NewestInputEvent);
+ native_window_set_frame_timeline_info(mNativeSurface->getNativeWindow(), vsyncId,
+ inputEventId);
}
}