Chromium Code Reviews| 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() { |