summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Caches.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2012-09-25 22:52:40 -0700
committerMathias Agopian <mathias@google.com>2012-09-25 22:52:40 -0700
commit17ef62cc1f9d092669af0fed465a9a77e0dc1a4f (patch)
tree6d88c86ef0cb81ae3cecdfc4724f96f850415983 /libs/hwui/Caches.cpp
parent348f08f468167d56d7f66c59401da8bc69aab746 (diff)
downloadframeworks_base-17ef62cc1f9d092669af0fed465a9a77e0dc1a4f.zip
frameworks_base-17ef62cc1f9d092669af0fed465a9a77e0dc1a4f.tar.gz
frameworks_base-17ef62cc1f9d092669af0fed465a9a77e0dc1a4f.tar.bz2
fix a possible dead-lock when clearing caches
Bug: 7195815 Change-Id: I8e226b7ec445f9f4fe46ae216ef7cc41efc5a0fd
Diffstat (limited to 'libs/hwui/Caches.cpp')
-rw-r--r--libs/hwui/Caches.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index 4459495..f0f72f9 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -227,21 +227,29 @@ void Caches::clearGarbage() {
textureCache.clearGarbage();
pathCache.clearGarbage();
- Mutex::Autolock _l(mGarbageLock);
+ Vector<DisplayList*> displayLists;
+ Vector<Layer*> layers;
+
+ { // scope for the lock
+ Mutex::Autolock _l(mGarbageLock);
+ displayLists = mDisplayListGarbage;
+ layers = mLayerGarbage;
+ mDisplayListGarbage.clear();
+ mLayerGarbage.clear();
+ }
- size_t count = mLayerGarbage.size();
+ size_t count = displayLists.size();
for (size_t i = 0; i < count; i++) {
- Layer* layer = mLayerGarbage.itemAt(i);
- delete layer;
+ DisplayList* displayList = displayLists.itemAt(i);
+ delete displayList;
}
- mLayerGarbage.clear();
- count = mDisplayListGarbage.size();
+ count = layers.size();
for (size_t i = 0; i < count; i++) {
- DisplayList* displayList = mDisplayListGarbage.itemAt(i);
- delete displayList;
+ Layer* layer = layers.itemAt(i);
+ delete layer;
}
- mDisplayListGarbage.clear();
+ layers.clear();
}
void Caches::deleteLayerDeferred(Layer* layer) {