tree: de9b9e7c108f9b9c29898ec92290ff766ce71b31 [search]
  1. winscope/
  2. Android.bp
  3. AndroidTrackEventOuterClass.java
  4. frameworks_base_common.proto
  5. frameworks_base_interned_data.proto
  6. frameworks_base_trace_packet.proto
  7. frameworks_base_tracing_protos.json
  8. frameworks_base_track_event.proto
  9. lite_for_tests_jarjar_rules.txt
  10. OWNERS
  11. README.md
proto/tracing/README.md

Android Tracing Protos (Out-of-Tree Perfetto Schemas)

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:

  • The schema file lives next to its writer and 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.
  • The owning module registers its field numbers in a small *_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.
  • Perfetto-side, the extension hole is recorded in 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/).

What's defined here

surfaceproto (wrapper)contents
TrackEvent extensionsframeworks_base_track_event.proto, frameworks_native_track_event.prototyped track-event payloads emitted by base / native code
TracePacket extensionsframeworks_base_trace_packet.protoapp wakelocks (116), video frames (1000/1001)
InternedData extensionsframeworks_base_interned_data.protointerned 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.

Winscope

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.

What do I link?

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?

intentlanguagemodulereference in code
trace writingCframeworks-native-tracing-protos-pzc-headers#include <android/tracing/winscope/x.pzc.h>
trace writing/readingC++frameworks-native-tracing-winscope-pbzero-cc-protos#include <android/tracing/winscope/x.pbzero.h>
message objectsC++frameworks-native-tracing-winscope-lite-cc-protos#include <frameworks/native/tracing/winscope/x.pb.h>
trace writing (framework dump)Javaframeworks-base-tracing-winscope-javastream-protoscom.android.internal.tracing.winscope.protos.*
message objects + reading TracePacket extensionsJavaframeworks-base-tracing-winscope-lite-java-protoscom.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.

Rules

  • One Java flavor per module. Javastream (write-only streaming tokens) and lite (message classes) generate the same class names with different members; their runtime packages differ (lite is relocated to .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.
  • Winscope payloads are proto2 EXTENSIONS of TracePacket. Plain TracePacket.parseFrom() in Java silently drops them — pass an ExtensionRegistryLite populated via the wrappers' registerAllExtensions() (all bundled in the lite Java library).
  • The lite Java library is self-contained. It carries the winscope messages, the extension accessors, and the perfetto TracePacket classes they need; link just it. Message-only consumers carry some unused classes — an accepted trade (consumers are tests and host tools) for zero duplicate-class pitfalls.
  • Config protos never moved. ProtoLogConfig, AndroidInputEventConfig etc. are Perfetto public API and stay perfetto-owned (perfetto.protos.*). Only trace payload schemas are OOT.
  • Reading packets in C++ (tests/tools): production writing always goes through the Perfetto SDK (pbzero); for reading payloads back out, parse the payload bytes with the lite message classes — do not use perfetto's protozero decoder internals (e.g. GetExtensionSlowly) outside the perfetto repo. See LayerTraceGeneratorTest.cpp for the reference pattern.

Wrapper and extension model

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.