From c3c58e015fa30a0ad87d4af2b95b7071baa8ffe4 Mon Sep 17 00:00:00 2001 From: Sangkyu Lee Date: Mon, 12 Jan 2015 09:51:53 +0900 Subject: Fix ANR caused by hwuiTask thread If hwuiTask thread is exited while HWUI renders something, some tasks can remain unfinished forever. This can make ANR problem if RenderThread waits this kind of tasks. According to the current implementation, hwuiTask threads are exited when HWUI receives trimMemory() callback with level >= 20 and some applications such as SystemUI can receive trimMemory() with level >= 20 even though they renders something yet. (For instance, when RecentsActivity in SystemUI is finished, HWUI receives trimMemory() callback with level >= 20 but SystemUI should still render the status bar and navigation bar.) This patch prevents the tasks from remaining unfinished and make the tasks executed immediately if they cannot be added to their TaskProcessors. Change-Id: I5bd26439aa5f183b1a7c1ce466362e27554b4d16 --- libs/hwui/TessellationCache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libs/hwui/TessellationCache.cpp') diff --git a/libs/hwui/TessellationCache.cpp b/libs/hwui/TessellationCache.cpp index 1e38f9e9e615..bc956be8a059 100644 --- a/libs/hwui/TessellationCache.cpp +++ b/libs/hwui/TessellationCache.cpp @@ -385,7 +385,9 @@ void TessellationCache::precacheShadows(const Matrix4* drawTransform, const Rect if (mShadowProcessor == NULL) { mShadowProcessor = new ShadowProcessor(Caches::getInstance()); } - mShadowProcessor->add(task); + if (!mShadowProcessor->add(task)) { + mShadowProcessor->process(task); + } task->incStrong(NULL); // not using sp<>s, so manually ref while in the cache mShadowCache.put(key, task.get()); @@ -421,7 +423,9 @@ TessellationCache::Buffer* TessellationCache::getOrCreateBuffer( if (mProcessor == NULL) { mProcessor = new TessellationProcessor(Caches::getInstance()); } - mProcessor->add(task); + if (!mProcessor->add(task)) { + mProcessor->process(task); + } mCache.put(entry, buffer); } return buffer; -- cgit v1.2.3-59-g8ed1b