Commit 55897b37 authored by Andrew Osmond's avatar Andrew Osmond
Browse files

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.
parent 17c17bd0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ public:
    , mStride(0)
    , mMapCount(0)
    , mFormat(SurfaceFormat::UNKNOWN)
    , mWasPurged(false)
  {
  }

@@ -66,10 +67,12 @@ public:
  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;
@@ -100,6 +103,7 @@ private:
  RefPtr<VolatileBuffer> mVBuf;
  VolatileBufferPtr<uint8_t> mVBufPtr;
  SurfaceFormat mFormat;
  bool mWasPurged;
};

} // namespace gfx