Bug 1501869 - Part 1: Refine the mechanism for VR tasks. r=kip
☠☠ backed out by 279ffbe01845 ☠ ☠
authorDaosheng Mu <daoshengmu@gmail.com>
Fri, 26 Oct 2018 17:23:13 +0000
changeset 443199 cdb87cbfe882997bdcbd39d5380738a42aa07a27
parent 443198 2c6e366ebc6e9fc772f0128016e22d28c8e2dc4a
child 443200 56896b0e10d3a554e329de778247ff60265c96e3
push id34944
push userncsoregi@mozilla.com
push dateSat, 27 Oct 2018 09:49:55 +0000
treeherdermozilla-central@49d47a692ca4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskip
bugs1501869
milestone65.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 1501869 - Part 1: Refine the mechanism for VR tasks. r=kip Differential Revision: https://phabricator.services.mozilla.com/D9879
gfx/vr/VRManager.cpp
gfx/vr/VRManager.h
gfx/vr/service/OculusSession.cpp
gfx/vr/service/VRService.cpp
--- a/gfx/vr/VRManager.cpp
+++ b/gfx/vr/VRManager.cpp
@@ -161,17 +161,16 @@ VRManager::Shutdown()
   }
 #endif
   mVRServiceStarted = false;
 }
 
 void
 VRManager::Init()
 {
-  StartTasks();
   mInitialized = true;
 }
 
 /* static */VRManager*
 VRManager::Get()
 {
   MOZ_ASSERT(sVRManagerSingleton != nullptr);
 
@@ -442,16 +441,17 @@ VRManager::NotifyVRVsync(const uint32_t&
   }
 
   DispatchVRDisplayInfoUpdate();
 }
 
 void
 VRManager::EnumerateVRDisplays()
 {
+  StartTasks();
   /**
    * Throttle the rate of enumeration to the interval set in
    * VRDisplayEnumerateInterval
    */
   if (!mLastDisplayEnumerationTime.IsNull()) {
     TimeDuration duration = TimeStamp::Now() - mLastDisplayEnumerationTime;
     if (duration.ToMilliseconds() < gfxPrefs::VRDisplayEnumerateInterval()) {
       return;
--- a/gfx/vr/VRManager.h
+++ b/gfx/vr/VRManager.h
@@ -28,16 +28,17 @@ class VRDisplayHost;
 class VRService;
 #endif
 class VRSystemManagerPuppet;
 class VRSystemManagerExternal;
 
 class VRManager
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(mozilla::gfx::VRManager)
+  friend class VRManagerParent;
 
 public:
   static void ManagerInit();
   static VRManager* Get();
 
   void AddVRManagerParent(VRManagerParent* aVRManagerParent);
   void RemoveVRManagerParent(VRManagerParent* aVRManagerParent);
 
--- a/gfx/vr/service/OculusSession.cpp
+++ b/gfx/vr/service/OculusSession.cpp
@@ -231,26 +231,25 @@ OculusSession::OculusSession()
 OculusSession::~OculusSession()
 {
   Shutdown();
 }
 
 bool
 OculusSession::Initialize(mozilla::gfx::VRSystemState& aSystemState)
 {
+  if (!LoadOvrLib()) {
+    return false;
+  }
   if (!CreateD3DObjects()) {
     return false;
   }
   if (!CreateShaders()) {
     return false;
   }
-
-  if (!LoadOvrLib()) {
-    return false;
-  }
   // We start off with an invisible session, then re-initialize
   // with visible session once WebVR content starts rendering.
   if (!ChangeVisibility(false)) {
     return false;
   }
   if (!InitState(aSystemState)) {
     return false;
   }
--- a/gfx/vr/service/VRService.cpp
+++ b/gfx/vr/service/VRService.cpp
@@ -129,16 +129,17 @@ VRService::Start()
        acceptable goal for Compositor responsiveness (normal goal is 60Hz). */
     options.transient_hang_timeout = 128; // milliseconds
     /* 2048ms is chosen for permanent hangs because it's longer than most
      * Compositor hangs seen in the wild, but is short enough to not miss
      * getting native hang stacks. */
     options.permanent_hang_timeout = 2048; // milliseconds
 
     if (!mServiceThread->StartWithOptions(options)) {
+      mServiceThread->Stop();
       delete mServiceThread;
       mServiceThread = nullptr;
       return;
     }
 
     mServiceThread->message_loop()->PostTask(
       NewRunnableMethod("gfx::VRService::ServiceInitialize",
                         this,
@@ -146,16 +147,17 @@ VRService::Start()
   }
 }
 
 void
 VRService::Stop()
 {
   if (mServiceThread) {
     mShutdownRequested = true;
+    mServiceThread->Stop();
     delete mServiceThread;
     mServiceThread = nullptr;
   }
   if (mTargetShmemFile) {
 #if defined(XP_WIN)
     CloseHandle(mTargetShmemFile);
 #endif
     mTargetShmemFile = 0;