diff options
author | 2019-08-08 20:05:32 -0700 | |
---|---|---|
committer | 2019-08-12 22:23:20 +0000 | |
commit | 4545a8a3ffece9db0732cb9183ed253dc22e8216 (patch) | |
tree | 144ace6c6f0a625e521752ff12fa1ed8e4fd9c08 /services/surfaceflinger/ClientCache.cpp | |
parent | 2a7a3bfec713dac55a482c60e977333b63cb7de5 (diff) |
[SurfaceFlinger] Callback to renderengine when erasing BLAST buffers
Otherwise we may leak if BufferStateLayer is destroyed first.
Bug: 137514000
Test: Over 61 hours, ran: while [ true ]; do am start -n \
com.android.chrome/com.google.android.apps.chrome.Main \
http://m.youtube.com; sleep 10; input tap 740 740 ; sleep 10; input \
keyevent HOME; sleep 0.5; am force-stop com.android.chrome; sleep 0.5; \
done
Test: Over >30 minutes: while [ true ]; do am start -n \
com.android.chrome/com.google.android.apps.chrome.Main \
http://m.youtube.com; sleep 10; input tap 740 740; \
sleep 1; content insert --uri content://settings/system --bind \
name:s:user_rotation --bind value:i:1; sleep 4; content insert --uri \
content://settings/system --bind name:s:user_rotation --bind value:i:0; \
sleep 5; input keyevent HOME; sleep 0.5; \
am force-stop com.android.chrome; sleep 0.5; done
Test: CtsViewTestCases:ASurfaceControlTest
Test: CtsViewTestCases:SurfaceControlTest
Test: Transaction_test
Change-Id: I743eb8bd9887d17e08b6f1b8e8ec5874359df175
Diffstat (limited to 'services/surfaceflinger/ClientCache.cpp')
-rw-r--r-- | services/surfaceflinger/ClientCache.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp index 77f2f5765c..16fe27c00a 100644 --- a/services/surfaceflinger/ClientCache.cpp +++ b/services/surfaceflinger/ClientCache.cpp @@ -55,16 +55,16 @@ bool ClientCache::getBuffer(const client_cache_t& cacheId, return true; } -void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) { +bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) { auto& [processToken, id] = cacheId; if (processToken == nullptr) { ALOGE("failed to cache buffer: invalid process token"); - return; + return false; } if (!buffer) { ALOGE("failed to cache buffer: invalid buffer"); - return; + return false; } std::lock_guard lock(mMutex); @@ -77,13 +77,13 @@ void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu token = processToken.promote(); if (!token) { ALOGE("failed to cache buffer: invalid token"); - return; + return false; } status_t err = token->linkToDeath(mDeathRecipient); if (err != NO_ERROR) { ALOGE("failed to cache buffer: could not link to death"); - return; + return false; } auto [itr, success] = mBuffers.emplace(processToken, std::unordered_map<uint64_t, ClientCacheBuffer>()); @@ -95,10 +95,11 @@ void ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu if (processBuffers.size() > BUFFER_CACHE_MAX_SIZE) { ALOGE("failed to cache buffer: cache is full"); - return; + return false; } processBuffers[id].buffer = buffer; + return true; } void ClientCache::erase(const client_cache_t& cacheId) { @@ -139,16 +140,17 @@ sp<GraphicBuffer> ClientCache::get(const client_cache_t& cacheId) { return buf->buffer; } -void ClientCache::registerErasedRecipient(const client_cache_t& cacheId, +bool ClientCache::registerErasedRecipient(const client_cache_t& cacheId, const wp<ErasedRecipient>& recipient) { std::lock_guard lock(mMutex); ClientCacheBuffer* buf = nullptr; if (!getBuffer(cacheId, &buf)) { ALOGE("failed to register erased recipient, could not retrieve buffer"); - return; + return false; } buf->recipients.insert(recipient); + return true; } void ClientCache::unregisterErasedRecipient(const client_cache_t& cacheId, |