Bug 1516554 - Part 4: Fix Win 7 try fails when VR process enable but no GPU process. r=kip
authorDaosheng Mu <daoshengmu@gmail.com>
Fri, 11 Jan 2019 22:49:20 +0000
changeset 510941 bff1af3da43332085f4c862c9d8718c17c193e8d
parent 510940 625005dcd0b35eff30d350934c7b4bf6e2e248c9
child 510942 518dbd08c0d75abd6ab5e194c719bcf3179d487b
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1516554
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1516554 - Part 4: Fix Win 7 try fails when VR process enable but no GPU process. r=kip Differential Revision: https://phabricator.services.mozilla.com/D16258
gfx/vr/VRManager.cpp
--- a/gfx/vr/VRManager.cpp
+++ b/gfx/vr/VRManager.cpp
@@ -73,17 +73,17 @@ VRManager::VRManager()
   MOZ_COUNT_CTOR(VRManager);
   MOZ_ASSERT(sVRManagerSingleton == nullptr);
 
   RefPtr<VRSystemManager> mgr;
 
 #if !defined(MOZ_WIDGET_ANDROID)
   // The VR Service accesses all hardware from a separate process
   // and replaces the other VRSystemManager when enabled.
-  if (!gfxPrefs::VRProcessEnabled()) {
+  if (!gfxPrefs::VRProcessEnabled() || !XRE_IsGPUProcess()) {
     VRServiceManager::Get().CreateService();
   }
   if (VRServiceManager::Get().IsServiceValid()) {
     mExternalManager =
         VRSystemManagerExternal::Create(VRServiceManager::Get().GetAPIShmem());
   }
   if (mExternalManager) {
     mManagers.AppendElement(mExternalManager);
@@ -122,30 +122,33 @@ void VRManager::Destroy() {
   for (uint32_t i = 0; i < mManagers.Length(); ++i) {
     mManagers[i]->Destroy();
   }
 #if !defined(MOZ_WIDGET_ANDROID)
   if (VRServiceManager::Get().IsServiceValid()) {
     VRServiceManager::Get().Shutdown();
   }
 #endif
+  Shutdown();
   mInitialized = false;
 }
 
 void VRManager::Shutdown() {
   mVRDisplays.Clear();
   mVRControllers.Clear();
   for (uint32_t i = 0; i < mManagers.Length(); ++i) {
     mManagers[i]->Shutdown();
   }
 #if !defined(MOZ_WIDGET_ANDROID)
   if (VRServiceManager::Get().IsServiceValid()) {
     VRServiceManager::Get().Stop();
   }
-  if (gfxPrefs::VRProcessEnabled() && mVRServiceStarted) {
+  // XRE_IsGPUProcess() is helping us to check some platforms like
+  // Win 7 try which are not using GPU process but VR process is enabled.
+  if (XRE_IsGPUProcess() && gfxPrefs::VRProcessEnabled() && mVRServiceStarted) {
     RefPtr<Runnable> task = NS_NewRunnableFunction(
         "VRServiceManager::ShutdownVRProcess",
         []() -> void { VRServiceManager::Get().ShutdownVRProcess(); });
     NS_DispatchToMainThread(task.forget());
   }
 #endif
   mVRServiceStarted = false;
 }
@@ -430,23 +433,25 @@ void VRManager::EnumerateVRDisplays() {
    * and VR Process before enumeration.
    * We don't want to start this until we will
    * actualy enumerate, to avoid continuously
    * re-launching the thread/process when
    * no hardware is found or a VR software update
    * is in progress
    */
 #if !defined(MOZ_WIDGET_ANDROID)
-  if (gfxPrefs::VRProcessEnabled() && !mVRServiceStarted) {
-    VRServiceManager::Get().CreateVRProcess();
-    mVRServiceStarted = true;
-  } else if (!gfxPrefs::VRProcessEnabled()) {
-    if (VRServiceManager::Get().IsServiceValid()) {
-      VRServiceManager::Get().Start();
+  if (!mVRServiceStarted) {
+    if (XRE_IsGPUProcess() && gfxPrefs::VRProcessEnabled()) {
+      VRServiceManager::Get().CreateVRProcess();
       mVRServiceStarted = true;
+    } else {
+      if (VRServiceManager::Get().IsServiceValid()) {
+        VRServiceManager::Get().Start();
+        mVRServiceStarted = true;
+      }
     }
   }
 #endif
 
   /**
    * VRSystemManagers are inserted into mManagers in
    * a strict order of priority.  The managers for the
    * most device-specialized API's will have a chance