Bug 1415762 - Cancel VRListener task when CompositorVsyncScheduler is going to destroy; r=dvander
☠☠ backed out by d32ac3e582b6 ☠ ☠
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 09 Nov 2017 11:41:15 +0800
changeset 444493 f296220f41172e899e585354439d37877aada199
parent 444492 ead14db678204b84c56e6238f5069a93dfb0dadc
child 444494 40f071c58bf9fc1d6c3afcea0267d5f98ad523a6
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1415762
milestone58.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 1415762 - Cancel VRListener task when CompositorVsyncScheduler is going to destroy; r=dvander MozReview-Commit-ID: F25LE5Ru9gz
gfx/layers/ipc/CompositorVsyncScheduler.cpp
gfx/vr/VRThread.h
--- a/gfx/layers/ipc/CompositorVsyncScheduler.cpp
+++ b/gfx/layers/ipc/CompositorVsyncScheduler.cpp
@@ -128,16 +128,17 @@ CompositorVsyncScheduler::PostCompositeT
     RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
       "layers::CompositorVsyncScheduler::Composite",
       this,
       &CompositorVsyncScheduler::Composite,
       aCompositeTimestamp);
     mCurrentCompositeTask = task;
     ScheduleTask(task.forget(), 0);
   }
+  MonitorAutoLock lockVR(mCurrentVRListenerTaskMonitor);
   if (mCurrentVRListenerTask == nullptr && VRListenerThreadHolder::Loop()) {
     RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod<TimeStamp>(
       "layers::CompositorVsyncScheduler::DispatchVREvents",
       this,
       &CompositorVsyncScheduler::DispatchVREvents,
       aCompositeTimestamp);
     mCurrentVRListenerTask = task;
     MOZ_ASSERT(VRListenerThreadHolder::Loop());
@@ -235,16 +236,21 @@ void
 CompositorVsyncScheduler::CancelCurrentCompositeTask()
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread() || NS_IsMainThread());
   MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
   if (mCurrentCompositeTask) {
     mCurrentCompositeTask->Cancel();
     mCurrentCompositeTask = nullptr;
   }
+  MonitorAutoLock lockVR(mCurrentVRListenerTaskMonitor);
+  if (mCurrentVRListenerTask) {
+    mCurrentVRListenerTask->Cancel();
+    mCurrentVRListenerTask = nullptr;
+  }
 }
 
 void
 CompositorVsyncScheduler::Composite(TimeStamp aVsyncTimestamp)
 {
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   {
     MonitorAutoLock lock(mCurrentCompositeTaskMonitor);
--- a/gfx/vr/VRThread.h
+++ b/gfx/vr/VRThread.h
@@ -22,17 +22,17 @@ public:
 
   base::Thread* GetThread() const {
     return mThread;
   }
 
   static VRListenerThreadHolder* GetSingleton();
 
   static bool IsActive() {
-    return !!GetSingleton();
+    return GetSingleton() && Loop();
   }
 
   static void Start();
   static void Shutdown();
   static MessageLoop* Loop();
   static bool IsInVRListenerThread();
 
 private: