Fix concurrent writes to the hardware composer
Stale hardware composer layers were causing concurrent writes to the
Composer object from the surface flinger and vr flinger threads, a big
no-no. The concurrent writes would sometimes stomp on each other,
causing the hardware composer service to fail to read the command buffer
containing surface flinger's composer commands, leading to all sorts of
issues.
Bug: 62925812
Test: Locally added logs to surface flinger to catch the concurrent
writes, and confirmed the logs are no longer present with this patch
applied. Went through a bunch of sleep/wake cycles and confirmed the
device continues to function normally.
Change-Id: I70929c4a3c71142f5e9083cac294c122d127aa27
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index 2360a61..dc0fb58 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -577,7 +577,12 @@
/* ------------------------------------------------------------------------
* VrFlinger
*/
- void clearHwcLayers(const LayerVector& layers);
+ template<typename T>
+ void clearHwcLayers(const T& layers) {
+ for (size_t i = 0; i < layers.size(); ++i) {
+ layers[i]->clearHwcLayers();
+ }
+ }
void resetHwcLocked();
// Check to see if we should handoff to vr flinger.