Backed out changeset 2efe54944e8c (bug 1453801) for huge AWSY regression with WebRender (bug 1454346) as well as frequent crashes (bug 1454112, bug 1454114). a=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 18 Apr 2018 01:08:20 +0300
changeset 467653 789e30ff2e3d6e1fcfce1a373c1e5635488d24da
parent 467652 d6eb5597d7447ee84aced9345bd4d13175c7e671
child 467671 5b68f5f5ed00691f9cab9ca9a42cd406d29ea57e
child 467725 786de338af8a63c33870f606fb7afb32b49798dc
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1453801, 1454346, 1454112, 1454114
milestone61.0a1
backs out2efe54944e8cb91f1198d0c55ccb440de5b37997
first release with
nightly linux32
789e30ff2e3d / 61.0a1 / 20180417225505 / files
nightly linux64
789e30ff2e3d / 61.0a1 / 20180417225505 / files
nightly mac
789e30ff2e3d / 61.0a1 / 20180417225505 / files
nightly win32
789e30ff2e3d / 61.0a1 / 20180417225505 / files
nightly win64
789e30ff2e3d / 61.0a1 / 20180417225505 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 2efe54944e8c (bug 1453801) for huge AWSY regression with WebRender (bug 1454346) as well as frequent crashes (bug 1454112, bug 1454114). a=backout
gfx/layers/SourceSurfaceSharedData.h
gfx/layers/ipc/SharedSurfacesParent.cpp
gfx/layers/ipc/SharedSurfacesParent.h
gfx/webrender_bindings/RenderThread.cpp
--- a/gfx/layers/SourceSurfaceSharedData.h
+++ b/gfx/layers/SourceSurfaceSharedData.h
@@ -77,28 +77,40 @@ public:
     aMappedSurface->mData = GetData();
     aMappedSurface->mStride = mStride;
     return true;
   }
 
   void Unmap() override
   { }
 
+  bool AddConsumer()
+  {
+    return ++mConsumers == 1;
+  }
+
+  bool RemoveConsumer()
+  {
+    MOZ_ASSERT(mConsumers > 0);
+    return --mConsumers == 0;
+  }
+
 private:
   size_t GetDataLength() const
   {
     return static_cast<size_t>(mStride) * mSize.height;
   }
 
   size_t GetAlignedDataLength() const
   {
     return mozilla::ipc::SharedMemory::PageAlignedSize(GetDataLength());
   }
 
   int32_t mStride;
+  uint32_t mConsumers;
   IntSize mSize;
   RefPtr<SharedMemoryBasic> mBuf;
   SurfaceFormat mFormat;
   base::ProcessId mCreatorPid;
 };
 
 /**
  * This class is used to wrap shared (as in process) data buffers used by a
--- a/gfx/layers/ipc/SharedSurfacesParent.cpp
+++ b/gfx/layers/ipc/SharedSurfacesParent.cpp
@@ -49,32 +49,54 @@ SharedSurfacesParent::Get(const wr::Exte
     return nullptr;
   }
 
   RefPtr<SourceSurfaceSharedDataWrapper> surface;
   sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
   return surface.forget();
 }
 
-/* static */ void
-SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
+/* static */ already_AddRefed<DataSourceSurface>
+SharedSurfacesParent::Acquire(const wr::ExternalImageId& aId)
+{
+  MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
+  if (!sInstance) {
+    return nullptr;
+  }
+
+  RefPtr<SourceSurfaceSharedDataWrapper> surface;
+  sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
+
+  if (surface) {
+    DebugOnly<bool> rv = surface->AddConsumer();
+    MOZ_ASSERT(!rv);
+  }
+  return surface.forget();
+}
+
+/* static */ bool
+SharedSurfacesParent::Release(const wr::ExternalImageId& aId)
 {
   //MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   if (!sInstance) {
-    return;
+    return false;
   }
 
   uint64_t id = wr::AsUint64(aId);
   RefPtr<SourceSurfaceSharedDataWrapper> surface;
   sInstance->mSurfaces.Get(wr::AsUint64(aId), getter_AddRefs(surface));
   if (!surface) {
-    return;
+    return false;
   }
 
-  sInstance->mSurfaces.Remove(id);
+  if (surface->RemoveConsumer()) {
+    sInstance->mSurfaces.Remove(id);
+  }
+
+  return true;
 }
 
 /* static */ void
 SharedSurfacesParent::AddSameProcess(const wr::ExternalImageId& aId,
                                      SourceSurfaceSharedData* aSurface)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
   MOZ_ASSERT(NS_IsMainThread());
@@ -166,10 +188,18 @@ SharedSurfacesParent::Add(const wr::Exte
 
   RefPtr<wr::RenderSharedSurfaceTextureHost> texture =
     new wr::RenderSharedSurfaceTextureHost(surface);
   wr::RenderThread::Get()->RegisterExternalImage(id, texture.forget());
 
   sInstance->mSurfaces.Put(id, surface.forget());
 }
 
+/* static */ void
+SharedSurfacesParent::Remove(const wr::ExternalImageId& aId)
+{
+  //MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
+  DebugOnly<bool> rv = Release(aId);
+  MOZ_ASSERT(rv);
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/ipc/SharedSurfacesParent.h
+++ b/gfx/layers/ipc/SharedSurfacesParent.h
@@ -30,19 +30,26 @@ namespace layers {
 class SharedSurfacesChild;
 
 class SharedSurfacesParent final
 {
 public:
   static void Initialize();
   static void Shutdown();
 
+  // Get without increasing the consumer count.
   static already_AddRefed<gfx::DataSourceSurface>
   Get(const wr::ExternalImageId& aId);
 
+  // Get but also increase the consumer count. Must call Release after finished.
+  static already_AddRefed<gfx::DataSourceSurface>
+  Acquire(const wr::ExternalImageId& aId);
+
+  static bool Release(const wr::ExternalImageId& aId);
+
   static void Add(const wr::ExternalImageId& aId,
                   const SurfaceDescriptorShared& aDesc,
                   base::ProcessId aPid);
 
   static void Remove(const wr::ExternalImageId& aId);
 
   static void DestroyProcess(base::ProcessId aPid);
 
--- a/gfx/webrender_bindings/RenderThread.cpp
+++ b/gfx/webrender_bindings/RenderThread.cpp
@@ -95,19 +95,16 @@ RenderThread::ShutDown()
 #endif
 }
 
 void
 RenderThread::ShutDownTask(layers::SynchronousTask* aTask)
 {
   layers::AutoCompleteTask complete(aTask);
   MOZ_ASSERT(IsInRenderThread());
-
-  MutexAutoLock lock(mRenderTextureMapLock);
-  mRenderTextures.Clear();
 }
 
 // static
 MessageLoop*
 RenderThread::Loop()
 {
   return sRenderThread ? sRenderThread->mThread->message_loop() : nullptr;
 }