perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

TRACE_EVENT_BEGIN with track id doesn't work well with perfetto UI

Open dionysus1016 opened this issue 5 years ago • 4 comments

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

dionysus1016 avatar Dec 12 '20 05:12 dionysus1016

// auto desc = track.Serialize(); // desc.set_name("MyTrack"); // perfetto::TrackEvent::SetTrackDescriptor(track, desc);

dionysus1016 avatar Dec 12 '20 08:12 dionysus1016

@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.

primiano avatar Dec 14 '20 15:12 primiano

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.

betasheet avatar Dec 17 '20 10:12 betasheet

Thanks betasheet.

dionysus1016 avatar Dec 19 '20 09:12 dionysus1016