From 2e4f67c388aff0def50dd619388624f1dbe359ad Mon Sep 17 00:00:00 2001 From: Digish Pandya Date: Wed, 4 Nov 2015 11:00:28 +0530 Subject: Fix HWUI Path Cache dangling pointer When precache, PathTexture is added to PathCache, and it is released after drawn if we want to clean it. But the PathCache LRU still holds the entry of the PathTexture object. When trim the cache in the end of each frame, LRU finds that its mListener is not NULL and invoke the functor, however, mListerer points to the released PathTexture object and is a dangling pointer, thus leads to crash. Smart pointer don't help here since they only manage scopes, while PathTexture is also controled by its cleanup field. The fix is to also remove the LRU entry of PathTexture*, it will also release the texture object and there won't be texture leaks. Change-Id: Iaa0621df5dc71532e9e75b38ad94384353930b95 --- libs/hwui/PathCache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libs/hwui/PathCache.cpp') diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 3af640f76365..3236f6f7c24d 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -400,6 +400,13 @@ PathTexture* PathCache::get(const SkPath* path, const SkPaint* paint) { return texture; } +void PathCache::remove(const SkPath* path, const SkPaint* paint) +{ + PathDescription entry(kShapePath, paint); + entry.shape.path.mGenerationID = path->getGenerationID(); + mCache.remove(entry); +} + void PathCache::precache(const SkPath* path, const SkPaint* paint) { if (!Caches::getInstance().tasks.canRunTasks()) { return; -- cgit v1.2.3-59-g8ed1b