Bug 933082 - Part 2: propagate the mIPCOpen flag, avoid crashing in DestroySharedSurface on a dead channel - r=nical
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 27 Nov 2013 10:18:38 -0500
changeset 172448 849931c5c32edd3bf0ec786c1e44ea8179cf90c7
parent 172447 1cf4d557bf9433b2feff93793fb16d114a67a345
child 172449 958fa3ca2b5979764712ecfe8893545e961aba05
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs933082
milestone28.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 933082 - Part 2: propagate the mIPCOpen flag, avoid crashing in DestroySharedSurface on a dead channel - r=nical
gfx/layers/ipc/ISurfaceAllocator.cpp
gfx/layers/ipc/ISurfaceAllocator.h
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
--- a/gfx/layers/ipc/ISurfaceAllocator.cpp
+++ b/gfx/layers/ipc/ISurfaceAllocator.cpp
@@ -122,16 +122,19 @@ ISurfaceAllocator::IsShmem(SurfaceDescri
 
 void
 ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface)
 {
   MOZ_ASSERT(aSurface);
   if (!aSurface) {
     return;
   }
+  if (!IPCOpen()) {
+    return;
+  }
   if (PlatformDestroySharedSurface(aSurface)) {
     return;
   }
   switch (aSurface->type()) {
     case SurfaceDescriptor::TShmem:
       DeallocShmem(aSurface->get_Shmem());
       break;
     case SurfaceDescriptor::TYCbCrImage:
--- a/gfx/layers/ipc/ISurfaceAllocator.h
+++ b/gfx/layers/ipc/ISurfaceAllocator.h
@@ -119,16 +119,18 @@ ISurfaceAllocator() {}
   virtual PGrallocBufferChild* AllocGrallocBuffer(const gfxIntSize& aSize,
                                                   uint32_t aFormat,
                                                   uint32_t aUsage,
                                                   MaybeMagicGrallocBufferHandle* aHandle)
   {
     return nullptr;
   }
 
+  virtual bool IPCOpen() const { return true; }
+
   // Returns true if aSurface wraps a Shmem.
   static bool IsShmem(SurfaceDescriptor* aSurface);
 
 protected:
   // this method is needed for a temporary fix, will be removed after
   // DeprecatedTextureClient/Host rework.
   virtual bool IsOnCompositorSide() const = 0;
   static bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -612,16 +612,22 @@ ShadowLayerForwarder::AllocUnsafeShmem(s
 }
 void
 ShadowLayerForwarder::DeallocShmem(ipc::Shmem& aShmem)
 {
   NS_ABORT_IF_FALSE(HasShadowManager(), "no shadow manager");
   mShadowManager->DeallocShmem(aShmem);
 }
 
+bool
+ShadowLayerForwarder::IPCOpen() const
+{
+  return mShadowManager->IPCOpen();
+}
+
 /*static*/ already_AddRefed<gfxASurface>
 ShadowLayerForwarder::OpenDescriptor(OpenMode aMode,
                                      const SurfaceDescriptor& aSurface)
 {
   nsRefPtr<gfxASurface> surf = PlatformOpenDescriptor(aMode, aSurface);
   if (surf) {
     return surf.forget();
   }
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -389,16 +389,18 @@ public:
   virtual bool AllocUnsafeShmem(size_t aSize,
                                 mozilla::ipc::SharedMemory::SharedMemoryType aType,
                                 mozilla::ipc::Shmem* aShmem) MOZ_OVERRIDE;
   virtual bool AllocShmem(size_t aSize,
                           mozilla::ipc::SharedMemory::SharedMemoryType aType,
                           mozilla::ipc::Shmem* aShmem) MOZ_OVERRIDE;
   virtual void DeallocShmem(mozilla::ipc::Shmem& aShmem) MOZ_OVERRIDE;
 
+  virtual bool IPCOpen() const MOZ_OVERRIDE;
+
   /**
    * Construct a shadow of |aLayer| on the "other side", at the
    * LayerManagerComposite.
    */
   PLayerChild* ConstructShadowFor(ShadowableLayer* aLayer);
 
   /**
    * Flag the next paint as the first for a document.