diff options
author | 2022-10-17 21:37:42 +0000 | |
---|---|---|
committer | 2022-10-20 20:07:45 +0000 | |
commit | f1e5df1d266f70a508c7b520fd52feced8fbcf61 (patch) | |
tree | 93b2588fa1ecf9d95ea6192ee0a51cdf20822dc6 /services/surfaceflinger/ClientCache.cpp | |
parent | b7458aeec6d575bd06e33a83ab26ebd41c3eaa63 (diff) |
SF: Trigger ANR when buffer cache is full
* Updates the transaction queue stall listener to take a string that
contains the reason for hanging.
* Updates ClientCache::add to indicate whether or not a failure is due
to the cache being full
* Calls the transaction queue stall listener when the ClientCache is
full
Bug: 244218818
Test: presubmits
Change-Id: I5fdc9aef0f0a1601ace1c42cfac5024c3de8d299
Diffstat (limited to 'services/surfaceflinger/ClientCache.cpp')
-rw-r--r-- | services/surfaceflinger/ClientCache.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/services/surfaceflinger/ClientCache.cpp b/services/surfaceflinger/ClientCache.cpp index b01932e413..2bd8f324e1 100644 --- a/services/surfaceflinger/ClientCache.cpp +++ b/services/surfaceflinger/ClientCache.cpp @@ -59,16 +59,17 @@ bool ClientCache::getBuffer(const client_cache_t& cacheId, return true; } -bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) { +base::expected<std::shared_ptr<renderengine::ExternalTexture>, ClientCache::AddError> +ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& buffer) { auto& [processToken, id] = cacheId; if (processToken == nullptr) { ALOGE_AND_TRACE("ClientCache::add - invalid (nullptr) process token"); - return false; + return base::unexpected(AddError::Unspecified); } if (!buffer) { ALOGE_AND_TRACE("ClientCache::add - invalid (nullptr) buffer"); - return false; + return base::unexpected(AddError::Unspecified); } std::lock_guard lock(mMutex); @@ -81,7 +82,7 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu token = processToken.promote(); if (!token) { ALOGE_AND_TRACE("ClientCache::add - invalid token"); - return false; + return base::unexpected(AddError::Unspecified); } // Only call linkToDeath if not a local binder @@ -89,7 +90,7 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu status_t err = token->linkToDeath(mDeathRecipient); if (err != NO_ERROR) { ALOGE_AND_TRACE("ClientCache::add - could not link to death"); - return false; + return base::unexpected(AddError::Unspecified); } } auto [itr, success] = @@ -104,17 +105,17 @@ bool ClientCache::add(const client_cache_t& cacheId, const sp<GraphicBuffer>& bu if (processBuffers.size() > BUFFER_CACHE_MAX_SIZE) { ALOGE_AND_TRACE("ClientCache::add - cache is full"); - return false; + return base::unexpected(AddError::CacheFull); } LOG_ALWAYS_FATAL_IF(mRenderEngine == nullptr, "Attempted to build the ClientCache before a RenderEngine instance was " "ready!"); - processBuffers[id].buffer = std::make_shared< - renderengine::impl::ExternalTexture>(buffer, *mRenderEngine, - renderengine::impl::ExternalTexture::Usage:: - READABLE); - return true; + + return (processBuffers[id].buffer = std::make_shared< + renderengine::impl::ExternalTexture>(buffer, *mRenderEngine, + renderengine::impl::ExternalTexture:: + Usage::READABLE)); } void ClientCache::erase(const client_cache_t& cacheId) { |