diff options
author | 2019-11-18 11:18:57 -0800 | |
---|---|---|
committer | 2019-11-19 18:29:37 +0000 | |
commit | 90fcc94791b5970766ed4571ed85e7c76ffc7c55 (patch) | |
tree | 19d6ed949c78e743f251cb152e5f7ebc8751bf0f | |
parent | 1c2a53e618eff6ed831f6c70196389c02a27c6dd (diff) |
Keeping sp<IBinder> around in ClientCache
binderDied is no longer called if all sp references are dropped in SF
process. Keep an sp<IBinder> around so that we can get notified to
clean up the ClientCache/RenderEngine
Bug: b/144371238
Test: build, boot, manual (script to open and close Chrome
repeatedly, check RenderEngine image cache size in dumpsys), SurfaceFlinger_test,
libsurfaceflinger_unittest
Change-Id: Ib9374c02db59e09ca53280acc64419bda6827a4d
-rw-r--r-- | services/surfaceflinger/ClientCache.cpp | 12 | ||||
-rw-r--r-- | services/surfaceflinger/ClientCache.h | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp index 16fe27c00a..a5be01c75c 100644 --- a/services/surfaceflinger/ClientCache.cpp +++ b/services/surfaceflinger/ClientCache.cpp @@ -42,7 +42,7 @@ bool ClientCache::getBuffer(const client_cache_t& cacheId, return false; } - auto& processBuffers = it->second; + auto& processBuffers = it->second.second; auto bufItr = processBuffers.find(id); if (bufItr == processBuffers.end()) { @@ -86,12 +86,14 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu return false; } auto [itr, success] = - mBuffers.emplace(processToken, std::unordered_map<uint64_t, ClientCacheBuffer>()); + mBuffers.emplace(processToken, + std::make_pair(token, + std::unordered_map<uint64_t, ClientCacheBuffer>())); LOG_ALWAYS_FATAL_IF(!success, "failed to insert new process into client cache"); it = itr; } - auto& processBuffers = it->second; + auto& processBuffers = it->second.second; if (processBuffers.size() > BUFFER_CACHE_MAX_SIZE) { ALOGE("failed to cache buffer: cache is full"); @@ -120,7 +122,7 @@ void ClientCache::erase(const client_cache_t& cacheId) { } } - mBuffers[processToken].erase(id); + mBuffers[processToken].second.erase(id); } for (auto& recipient : pendingErase) { @@ -180,7 +182,7 @@ void ClientCache::removeProcess(const wp<IBinder>& processToken) { return; } - for (auto& [id, clientCacheBuffer] : itr->second) { + for (auto& [id, clientCacheBuffer] : itr->second.second) { client_cache_t cacheId = {processToken, id}; for (auto& recipient : clientCacheBuffer.recipients) { sp<ErasedRecipient> erasedRecipient = recipient.promote(); diff --git a/services/surfaceflinger/ClientCache.h b/services/surfaceflinger/ClientCache.h index aa6c80dfa7..d7af7c0e97 100644 --- a/services/surfaceflinger/ClientCache.h +++ b/services/surfaceflinger/ClientCache.h @@ -61,7 +61,8 @@ private: std::set<wp<ErasedRecipient>> recipients; }; std::map<wp<IBinder> /*caching process*/, - std::unordered_map<uint64_t /*cache id*/, ClientCacheBuffer>> + std::pair<sp<IBinder> /*strong ref to caching process*/, + std::unordered_map<uint64_t /*cache id*/, ClientCacheBuffer>>> mBuffers GUARDED_BY(mMutex); class CacheDeathRecipient : public IBinder::DeathRecipient { |