Set the vr hwc vsync rate to match the native vsync
This simple modification reduces the motopho latency from 85ms to 65ms.
However, this is not a final solution, and we should continue to look
for how to address the issue of difference in vsync reporting.
Bug: 36493906
Test: Run motopho, latency is now much lower.
Change-Id: Id52689900a5fe58dfc9d7790b7c3746903380972
diff --git a/services/vr/hardware_composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
index 565e5d3..9bbb7f3 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -336,7 +336,19 @@
*outValue = display_ptr->height();
break;
case IComposerClient::Attribute::VSYNC_PERIOD:
- *outValue = 1000 * 1000 * 1000 / 30; // 30fps
+ {
+ int error = 0;
+ auto display_client = display::DisplayClient::Create(&error);
+ if (!display_client) {
+ ALOGE("Could not connect to display service : %s(%d)",
+ strerror(error), error);
+ // Return a default value of 30 fps
+ *outValue = 1000 * 1000 * 1000 / 30;
+ } else {
+ auto metrics = display_client->GetDisplayMetrics();
+ *outValue = metrics.get().vsync_period_ns;
+ }
+ }
break;
case IComposerClient::Attribute::DPI_X:
case IComposerClient::Attribute::DPI_Y: