make GrTextBlobCache::remove thread safe
Change-Id: I48979516c13fcfedcb9580e05c899d800553d55a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/375072
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Adlai Holler <adlai@google.com>
diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp
index baee93ee2..3fbe5c5 100644
--- a/src/gpu/text/GrTextBlobCache.cpp
+++ b/src/gpu/text/GrTextBlobCache.cpp
@@ -52,13 +52,17 @@
void GrTextBlobCache::internalRemove(GrTextBlob* blob) {
auto id = GrTextBlob::GetKey(*blob).fUniqueID;
auto* idEntry = fBlobIDCache.find(id);
- SkASSERT(idEntry);
- fCurrentSize -= blob->size();
- fBlobList.remove(blob);
- idEntry->removeBlob(blob);
- if (idEntry->fBlobs.empty()) {
- fBlobIDCache.remove(id);
+ if (idEntry != nullptr) {
+ sk_sp<GrTextBlob> stillExists = idEntry->find(blob->key());
+ if (blob == stillExists.get()) {
+ fCurrentSize -= blob->size();
+ fBlobList.remove(blob);
+ idEntry->removeBlob(blob);
+ if (idEntry->fBlobs.empty()) {
+ fBlobIDCache.remove(id);
+ }
+ }
}
}