TRACE_EVENT_BEGIN with track id doesn't work well with perfetto UI
I have sample code like:
void DrawDifferentTrack(int i) { TRACE_EVENT_BEGIN("rendering", "DrawGamediff",perfetto::Track(i%8)); DrawPlayer(1); TRACE_EVENT_END("rendering", perfetto::Track(i%8)); }
but the SQL query shows track with same name looks like:
| id | type | name | source_arg_set_id |
|---|---|---|---|
| 0 | process_track | [NULL] | [NULL] |
| 1 | thread_track | [NULL] | [NULL] |
| 2 | process_track | DrawGamediff | 4 |
| 3 | process_track | DrawGamediff | 5 |
| 4 | process_track | DrawGamediff | 6 |
| 5 | process_track | DrawGamediff | 7 |
| 6 | process_track | DrawGamediff | 8 |
| 7 | process_track | DrawGamediff | 9 |
| 8 | process_track | DrawGamediff | 10 |
and perfetoo UI only see one track line with name "DrawGamediff", is this expected? is it possible to set track id or track name from interface?
Thanks, Dion
// auto desc = track.Serialize(); // desc.set_name("MyTrack"); // perfetto::TrackEvent::SetTrackDescriptor(track, desc);
@betasheet or @chromy might remember what's the current state of UI when multiple tracks are used.
P.S. most of the team is out throughout the rest of Dec, so nobody might reply to this until Jan 2021.
Currently we visually merge "async" tracks with the same name into one track in the UI to reduce the vertical space taken up by the events. If you don't specify a TrackDescriptor, your tracks obtain their names from the first event on the track. To give them different names, you can register a TrackDescriptor with the SDK via the APIs in include/perfetto/tracing/track.h, e.g.:
auto track = perfetto::Track(1);
auto desc = track.Serialize();
desc.set_name("MyTrack 1");
perfetto::TrackEvent::SetTrackDescriptor(track, desc);
You only have to register each TrackDescriptor once.
Thanks betasheet.