Commit 7746363d authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Update presentation time calculations.

As per the spec, the driver is expected to return a valid timestamp from
the call eglGetFrameTimestampsANDROID() when its not
EGL_TIMESTAMP_PENDING_ANDROID or EGL_TIMESTAMP_INVALID_ANDROID.
But currently few buggy drivers returns an invalid timestamp 0.

We fix/workaround this in chrome by returning the presentation time
as TimeTicks::Now() (snapped to the next vsync) instead of 0.

Bug: 966638
Change-Id: I5075dda0739f02029922ebbc20c09656fb0e87ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1631354Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: vikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663918}
parent 842fb667
......@@ -1477,6 +1477,15 @@ bool NativeViewGLSurfaceEGL::GetFrameTimestampInfoIfAvailable(
// reporting purpose.
std::vector<EGLnsecsANDROID> egl_timestamps(supported_egl_timestamps_.size(),
EGL_TIMESTAMP_INVALID_ANDROID);
// TODO(vikassoni): File a driver bug for eglGetFrameTimestampsANDROID().
// See https://bugs.chromium.org/p/chromium/issues/detail?id=966638.
// As per the spec, the driver is expected to return a valid timestamp from
// the call eglGetFrameTimestampsANDROID() when its not
// EGL_TIMESTAMP_PENDING_ANDROID or EGL_TIMESTAMP_INVALID_ANDROID. But
// currently some buggy drivers an invalid timestamp 0.
// This is currentlt handled in chrome for by setting the presentation time to
// TimeTicks::Now() (snapped to the next vsync) instead of 0.
if ((frame_id < 0) ||
!eglGetFrameTimestampsANDROID(
GetDisplay(), surface_, frame_id,
......@@ -1512,7 +1521,6 @@ bool NativeViewGLSurfaceEGL::GetFrameTimestampInfoIfAvailable(
base::TimeDelta::FromNanoseconds(presentation_time_ns);
*presentation_flags = presentation_flags_;
}
DCHECK(!presentation_time->is_null());
return true;
}
......
......@@ -70,8 +70,24 @@ bool GLSurfacePresentationHelper::GetFrameTimestampInfoIfAvailable(
DCHECK(frame.timer || frame.fence || egl_timestamp_client_);
if (egl_timestamp_client_) {
return egl_timestamp_client_->GetFrameTimestampInfoIfAvailable(
bool result = egl_timestamp_client_->GetFrameTimestampInfoIfAvailable(
timestamp, interval, flags, frame.frame_id);
// Workaround null timestamp by setting it to TimeTicks::Now() snapped to
// the next vsync interval. See
// https://bugs.chromium.org/p/chromium/issues/detail?id=966638 for more
// details.
if (result && timestamp->is_null()) {
*timestamp = base::TimeTicks::Now();
*interval = vsync_interval_;
*flags = 0;
if (!vsync_interval_.is_zero()) {
*timestamp =
timestamp->SnappedToNextTick(vsync_timebase_, vsync_interval_);
*flags = gfx::PresentationFeedback::kVSync;
}
}
return result;
} else if (frame.timer) {
if (!frame.timer->IsAvailable())
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment