diff --git a/src/gpu/graphite/BufferManager.cpp b/src/gpu/graphite/BufferManager.cpp index bd72625150c..6f3ea046af0 100644 --- a/src/gpu/graphite/BufferManager.cpp +++ b/src/gpu/graphite/BufferManager.cpp @@ -264,6 +264,17 @@ void BufferSubAllocator::reset() { SkASSERT(fOwner); DrawBufferManager::BufferState& state = fOwner->fCurrentBuffers[fStateIndex]; + if (fOwner->fMappingFailed) { + // onFailedBuffer() has already cleared fAvailableBuffer and fUsedBuffers; do not + // re-stash this allocator (which would carry a stale fTransferBuffer raw Buffer* and + // fMappedPtr past the failed snap into the next one). Just drop the buffer. + if (fBuffer->isMapped()) { + fBuffer->unmap(); + } + fBuffer.reset(); + fRemaining = 0; + return; + } if (fBuffer->shareable() == Shareable::kScratch) { // TODO: Merge this reuse of scratch resources with the ScratchResourceManager, but // currently this is resolved outside of Task::prepareResources().