Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: third_party/WebKit/Source/modules/vr/VRDisplay.cpp

Issue 2748293002: WebVR: process animations from posted task to yield for other events (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/vr/VRDisplay.cpp
diff --git a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
index 4fa6fa737b48b1bcd283427ec31cc2e29c010de0..9e7cf6bb540a00d4fe9b2143f4f3ee3886e2cd62 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -151,6 +151,14 @@ VREyeParameters* VRDisplay::getEyeParameters(const String& whichEye) {
}
}
+void VRDisplay::doGetVSync() {
+ if (!m_displayBlurred && !m_pendingVsync) {
+ m_pendingVsync = true;
+ m_vrVSyncProvider->GetVSync(convertToBaseCallback(
+ WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this))));
+ }
+}
+
int VRDisplay::requestAnimationFrame(FrameRequestCallback* callback) {
Document* doc = this->document();
if (!doc)
@@ -159,9 +167,15 @@ int VRDisplay::requestAnimationFrame(FrameRequestCallback* callback) {
if (!m_vrVSyncProvider.is_bound()) {
ConnectVSyncProvider();
} else if (!m_displayBlurred && !m_pendingVsync) {
- m_pendingVsync = true;
- m_vrVSyncProvider->GetVSync(convertToBaseCallback(
- WTF::bind(&VRDisplay::OnVSync, wrapWeakPersistent(this))));
+ // Schedule a task to fetch a new VSync after the current
+ // execution context finishes. If we call GetVSync inline here, we
+ // can end up with the next VSync already being ready and
+ // scheduled when we exit, and then we'll process several frames
+ // in a row without ever yielding back to the main event loop,
+ // causing extreme input delay. See crbug.com/701444.
+ Platform::current()->currentThread()->getWebTaskRunner()->postTask(
mthiesse 2017/03/15 15:17:35 Two comments: 1. This shouldn't be necessary, this
klausw 2017/03/15 15:42:39 Yes, this was unexpected. It's not just starving I
klausw 2017/03/15 15:50:59 To clarify, I think that executing the next GetVSy
klausw 2017/03/15 17:39:25 The deferred serviceScriptedAnimations works, goin
+ BLINK_FROM_HERE,
+ WTF::bind(&VRDisplay::doGetVSync, wrapWeakPersistent(this)));
}
callback->m_useLegacyTimeBase = false;
return ensureScriptedAnimationController(doc).registerCallback(callback);
@@ -715,6 +729,8 @@ void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose,
m_framePose = std::move(pose);
m_vrFrameId = frameId;
m_pendingRaf = false;
+ TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", frameId);
+
m_scriptedAnimationController->serviceScriptedAnimations(
m_timebase + timeDelta.InSecondsF());
}
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRDisplay.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698