summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2016-03-17 11:02:07 -0700
committer John Reck <jreck@google.com> 2016-03-17 11:02:07 -0700
commitdb009173f800bb0d626c42786b5bd0f57cc6545a (patch)
tree1d754611a0bfc0501424c05770c8ad3266724a62
parentf068cff1761a2876587caa7ca6978a848198439a (diff)
Fix NPE in clearTexture()
Change-Id: I38d261968506ab8b312584c7e688e2b148fadd1f Fixes: 25928378
-rw-r--r--libs/hwui/Caches.h2
-rw-r--r--libs/hwui/Layer.cpp7
2 files changed, 8 insertions, 1 deletions
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index 330dc2951ec9..eac9359beab3 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -92,6 +92,8 @@ public:
*/
bool init();
+ bool isInitialized() { return mInitialized; }
+
/**
* Flush the cache.
*
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp
index 114347d94357..cdbbbab7730d 100644
--- a/libs/hwui/Layer.cpp
+++ b/libs/hwui/Layer.cpp
@@ -197,7 +197,12 @@ void Layer::generateTexture() {
}
void Layer::clearTexture() {
- caches.textureState().unbindTexture(texture.mId);
+ // There's a rare possibility that Caches could have been destroyed already
+ // since this method is queued up as a task.
+ // Since this is a reset method, treat this as non-fatal.
+ if (caches.isInitialized()) {
+ caches.textureState().unbindTexture(texture.mId);
+ }
texture.mId = 0;
}