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.
This commit is contained in:
Andrew Osmond 2017-09-15 14:47:52 -04:00
Родитель 17c17bd036
Коммит 55897b37f2
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -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