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

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

Issue 2926953002: Fix WebVR so we don't animation when stopped at a JS breakpoint (Closed)
Patch Set: Created 3 years, 6 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
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 ace724eec6f9ca1ef506f130936aee361715a9f3..fd94a9c7851f776217acf3ed07c0e7292a9cfba6 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -55,17 +55,30 @@ VREye StringToVREye(const String& which_eye) {
VRDisplay::VRDisplay(NavigatorVR* navigator_vr,
device::mojom::blink::VRDisplayPtr display,
device::mojom::blink::VRDisplayClientRequest request)
- : ContextLifecycleObserver(navigator_vr->GetDocument()),
+ : SuspendableObject(navigator_vr->GetDocument()),
navigator_vr_(navigator_vr),
capabilities_(new VRDisplayCapabilities()),
eye_parameters_left_(new VREyeParameters()),
eye_parameters_right_(new VREyeParameters()),
display_(std::move(display)),
submit_frame_client_binding_(this),
- display_client_binding_(this, std::move(request)) {}
+ display_client_binding_(this, std::move(request)) {
+ SuspendIfNeeded(); // Initialize suspended_.
+}
VRDisplay::~VRDisplay() {}
+void VRDisplay::Suspend() {
+ suspended_ = true;
+}
+
+void VRDisplay::Resume() {
+ suspended_ = false;
+ if (request_vsync_on_resume_) {
mthiesse 2017/06/08 03:26:30 No need for this boolean. RequestVSync() is always
billorr 2017/06/08 04:20:21 Done.
+ RequestVSync();
+ }
+}
+
VRController* VRDisplay::Controller() {
return navigator_vr_->Controller();
}
@@ -801,6 +814,13 @@ void VRDisplay::ProcessScheduledAnimations(double timestamp) {
return;
}
+ if (suspended_) {
+ // We are currently suspended - try ProcessScheduledAnimations again later
+ // when we resume.
+ request_vsync_on_resume_ = true;
+ return;
+ }
+
TRACE_EVENT1("gpu", "VRDisplay::OnVSync", "frame", vr_frame_id_);
if (pending_vrdisplay_raf_ && scripted_animation_controller_) {
@@ -910,7 +930,8 @@ const AtomicString& VRDisplay::InterfaceName() const {
return EventTargetNames::VRDisplay;
}
-void VRDisplay::ContextDestroyed(ExecutionContext*) {
+void VRDisplay::ContextDestroyed(ExecutionContext* context) {
+ SuspendableObject::ContextDestroyed(context);
ForceExitPresent();
scripted_animation_controller_.Clear();
}

Powered by Google App Engine
This is Rietveld 408576698