[sf] Switch layer trace generator to use the new sf front end
Previously we used a mocked up flinger to playback the transactions
and then generate the layers trace. This was prone to data races
since layers were added on binder thread and transactions were
committed on the main thread. This would lead to invalid data
being generated or crashes.
This cl modifies the transaction traces to capture state changes
in the main thread and uses the new front end logic to generate
the layer snapshots. New front end has no dependencies to the rest
of surfaceflinger and will be more robust in recreating layer
snapshots .
Test: presubmit
Test: capture layers and transaction traces
Fixes: 255901752
Change-Id: I416bff27c90eae1ab8383cbfff4403b0e93c1006
diff --git a/services/surfaceflinger/Tracing/LayerTracing.h b/services/surfaceflinger/Tracing/LayerTracing.h
index b32001c..11bb9f4 100644
--- a/services/surfaceflinger/Tracing/LayerTracing.h
+++ b/services/surfaceflinger/Tracing/LayerTracing.h
@@ -40,14 +40,15 @@
*/
class LayerTracing {
public:
- LayerTracing(SurfaceFlinger& flinger);
+ LayerTracing();
~LayerTracing();
bool enable();
bool disable(std::string filename = FILE_NAME);
bool isEnabled() const;
status_t writeToFile();
- LayersTraceFileProto createTraceFileProto() const;
- void notify(bool visibleRegionDirty, int64_t time, int64_t vsyncId);
+ static LayersTraceFileProto createTraceFileProto();
+ void notify(bool visibleRegionDirty, int64_t time, int64_t vsyncId, LayersProto* layers,
+ std::string hwcDump, google::protobuf::RepeatedPtrField<DisplayProto>* displays);
enum : uint32_t {
TRACE_INPUT = 1 << 1,
@@ -60,13 +61,12 @@
};
void setTraceFlags(uint32_t flags);
bool flagIsSet(uint32_t flags) const;
+ uint32_t getFlags() const;
void setBufferSize(size_t bufferSizeInBytes);
void dump(std::string&) const;
private:
static constexpr auto FILE_NAME = "/data/misc/wmtrace/layers_trace.winscope";
-
- SurfaceFlinger& mFlinger;
uint32_t mFlags = TRACE_INPUT;
mutable std::mutex mTraceLock;
bool mEnabled GUARDED_BY(mTraceLock) = false;