Bug 1380649 - Assert if we remap a purged SourceSurfaceVolatileBuffer. r=jrmuizel
☠☠ backed out by b3f6d72c338e ☠ ☠
authorAndrew Osmond <aosmond@mozilla.com>
Fri, 15 Sep 2017 14:47:52 -0400
changeset 381181 722569a89186be92efbaebfa99005e5c46e27cf5
parent 381180 eba07bb1d697ccb0bcc822bc80e7683bc0ca1879
child 381182 4360d673edef90dc3b3397b60d1cfdcc1ed0c312
push id95059
push useraosmond@gmail.com
push dateFri, 15 Sep 2017 18:48:04 +0000
treeherdermozilla-inbound@722569a89186 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1380649
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 1380649 - Assert if we remap a purged SourceSurfaceVolatileBuffer. r=jrmuizel There have been reports of images remaining in the surface cache but no longer containing the previously decoded data. Instead these appear as transparent (BGRA) or black (BGRX). This suggests that somehow the image surface buffer was reset to all zeroes. Additionally this seems to be correlated with suspend and resume. One possibility is that the OS purged our volatile buffers on suspend. This is because we are supposed to be able to regenerate the contents anyways, so it could choose to not preserve the data on suspend. In general we should recover from this however and clearly we are not. This patch adds a diagnostic assert to ensure that a buffer which was previously purged is not reused later, as we should be discarding said buffers.
gfx/layers/SourceSurfaceVolatileData.h
--- a/gfx/layers/SourceSurfaceVolatileData.h
+++ b/gfx/layers/SourceSurfaceVolatileData.h
@@ -27,16 +27,17 @@ class SourceSurfaceVolatileData : public
 public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceVolatileData, override)
 
   SourceSurfaceVolatileData()
     : mMutex("SourceSurfaceVolatileData")
     , mStride(0)
     , mMapCount(0)
     , mFormat(SurfaceFormat::UNKNOWN)
+    , mWasPurged(false)
   {
   }
 
   bool Init(const IntSize &aSize,
             int32_t aStride,
             SurfaceFormat aFormat);
 
   uint8_t *GetData() override { return mVBufPtr; }
@@ -61,20 +62,22 @@ public:
   // we want to allow it for SourceSurfaceVolatileData since it should
   // always be fine (for reading at least).
   //
   // This is the same as the base class implementation except using
   // mMapCount instead of mIsMapped since that breaks for multithread.
   bool Map(MapType, MappedSurface *aMappedSurface) override
   {
     MutexAutoLock lock(mMutex);
+    MOZ_DIAGNOSTIC_ASSERT(!mWasPurged);
     if (mMapCount == 0) {
       mVBufPtr = mVBuf;
     }
     if (mVBufPtr.WasBufferPurged()) {
+      mWasPurged = true;
       return false;
     }
     aMappedSurface->mData = mVBufPtr;
     aMappedSurface->mStride = mStride;
     ++mMapCount;
     return true;
   }
 
@@ -95,14 +98,15 @@ private:
 
   Mutex mMutex;
   int32_t mStride;
   int32_t mMapCount;
   IntSize mSize;
   RefPtr<VolatileBuffer> mVBuf;
   VolatileBufferPtr<uint8_t> mVBufPtr;
   SurfaceFormat mFormat;
+  bool mWasPurged;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_SOURCESURFACEVOLATILEDATA_H_ */