Bug 1389220 - Prevent navigator.activeVRDisplays from activating VR hardware and runtimes
MozReview-Commit-ID: JYMiGyT0iVY
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1488,24 +1488,29 @@ Navigator::GetVRDisplays(ErrorResult& aR
return p.forget();
}
void
Navigator::GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const
{
/**
* Get only the active VR displays.
- * Callers do not wish to VRDisplay::RefreshVRDisplays, as the enumeration may
- * activate hardware that is not yet intended to be used.
+ * GetActiveVRDisplays should only enumerate displays that
+ * are already active without causing any other hardware to be
+ * activated.
+ * We must not call nsGlobalWindow::NotifyVREventListenerAdded here,
+ * as that would cause enumeration and activation of other VR hardware.
+ * Activating VR hardware is intrusive to the end user, as it may
+ * involve physically powering on devices that the user did not
+ * intend to use.
*/
if (!mWindow || !mWindow->GetDocShell()) {
return;
}
nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
- win->NotifyVREventListenerAdded();
nsTArray<RefPtr<VRDisplay>> displays;
if (win->UpdateVRDisplays(displays)) {
for (auto display : displays) {
if (display->IsPresenting()) {
aDisplays.AppendElement(display);
}
}
}