Prevent ANR in apps using drawPath()
Bug #10347089
If an app clears its path cache before stopping background tasks, it could
get into an infinite loop in PathCache::trim().
Change-Id: Ieb865b762e7b00aebaba0c023769c2db286a94f5
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 641cbc8..f9cf9a2 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -331,6 +331,11 @@
void Caches::flush(FlushMode mode) {
FLUSH_LOGD("Flushing caches (mode %d)", mode);
+ // We must stop tasks before clearing caches
+ if (mode > kFlushMode_Layers) {
+ tasks.stop();
+ }
+
switch (mode) {
case kFlushMode_Full:
textureCache.clear();
@@ -345,7 +350,6 @@
fontRenderer->flush();
textureCache.flush();
pathCache.clear();
- tasks.stop();
// fall through
case kFlushMode_Layers:
layerCache.clear();