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

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

Issue 2550803002: WebVR: avoid race conditions for partially-initialized display (Closed)
Patch Set: Created 4 years 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 e6515a2eda78795122935ded775a9c85d462cb79..c286f069f65efba7d5c194963e6b69a5bd3a168b 100644
--- a/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
+++ b/third_party/WebKit/Source/modules/vr/VRDisplay.cpp
@@ -75,6 +75,7 @@ VRDisplay::VRDisplay(NavigatorVR* navigatorVR,
: m_navigatorVR(navigatorVR),
m_isConnected(false),
m_isPresenting(false),
+ m_isValidDeviceForPresenting(true),
m_canUpdateFramePose(true),
m_capabilities(new VRDisplayCapabilities()),
m_eyeParametersLeft(new VREyeParameters()),
@@ -108,6 +109,13 @@ void VRDisplay::update(const device::mojom::blink::VRDisplayInfoPtr& display) {
m_capabilities->setCanPresent(display->capabilities->canPresent);
m_capabilities->setMaxLayers(display->capabilities->canPresent ? 1 : 0);
+ // Ignore non presenting delegate
+ bool isValid = display->leftEye->renderWidth > 0;
+ bool needOnPresentChange = false;
+ if (m_isPresenting && isValid && !m_isValidDeviceForPresenting) {
+ needOnPresentChange = true;
+ }
+ m_isValidDeviceForPresenting = isValid;
m_eyeParametersLeft->update(display->leftEye);
m_eyeParametersRight->update(display->rightEye);
@@ -118,6 +126,10 @@ void VRDisplay::update(const device::mojom::blink::VRDisplayInfoPtr& display) {
} else {
m_stageParameters = nullptr;
}
+
+ if (needOnPresentChange) {
+ OnPresentChange();
+ }
}
void VRDisplay::disconnected() {
@@ -496,10 +508,10 @@ void VRDisplay::forceExitPresent() {
} else {
// Can't get into this presentation mode, so nothing to do here.
}
+ m_isPresenting = false;
OnPresentChange();
}
- m_isPresenting = false;
m_renderingContext = nullptr;
m_contextGL = nullptr;
}
@@ -619,6 +631,10 @@ Document* VRDisplay::document() {
}
void VRDisplay::OnPresentChange() {
+ if (m_isPresenting && !m_isValidDeviceForPresenting) {
+ VLOG(1) << __FUNCTION__ << ": device not valid, not sending event";
+ return;
+ }
m_navigatorVR->enqueueVREvent(VRDisplayEvent::create(
EventTypeNames::vrdisplaypresentchange, true, false, this, ""));
}
« 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