diff options
author | Ady Abraham <adyabr@google.com> | 2021-06-23 15:03:48 -0700 |
---|---|---|
committer | Ady Abraham <adyabr@google.com> | 2021-06-23 15:04:04 -0700 |
commit | 505e730e7d67f7a068ce5b3d2384643d0e04a282 (patch) | |
tree | 7df0aff120ba97a75377cb1d51cba1ff9f9bcc48 /libs/hwui/renderthread/TimeLord.cpp | |
parent | 343684b523b26ba6be76c496fbca853ea569dff5 (diff) |
vsyncId should always be incremental
In some conditions of scheduling delays, Choreographer may
synthetically advance the indented vsync time. In that case we can't
send a vsync id since there is no one that corresponds to that time.
Test: TBD
Bug: 191840734
Change-Id: I7b2754d5dcb0a3f5fd6cda00a3a2469041116f67
Diffstat (limited to 'libs/hwui/renderthread/TimeLord.cpp')
-rw-r--r-- | libs/hwui/renderthread/TimeLord.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libs/hwui/renderthread/TimeLord.cpp b/libs/hwui/renderthread/TimeLord.cpp index 406066c92bab..a43fcdc6e202 100644 --- a/libs/hwui/renderthread/TimeLord.cpp +++ b/libs/hwui/renderthread/TimeLord.cpp @@ -15,22 +15,28 @@ */ #include "TimeLord.h" #include <limits> +#include "FrameInfo.h" namespace android { namespace uirenderer { namespace renderthread { -TimeLord::TimeLord() : mFrameIntervalNanos(milliseconds_to_nanoseconds(16)), - mFrameTimeNanos(0), - mFrameIntendedTimeNanos(0), - mFrameVsyncId(-1), - mFrameDeadline(std::numeric_limits<int64_t>::max()){} +TimeLord::TimeLord() + : mFrameIntervalNanos(milliseconds_to_nanoseconds(16)) + , mFrameTimeNanos(0) + , mFrameIntendedTimeNanos(0) + , mFrameVsyncId(UiFrameInfoBuilder::INVALID_VSYNC_ID) + , mFrameDeadline(std::numeric_limits<int64_t>::max()) {} bool TimeLord::vsyncReceived(nsecs_t vsync, nsecs_t intendedVsync, int64_t vsyncId, int64_t frameDeadline, nsecs_t frameInterval) { if (intendedVsync > mFrameIntendedTimeNanos) { mFrameIntendedTimeNanos = intendedVsync; - mFrameVsyncId = vsyncId; + + // The intendedVsync might have been advanced to account for scheduling + // jitter. Since we don't have a way to advance the vsync id we just + // reset it. + mFrameVsyncId = (vsyncId > mFrameVsyncId) ? vsyncId : UiFrameInfoBuilder::INVALID_VSYNC_ID; mFrameDeadline = frameDeadline; if (frameInterval > 0) { mFrameIntervalNanos = frameInterval; |