Bug 1479912 - Clear WebRender resources asynchronously. r=sotaro
authorNicolas Silva <nsilva@mozilla.com>
Fri, 12 Oct 2018 06:47:29 +0000
changeset 499325 59b46598511704177bebd3e82504908655ebe5f1
parent 499324 bb8d7ab5e55fea5d8a962b59364d35eb955d8d94
child 499326 5b5ed02f86c785f0b78999f8ca94baf057eaf799
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1479912
milestone64.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 1479912 - Clear WebRender resources asynchronously. r=sotaro Differential Revision: https://phabricator.services.mozilla.com/D7280
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.cpp
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -518,20 +518,29 @@ CompositorBridgeParent::StopAndClearReso
         lts->mParent = nullptr;
       });
     }
     for (const RefPtr<WebRenderBridgeParent>& bridge : indirectBridgeParents) {
       bridge->Destroy();
     }
     indirectBridgeParents.clear();
 
+    RefPtr<wr::WebRenderAPI> api = mWrBridge->GetWebRenderAPI();
     // Ensure we are not holding the sIndirectLayerTreesLock here because we
     // are going to block on WR threads in order to shut it down properly.
     mWrBridge->Destroy();
     mWrBridge = nullptr;
+
+    if (api) {
+      // Make extra sure we are done cleaning WebRender up before continuing.
+      // After that we wont have a way to talk to a lot of the webrender parts.
+      api->FlushSceneBuilder();
+      api = nullptr;
+    }
+
     if (mAsyncImageManager) {
       mAsyncImageManager->Destroy();
       // WebRenderAPI should be already destructed
       mAsyncImageManager = nullptr;
     }
   }
 
   if (mCompositor) {
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -1841,23 +1841,16 @@ WebRenderBridgeParent::ClearResources()
   }
   mActiveAnimations.clear();
   std::queue<CompositorAnimationIdsForEpoch>().swap(mCompositorAnimationsToDelete); // clear queue
 
   if (IsRootWebRenderBridgeParent()) {
     mCompositorScheduler->Destroy();
   }
 
-  // Before tearing down mApi we should make sure the above transaction has been
-  // flushed back to the render backend thread. Otherwise the cleanup messages
-  // that the WebRenderAPI destructor triggers can race ahead of the transaction
-  // (because it goes directly to the RB thread, bypassing the scene builder
-  // thread) and clear caches etc. that are still in use.
-  FlushSceneBuilds();
-
   mAnimStorage = nullptr;
   mCompositorScheduler = nullptr;
   mAsyncImageManager = nullptr;
   mApi = nullptr;
   mCompositorBridge = nullptr;
 }
 
 bool