From 2803792bfa2dbefc2bf03f9417d13aaae2ce5673 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 8 Apr 2020 10:57:07 -0700 Subject: SurfaceComposerClient BLAST: Avoid recaching buffers. cacheBuffers works like this: 1. Look for any State with eBufferChanged 2. If it has a cache entry clear eBufferChanged and set the cache 3. If it doesn't have an entry leave eBufferChanged set, but also set the cache so we can use it next time. In the third case where we don't clear eBufferChanged we might attempt to recache buffers that have already been cached. This might happen in the wrong process. Bug: 153561718 Test: Existing tests pass. BLAST Sync Engine manual test. Change-Id: Ibe02e76d40fedef46a2418587e28e598d6e2c614 --- libs/gui/SurfaceComposerClient.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index e89863f48b..605c2e8848 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -560,6 +560,11 @@ void SurfaceComposerClient::Transaction::cacheBuffers() { layer_state_t* s = getLayerState(handle); if (!(s->what & layer_state_t::eBufferChanged)) { continue; + } else if (s->what & layer_state_t::eCachedBufferChanged) { + // If eBufferChanged and eCachedBufferChanged are both trued then that means + // we already cached the buffer in a previous call to cacheBuffers, perhaps + // from writeToParcel on a Transaction that was merged in to this one. + continue; } // Don't try to cache a null buffer. Sending null buffers is cheap so we shouldn't waste -- cgit v1.2.3-59-g8ed1b