LayerTraceGenerator: Fix layer deletion
Fixes a couple of issues with layer handle tracking which manifested
in the generated trace showing layers which were destroyed.
1. Destroyed handles were not written to proto correctly
2. When a handle was destroyed, it was removed from the tracing handle
to layer id map immediately. but we need to access this mapping in the
tracing thread when writing the transaction to proto.
Test: atest transactiontrace_testsuite
Bug: 235376060
Change-Id: I021be9a3864bdfc61422fc2f751f9bfd5e674059
diff --git a/services/surfaceflinger/Tracing/TransactionTracing.h b/services/surfaceflinger/Tracing/TransactionTracing.h
index 2f5ee87..ae01d3c 100644
--- a/services/surfaceflinger/Tracing/TransactionTracing.h
+++ b/services/surfaceflinger/Tracing/TransactionTracing.h
@@ -85,8 +85,10 @@
std::unordered_map<int, proto::LayerCreationArgs> mCreatedLayers GUARDED_BY(mTraceLock);
std::unordered_map<BBinder* /* layerHandle */, int32_t /* layerId */> mLayerHandles
GUARDED_BY(mTraceLock);
- std::vector<int32_t /* layerId */> mRemovedLayerHandles GUARDED_BY(mTraceLock);
+ std::vector<std::pair<BBinder* /* layerHandle */, int32_t /* layerId */>> mRemovedLayerHandles
+ GUARDED_BY(mTraceLock);
std::map<int32_t /* layerId */, TracingLayerState> mStartingStates GUARDED_BY(mTraceLock);
+ std::set<int32_t /* layerId */> mRemovedLayerHandlesAtStart GUARDED_BY(mTraceLock);
TransactionProtoParser mProtoParser GUARDED_BY(mTraceLock);
// Parses the transaction to proto without holding any tracing locks so we can generate proto
// in the binder thread without any contention.