Bug 1454594 - Follow-up to clear the static pointers on shutdown. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 24 Apr 2018 12:42:37 -0400
changeset 471473 77865327ee5700d7e5b688f0cbf1c95362b2ef17
parent 471472 ad0bde59038e823ec2dd44313473173ed482c8dc
child 471474 483a0ccebc285df70c11799d20269859a6a46593
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1454594
milestone61.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 1454594 - Follow-up to clear the static pointers on shutdown. r=botond MozReview-Commit-ID: 5NVaBGIzbMR
gfx/layers/apz/src/APZSampler.cpp
gfx/layers/apz/src/APZUpdater.cpp
--- a/gfx/layers/apz/src/APZSampler.cpp
+++ b/gfx/layers/apz/src/APZSampler.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/APZSampler.h"
 
 #include "APZCTreeManager.h"
 #include "AsyncPanZoomController.h"
+#include "mozilla/ClearOnShutdown.h"
 #include "mozilla/layers/APZThreadUtils.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/LayerMetricsWrapper.h"
 #include "mozilla/layers/SynchronousTask.h"
 #include "TreeTraversal.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 
 namespace mozilla {
@@ -47,16 +48,21 @@ APZSampler::~APZSampler()
 void
 APZSampler::SetWebRenderWindowId(const wr::WindowId& aWindowId)
 {
   StaticMutexAutoLock lock(sWindowIdLock);
   MOZ_ASSERT(!mWindowId);
   mWindowId = Some(aWindowId);
   if (!sWindowIdMap) {
     sWindowIdMap = new std::unordered_map<uint64_t, APZSampler*>();
+    NS_DispatchToMainThread(
+      NS_NewRunnableFunction("APZUpdater::ClearOnShutdown", [] {
+        ClearOnShutdown(&sWindowIdMap);
+      }
+    ));
   }
   (*sWindowIdMap)[wr::AsUint64(aWindowId)] = this;
 }
 
 /*static*/ void
 APZSampler::SetSamplerThread(const wr::WrWindowId& aWindowId)
 {
   if (RefPtr<APZSampler> sampler = GetSampler(aWindowId)) {
--- a/gfx/layers/apz/src/APZUpdater.cpp
+++ b/gfx/layers/apz/src/APZUpdater.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/APZUpdater.h"
 
 #include "APZCTreeManager.h"
 #include "AsyncPanZoomController.h"
 #include "base/task.h"
+#include "mozilla/ClearOnShutdown.h"
 #include "mozilla/layers/APZThreadUtils.h"
 #include "mozilla/layers/CompositorThread.h"
 #include "mozilla/layers/SynchronousTask.h"
 #include "mozilla/layers/WebRenderScrollDataWrapper.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 
 namespace mozilla {
 namespace layers {
@@ -54,16 +55,21 @@ APZUpdater::HasTreeManager(const RefPtr<
 void
 APZUpdater::SetWebRenderWindowId(const wr::WindowId& aWindowId)
 {
   StaticMutexAutoLock lock(sWindowIdLock);
   MOZ_ASSERT(!mWindowId);
   mWindowId = Some(aWindowId);
   if (!sWindowIdMap) {
     sWindowIdMap = new std::unordered_map<uint64_t, APZUpdater*>();
+    NS_DispatchToMainThread(
+      NS_NewRunnableFunction("APZUpdater::ClearOnShutdown", [] {
+        ClearOnShutdown(&sWindowIdMap);
+      }
+    ));
   }
   (*sWindowIdMap)[wr::AsUint64(aWindowId)] = this;
 }
 
 /*static*/ void
 APZUpdater::SetUpdaterThread(const wr::WrWindowId& aWindowId)
 {
   if (RefPtr<APZUpdater> updater = GetUpdater(aWindowId)) {