Bug 1393031 - Stop tracking active resource keys on the parent side. r=sotaro
authorNicolas Silva <nsilva@mozilla.com>
Mon, 04 Sep 2017 13:59:21 +0200
changeset 378850 cf18746c20ea99f41fd12e467ad5f4d81d06451a
parent 378849 684dd3236401702bac2c609066191b85e7368646
child 378851 44463d7234864ab61c9f6eb6605220d4f6e8c775
push id32443
push userarchaeopteryx@coole-files.de
push dateTue, 05 Sep 2017 09:41:20 +0000
treeherdermozilla-central@3ecda4678c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssotaro
bugs1393031
milestone57.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 1393031 - Stop tracking active resource keys on the parent side. r=sotaro
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/layers/wr/WebRenderBridgeParent.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -233,20 +233,18 @@ WebRenderBridgeParent::RecvAddImage(cons
   }
 
   // Check if key is obsoleted.
   if (aImageKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
   MOZ_ASSERT(mApi);
-  MOZ_ASSERT(mActiveImageKeys.find(wr::AsUint64(aImageKey)) == mActiveImageKeys.end());
 
   wr::ImageDescriptor descriptor(aSize, aStride, aFormat);
-  mActiveImageKeys.insert(wr::AsUint64(aImageKey));
   mApi->Resources().AddImage(aImageKey, descriptor, aBuffer.AsSlice());
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvAddBlobImage(const wr::ImageKey& aImageKey,
                                         const gfx::IntSize& aSize,
@@ -259,20 +257,18 @@ WebRenderBridgeParent::RecvAddBlobImage(
   }
 
   // Check if key is obsoleted.
   if (aImageKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
   MOZ_ASSERT(mApi);
-  MOZ_ASSERT(mActiveImageKeys.find(wr::AsUint64(aImageKey)) == mActiveImageKeys.end());
 
   wr::ImageDescriptor descriptor(aSize, aStride, aFormat);
-  mActiveImageKeys.insert(wr::AsUint64(aImageKey));
   mApi->Resources().AddBlobImage(aImageKey, descriptor, aBuffer.AsSlice());
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvAddRawFont(const wr::FontKey& aFontKey,
                                       const ByteBuffer& aBuffer,
@@ -283,20 +279,18 @@ WebRenderBridgeParent::RecvAddRawFont(co
   }
 
   // Check if key is obsoleted.
   if (aFontKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
   MOZ_ASSERT(mApi);
-  MOZ_ASSERT(mFontKeys.find(wr::AsUint64(aFontKey)) == mFontKeys.end());
 
   auto slice = aBuffer.AsSlice();
-  mFontKeys.insert(wr::AsUint64(aFontKey));
   mApi->Resources().AddRawFont(aFontKey, slice, aFontIndex);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvDeleteFont(const wr::FontKey& aFontKey)
 {
@@ -305,21 +299,17 @@ WebRenderBridgeParent::RecvDeleteFont(co
   }
   MOZ_ASSERT(mApi);
 
   // Check if key is obsoleted.
   if (aFontKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
-  if (mFontKeys.erase(wr::AsUint64(aFontKey)) > 0) {
-    mApi->Resources().DeleteFont(aFontKey);
-  } else {
-    MOZ_ASSERT_UNREACHABLE("invalid FontKey");
-  }
+  mApi->Resources().DeleteFont(aFontKey);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvAddFontInstance(const wr::FontInstanceKey& aInstanceKey,
                                            const wr::FontKey& aFontKey,
                                            const float& aGlyphSize,
@@ -331,19 +321,16 @@ WebRenderBridgeParent::RecvAddFontInstan
   }
 
   // Check if key is obsoleted.
   if (aInstanceKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
   MOZ_ASSERT(mApi);
-  MOZ_ASSERT(mFontInstanceKeys.find(wr::AsUint64(aInstanceKey)) == mFontInstanceKeys.end());
-
-  mFontInstanceKeys.insert(wr::AsUint64(aInstanceKey));
   mApi->Resources().AddFontInstance(aInstanceKey, aFontKey, aGlyphSize,
                                     aOptions.ptrOr(nullptr), aPlatformOptions.ptrOr(nullptr));
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvDeleteFontInstance(const wr::FontInstanceKey& aInstanceKey)
@@ -353,21 +340,17 @@ WebRenderBridgeParent::RecvDeleteFontIns
   }
   MOZ_ASSERT(mApi);
 
   // Check if key is obsoleted.
   if (aInstanceKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
-  if (mFontInstanceKeys.erase(wr::AsUint64(aInstanceKey)) > 0) {
-    mApi->Resources().DeleteFontInstance(aInstanceKey);
-  } else {
-    MOZ_ASSERT_UNREACHABLE("invalid FontInstanceKey");
-  }
+  mApi->Resources().DeleteFontInstance(aInstanceKey);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvUpdateImage(const wr::ImageKey& aImageKey,
                                        const gfx::IntSize& aSize,
                                        const gfx::SurfaceFormat& aFormat,
@@ -397,21 +380,18 @@ WebRenderBridgeParent::RecvDeleteImage(c
   }
   MOZ_ASSERT(mApi);
 
   // Check if key is obsoleted.
   if (aImageKey.mNamespace != mIdNamespace) {
     return IPC_OK();
   }
 
-  if (mActiveImageKeys.erase(wr::AsUint64(aImageKey)) > 0) {
-    mKeysToDelete.push_back(aImageKey);
-  } else {
-    MOZ_ASSERT_UNREACHABLE("invalid ImageKey");
-  }
+  mKeysToDelete.push_back(aImageKey);
+
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 WebRenderBridgeParent::RecvDeleteCompositorAnimations(InfallibleTArray<uint64_t>&& aIds)
 {
   if (mDestroyed) {
     return IPC_OK();
@@ -618,18 +598,16 @@ WebRenderBridgeParent::ProcessWebRenderP
       case WebRenderParentCommand::TOpAddExternalImage: {
         const OpAddExternalImage& op = cmd.get_OpAddExternalImage();
         Range<const wr::ImageKey> keys(&op.key(), 1);
         // Check if key is obsoleted.
         if (keys[0].mNamespace != mIdNamespace) {
           break;
         }
         MOZ_ASSERT(mExternalImageIds.Get(wr::AsUint64(op.externalImageId())).get());
-        MOZ_ASSERT(mActiveImageKeys.find(wr::AsUint64(keys[0])) == mActiveImageKeys.end());
-        mActiveImageKeys.insert(wr::AsUint64(keys[0]));
 
         RefPtr<WebRenderImageHost> host = mExternalImageIds.Get(wr::AsUint64(op.externalImageId()));
         if (!host) {
           NS_ERROR("CompositableHost does not exist");
           break;
         }
         if (!gfxEnv::EnableWebRenderRecording()) {
           TextureHost* texture = host->GetAsTextureHostForComposite();
@@ -1346,19 +1324,16 @@ WebRenderBridgeParent::ClearResources()
     return;
   }
 
   uint32_t wrEpoch = GetNextWrEpoch();
   mApi->ClearDisplayList(wr::NewEpoch(wrEpoch), mPipelineId);
   // Schedule composition to clean up Pipeline
   mCompositorScheduler->ScheduleComposition();
   // WrFontKeys and WrImageKeys are deleted during WebRenderAPI destruction.
-  mFontInstanceKeys.clear();
-  mFontKeys.clear();
-  mActiveImageKeys.clear();
   mKeysToDelete.clear();
   for (auto iter = mExternalImageIds.Iter(); !iter.Done(); iter.Next()) {
     iter.Data()->ClearWrBridge();
   }
   mExternalImageIds.Clear();
   for (auto iter = mAsyncCompositables.Iter(); !iter.Done(); iter.Next()) {
     wr::PipelineId pipelineId = wr::AsPipelineId(iter.Key());
     RefPtr<WebRenderImageHost> host = iter.Data();
--- a/gfx/layers/wr/WebRenderBridgeParent.h
+++ b/gfx/layers/wr/WebRenderBridgeParent.h
@@ -269,21 +269,16 @@ private:
   CompositorBridgeParentBase* MOZ_NON_OWNING_REF mCompositorBridge;
   wr::PipelineId mPipelineId;
   RefPtr<widget::CompositorWidget> mWidget;
   RefPtr<wr::WebRenderAPI> mApi;
   RefPtr<AsyncImagePipelineManager> mAsyncImageManager;
   RefPtr<CompositorVsyncScheduler> mCompositorScheduler;
   RefPtr<CompositorAnimationStorage> mAnimStorage;
   std::vector<wr::ImageKey> mKeysToDelete;
-  // mActiveImageKeys and mFontKeys are used to avoid leaking animations when
-  // WebRenderBridgeParent is destroyed abnormally and Tab move between different windows.
-  std::unordered_set<uint64_t> mActiveImageKeys;
-  std::unordered_set<uint64_t> mFontKeys;
-  std::unordered_set<uint64_t> mFontInstanceKeys;
   // mActiveAnimations is used to avoid leaking animations when WebRenderBridgeParent is
   // destroyed abnormally and Tab move between different windows.
   std::unordered_set<uint64_t> mActiveAnimations;
   nsDataHashtable<nsUint64HashKey, RefPtr<WebRenderImageHost>> mAsyncCompositables;
   nsDataHashtable<nsUint64HashKey, RefPtr<WebRenderImageHost>> mExternalImageIds;
 
   TimeStamp mPreviousFrameTimeStamp;
   // These fields keep track of the latest layer observer epoch values in the child and the