Add layer tracing's MODE_GENERATED_BUGREPORT_ONLY
The generated layers trace can be quite large (100-400 MB), which is way above
the perfetto's field upload budget.
On the field (AOT) we want the layers trace to be generated only when a bugreport
is taken and not when a perfetto's field upload happens. We achieve it as follows:
- In the AOT configuration, enable the 'android.surfaceflinger_layers' data source
with MODE_GENERATED_BUGREPORT_ONLY.
- When LayerTracing receives perfetto's OnFlush event and MODE_GENERATED_BUGREPORT_ONLY is enabled,
generate the layers trace only if the OnFlush event is due to a bugreport being taken:
args.flush_flags.reason() == perfetto::FlushFlags::Reason::kTraceClone &&
args.flush_flags.clone_target() == perfetto::FlushFlags::CloneTarget::kBugreport
In a test environment instead, we can use MODE_GENERATED to test the layers trace generation
without having to take a bugreport.
Bug: b/293429094
Test: 1. Manually start the perfetto's android.surfaceflinger_layers data source
with MODE_GENERATED_BUGREPORT_ONLY setting a high bugreport_score (e.g. 50000)
2. Take a bugreport (adb bugreport)
3. Verify that FS/data/misc/perfetto-traces/bugreport/systrace.pftrace (in the bugreport)
contains the generated layers trace. E.g. inspect bugreport with go/winscope.
Change-Id: I5b3ce59cc762fd5a22170e677e48be987380c94e
diff --git a/services/surfaceflinger/Tracing/LayerTracing.h b/services/surfaceflinger/Tracing/LayerTracing.h
index fe7f06d..2895ba7 100644
--- a/services/surfaceflinger/Tracing/LayerTracing.h
+++ b/services/surfaceflinger/Tracing/LayerTracing.h
@@ -55,7 +55,9 @@
* and written to perfetto.
*
*
- * E.g. start active mode tracing:
+ * E.g. start active mode tracing
+ * (replace mode value with MODE_DUMP, MODE_GENERATED or MODE_GENERATED_BUGREPORT_ONLY to enable
+ * different tracing modes):
*
adb shell -t perfetto \
-c - --txt \
@@ -79,7 +81,7 @@
}
}
}
- EOF
+EOF
*
*/
class LayerTracing {
@@ -106,7 +108,7 @@
// Start event from perfetto data source
void onStart(Mode mode, uint32_t flags);
// Flush event from perfetto data source
- void onFlush(Mode mode, uint32_t flags);
+ void onFlush(Mode mode, uint32_t flags, bool isBugreport);
// Stop event from perfetto data source
void onStop(Mode mode);