Free resources only from the GL context thread.
Bug #3179882
Resources were freed following garbage collections on a worker thread.
This worker thread had no EGL context, which would cause the renderer
to incorrectly assume that the memory was liberated.
Change-Id: Ifdb51f94ddf42641e8654522787bfac532976c7c
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 47c5d48..9f18948 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -126,7 +126,7 @@
if (ref == NULL) {
// If we're not tracking this resource, just delete it
if (Caches::hasInstance()) {
- Caches::getInstance().textureCache.remove(resource);
+ Caches::getInstance().textureCache.removeDeferred(resource);
}
delete resource;
return;
@@ -143,7 +143,7 @@
if (ref == NULL) {
// If we're not tracking this resource, just delete it
if (Caches::hasInstance()) {
- Caches::getInstance().gradientCache.remove(resource->getSkShader());
+ Caches::getInstance().gradientCache.removeDeferred(resource->getSkShader());
}
delete resource;
return;
@@ -179,7 +179,7 @@
{
SkBitmap* bitmap = (SkBitmap*)resource;
if (Caches::hasInstance()) {
- Caches::getInstance().textureCache.remove(bitmap);
+ Caches::getInstance().textureCache.removeDeferred(bitmap);
}
delete bitmap;
}
@@ -188,7 +188,7 @@
{
SkiaShader* shader = (SkiaShader*)resource;
if (Caches::hasInstance()) {
- Caches::getInstance().gradientCache.remove(shader->getSkShader());
+ Caches::getInstance().gradientCache.removeDeferred(shader->getSkShader());
}
delete shader;
}