Bug 1389220 - Prevent navigator.activeVRDisplays from activating VR hardware and runtimes draft
authorKearwood "Kip" Gilbert <kgilbert@mozilla.com>
Wed, 20 Sep 2017 15:39:35 -0700
changeset 667955 9e2d7b6815849330a3e25b36c070fbef5e6ce450
parent 667790 469eb992a9d166004f2601ce725786f671219054
child 732554 32185a514446464c49d2d193942b0ef114cdacb4
push id80891
push userkgilbert@mozilla.com
push dateWed, 20 Sep 2017 22:55:26 +0000
bugs1389220
milestone57.0a1
Bug 1389220 - Prevent navigator.activeVRDisplays from activating VR hardware and runtimes MozReview-Commit-ID: JYMiGyT0iVY
dom/base/Navigator.cpp
--- 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);
       }
     }
   }