Bug 1402749 - Part 2: Only allow updating VR controller amount at Vsync time; r=kip
authordmu@mozilla.com <dmu@mozilla.com>
Fri, 29 Sep 2017 06:53:27 +0000
changeset 426530 f1f664402e0f9f128924d21e2844b5331a370f06
parent 426529 f1043664d830166400076a8d2887e92d4e40c681
child 426531 edb79608b20bdbe4059c803436af85929164dc45
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewerskip
bugs1402749
milestone58.0a1
Bug 1402749 - Part 2: Only allow updating VR controller amount at Vsync time; r=kip MozReview-Commit-ID: EwXpyGnTYTD
dom/vr/test/mochitest/mochitest.ini
dom/vr/test/reftest/reftest.list
gfx/vr/ipc/VRManagerParent.cpp
--- a/dom/vr/test/mochitest/mochitest.ini
+++ b/dom/vr/test/mochitest/mochitest.ini
@@ -1,8 +1,9 @@
+# Please confirm there is no other VR display connected. Otherwise, VRPuppetDisplay can't be attached.
 [DEFAULT]
 support-files =
   VRSimulationDriver.js
   requestPresent.js
   runVRTest.js
   WebVRHelpers.js
 
 [test_vrController_displayId.html]
--- a/dom/vr/test/reftest/reftest.list
+++ b/dom/vr/test/reftest/reftest.list
@@ -1,9 +1,10 @@
 # WebVR Reftests
+# Please confirm there is no other VR display connected. Otherwise, VRPuppetDisplay can't be attached.
 default-preferences pref(dom.vr.puppet.enabled,true) pref(dom.vr.test.enabled,true) pref(dom.vr.require-gesture,false) pref(dom.vr.puppet.submitframe,1)
 
 # VR SubmitFrame is only implemented for D3D11.1 and MacOSX now.
 # Our Windows 7 test machines don't support D3D11.1, so we run these tests on Windows 8+ only.
 # We need to continue to investigate why these reftests can be run well in local,
 # but will be suspended until terminating on reftest D3D11 debug build.
 skip-if((!winWidget&&release_or_beta)||Android||gtkWidget||(winWidget&&isDebugBuild)||!layersGPUAccelerated||/^Windows\x20NT\x206\.1/.test(http.oscpu)) == draw_rect.html wrapper.html?draw_rect.png
 # On MacOSX platform, getting different color interpolation result.
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -274,28 +274,29 @@ VRManagerParent::RecvSetHaveEventListene
 {
   mHaveEventListener = aHaveEventListener;
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 VRManagerParent::RecvControllerListenerAdded()
 {
+  // Force update the available controllers for GamepadManager,
+  // remove the existing controllers and sync them by NotifyVsync().
   VRManager* vm = VRManager::Get();
+  vm->RemoveControllers();
   mHaveControllerListener = true;
-  // Ask the connected gamepads to be added to GamepadManager
-  vm->ScanForControllers();
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 VRManagerParent::RecvControllerListenerRemoved()
 {
+  mHaveControllerListener = false;
   VRManager* vm = VRManager::Get();
-  mHaveControllerListener = false;
   vm->RemoveControllers();
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 VRManagerParent::RecvCreateVRTestSystem()
 {
   VRManager* vm = VRManager::Get();