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

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

Issue 2774673003: WebVR: process animations from posted task to yield for other events (Closed)
Patch Set: Merge fix: add missing include file 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 cc8f1038aae5d967f3865cc8b9a1881194dcb3d9..7c76114d50501e017583313962039ed7914c5333 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -27,6 +27,7 @@
#include "modules/webgl/WebGLRenderingContextBase.h"
#include "platform/Histogram.h"
#include "platform/UserGestureIndicator.h"
+#include "platform/instrumentation/tracing/TraceEvent.h"
#include "public/platform/Platform.h"
#include "wtf/AutoReset.h"
#include "wtf/Time.h"
@@ -676,6 +677,14 @@ void VRDisplay::OnDeactivate(
EventTypeNames::vrdisplaydeactivate, true, false, this, reason));
}
+void VRDisplay::processScheduledAnimations(double timestamp) {
+ TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", m_vrFrameId);
+
+ AutoReset<bool> animating(&m_inAnimationFrame, true);
+ m_pendingRaf = false;
+ m_scriptedAnimationController->serviceScriptedAnimations(timestamp);
+}
+
void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose,
mojo::common::mojom::blink::TimeDeltaPtr time,
int16_t frameId,
@@ -704,12 +713,21 @@ void VRDisplay::OnVSync(device::mojom::blink::VRPosePtr pose,
m_timebase = WTF::monotonicallyIncreasingTime() - timeDelta.InSecondsF();
}
- AutoReset<bool> animating(&m_inAnimationFrame, true);
m_framePose = std::move(pose);
m_vrFrameId = frameId;
- m_pendingRaf = false;
- m_scriptedAnimationController->serviceScriptedAnimations(
- m_timebase + timeDelta.InSecondsF());
+
+ // Post a task to handle scheduled animations after the current
+ // execution context finishes, so that we yield to non-mojo tasks in
+ // between frames. Executing mojo tasks back to back within the same
+ // execution context caused extreme input delay due to processing
+ // multiple frames without yielding, see crbug.com/701444. I suspect
+ // this is due to WaitForIncomingMethodCall receiving the OnVSync
+ // but queueing it for immediate execution since it doesn't match
+ // the interface being waited on.
+ Platform::current()->currentThread()->getWebTaskRunner()->postTask(
haraken 2017/03/24 01:16:06 The default task runner is going to be deprecated.
+ BLINK_FROM_HERE,
+ WTF::bind(&VRDisplay::processScheduledAnimations,
+ wrapWeakPersistent(this), m_timebase + timeDelta.InSecondsF()));
}
void VRDisplay::ConnectVSyncProvider() {
« 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