Skip to content

Commit e8c13aa

Browse files
Disable event tracing templates in release mode (flutter#18855)
1 parent e356b06 commit e8c13aa

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

fml/trace_event.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@
1212
#include "flutter/fml/build_config.h"
1313
#include "flutter/fml/logging.h"
1414

15-
#if (FLUTTER_RELEASE && !defined(OS_FUCHSIA))
16-
#define TIMELINE_ENABLED 0
17-
#else
18-
#define TIMELINE_ENABLED 1
19-
#endif
20-
2115
namespace fml {
2216
namespace tracing {
2317

24-
#if TIMELINE_ENABLED
18+
#if FLUTTER_TIMELINE_ENABLED
2519

2620
namespace {
2721
AsciiTrie gWhitelist;
@@ -290,7 +284,7 @@ void TraceEventFlowEnd0(TraceArg category_group, TraceArg name, TraceIDArg id) {
290284
);
291285
}
292286

293-
#else // TIMELINE_ENABLED
287+
#else // FLUTTER_TIMELINE_ENABLED
294288

295289
void TraceSetWhitelist(const std::vector<std::string>& whitelist) {}
296290

@@ -379,7 +373,7 @@ void TraceEventFlowStep0(TraceArg category_group,
379373
void TraceEventFlowEnd0(TraceArg category_group, TraceArg name, TraceIDArg id) {
380374
}
381375

382-
#endif // TIMELINE_ENABLED
376+
#endif // FLUTTER_TIMELINE_ENABLED
383377

384378
} // namespace tracing
385379
} // namespace fml

fml/trace_event.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
#include "flutter/fml/time/time_point.h"
4646
#include "third_party/dart/runtime/include/dart_tools_api.h"
4747

48+
#if (FLUTTER_RELEASE && !defined(OS_FUCHSIA))
49+
#define FLUTTER_TIMELINE_ENABLED 0
50+
#else
51+
#define FLUTTER_TIMELINE_ENABLED 1
52+
#endif
53+
4854
#if !defined(OS_FUCHSIA)
4955
#ifndef TRACE_EVENT_HIDE_MACROS
5056

@@ -193,9 +199,11 @@ void TraceCounter(TraceArg category,
193199
TraceArg name,
194200
TraceIDArg identifier,
195201
Args... args) {
202+
#if FLUTTER_TIMELINE_ENABLED
196203
auto split = SplitArguments(args...);
197204
TraceTimelineEvent(category, name, identifier, Dart_Timeline_Event_Counter,
198205
split.first, split.second);
206+
#endif // FLUTTER_TIMELINE_ENABLED
199207
}
200208

201209
// HACK: Used to NOP FML_TRACE_COUNTER macro without triggering unused var
@@ -208,9 +216,11 @@ void TraceCounterNopHACK(TraceArg category,
208216

209217
template <typename... Args>
210218
void TraceEvent(TraceArg category, TraceArg name, Args... args) {
219+
#if FLUTTER_TIMELINE_ENABLED
211220
auto split = SplitArguments(args...);
212221
TraceTimelineEvent(category, name, 0, Dart_Timeline_Event_Begin, split.first,
213222
split.second);
223+
#endif // FLUTTER_TIMELINE_ENABLED
214224
}
215225

216226
void TraceEvent0(TraceArg category_group, TraceArg name);
@@ -235,6 +245,7 @@ void TraceEventAsyncComplete(TraceArg category_group,
235245
TimePoint begin,
236246
TimePoint end,
237247
Args... args) {
248+
#if FLUTTER_TIMELINE_ENABLED
238249
auto identifier = TraceNonce();
239250
const auto split = SplitArguments(args...);
240251

@@ -262,6 +273,7 @@ void TraceEventAsyncComplete(TraceArg category_group,
262273
split.first, // names
263274
split.second // values
264275
);
276+
#endif // FLUTTER_TIMELINE_ENABLED
265277
}
266278

267279
void TraceEventAsyncBegin0(TraceArg category_group,

0 commit comments

Comments
 (0)