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

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: Throw shade at WaitForIncomingMethodCall in comment. 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..e6f35dc0b44df24035cbcc389ec7b77499399c8f 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -689,6 +689,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,
@@ -711,12 +719,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(
billorr 2017/03/15 18:35:45 Does this measurably have a negative effect on lat
klausw 2017/03/15 19:00:17 I don't think so, if I understand it right it's ju
+ 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