The protos in this directory (and in frameworks/native/tracing/) define trace content that Android emits into Perfetto traces. They are “out-of-tree” (OOT) schemas: Android owns them, each one living in the repository that owns the process writing it. Perfetto's TracePacket / TrackEvent / InternedData messages reserve extension field numbers for them, and external/perfetto carries a read-only mirror under protos/third_party/android/ so trace_processor and the Winscope UI can decode the data. Design: rfcs/0017-out-of-tree-protos.md in Perfetto.
How the pieces fit, for every OOT schema:
extends the perfetto message through a wrapper (e.g. extend perfetto.protos.TracePacket { ... = N; }). Wire format is identical to a regular field with the same number.*_tracing_protos.json, aggregated by the platform registry at system/extras/tracing/system_tracing_protos.json. The registry build checks for collisions and produces /system/etc/tracing_descriptors.gz; traced embeds that descriptor into every trace, which is how trace tools decode new fields without a Perfetto update.protos/perfetto/trace/extensions.json and the schema is mirrored.This directory hosts the frameworks/base and frameworks/native schemas. Other modules own theirs the same way in their own repos (e.g. ART heap graph in art/perfetto_hprof/proto/, Connectivity network trace in packages/modules/Connectivity/.../libnetworkstats/proto/, Bluetooth in packages/modules/Bluetooth/system/gd/proto/tracing/).
| surface | proto (wrapper) | contents |
|---|---|---|
| TrackEvent extensions | frameworks_base_track_event.proto, frameworks_native_track_event.proto | typed track-event payloads emitted by base / native code |
| TracePacket extensions | frameworks_base_trace_packet.proto | app wakelocks (116), video frames (1000/1001) |
| InternedData extensions | frameworks_base_interned_data.proto | interned app-wakelock info (42), job names (44) |
| Winscope (TracePacket extensions) | winscope/ here + frameworks/native/tracing/winscope/ | window management, input, SurfaceFlinger, IME, ProtoLog, ViewCapture |
Adding a new payload: define the message next to its writer, add a field in the owning repo‘s wrapper using a number allocated by the Perfetto team (extensions.json), list the proto in the module’s *_tracing_protos.json, and mirror the schema into external/perfetto. Use the protos above as templates.
The winscope schemas are the complicated case: split across two repos (writers live in both), generated in three languages, with a frozen legacy umbrella. Everything below is winscope-specific.
Decide by two questions: are you handling whole TRACE PACKETS (a stream going into / coming out of a Perfetto trace) or standalone MESSAGE OBJECTS (payloads in isolation: tests, dumps, tools)? And in which language?
| intent | language | module | reference in code |
|---|---|---|---|
| trace writing | C | frameworks-native-tracing-protos-pzc-headers | #include <android/tracing/winscope/x.pzc.h> |
| trace writing/reading | C++ | frameworks-native-tracing-winscope-pbzero-cc-protos | #include <android/tracing/winscope/x.pbzero.h> |
| message objects | C++ | frameworks-native-tracing-winscope-lite-cc-protos | #include <frameworks/native/tracing/winscope/x.pb.h> |
| trace writing (framework dump) | Java | frameworks-base-tracing-winscope-javastream-protos | com.android.internal.tracing.winscope.protos.* |
| message objects + reading TracePacket extensions | Java | frameworks-base-tracing-winscope-lite-java-protos | com.android.internal.tracing.winscope.protos.lite.* |
Include-path rule: headers from the trace-SDK plugins (pzc, pbzero) live in the curated, repo-neutral android/tracing/... namespace; protoc-native .pb.h headers use the real tree-rooted path — each flavor follows the convention of the tool that generates it. The protos' own import statements are always tree-rooted (import "frameworks/native/tracing/winscope/..."); never reintroduce short-form imports, they recreate protoc's duplicate-canonical-name failure.
.protos.lite by lite_for_tests_jarjar_rules.txt precisely so the two can coexist on a test classpath). Depend on exactly the one your code uses.TracePacket.parseFrom() in Java silently drops them — pass an ExtensionRegistryLite populated via the wrappers' registerAllExtensions() (all bundled in the lite Java library).ProtoLogConfig, AndroidInputEventConfig etc. are Perfetto public API and stay perfetto-owned (perfetto.protos.*). Only trace payload schemas are OOT.GetExtensionSlowly) outside the perfetto repo. See LayerTraceGeneratorTest.cpp for the reference pattern.Each repo declares its TracePacket extension fields in its own wrapper — FrameworksNativeWinscopeTracePacket and FrameworksBaseWinscopeTracePacket — because extension ownership follows the repo that writes the data.
WinscopeExtensions (TracePacket field 112) is a legacy umbrella predating the migration: its extension range 1–8 is PERMANENTLY FROZEN to keep archival traces parseable. Never add fields there; new payloads request their own TracePacket extension number and use the owning repo's wrapper.
ProtoLogLevel deliberately exists twice: config-side in Perfetto (perfetto.protos, protolog_config.proto) and trace-side here (com.android.internal, protolog.proto). Their values MUST stay identical — wire-compatibility contract, marked on both enums.