5#include "flutter/fml/trace_event.h"
11#include "flutter/fml/ascii_trie.h"
12#include "flutter/fml/build_config.h"
13#include "flutter/fml/logging.h"
18#if FLUTTER_TIMELINE_ENABLED
22int64_t DefaultMicrosSource() {
27std::atomic<TimelineEventHandler> gTimelineEventHandler;
28std::atomic<TimelineMicrosSource> gTimelineMicrosSource = DefaultMicrosSource;
30inline void FlutterTimelineEvent(
const char* label,
32 int64_t timestamp1_or_async_id,
33 intptr_t flow_id_count,
34 const int64_t* flow_ids,
37 const char** argument_names,
38 const char** argument_values) {
40 gTimelineEventHandler.load(std::memory_order_relaxed);
41 if (handler && gAllowlist.
Query(label)) {
42 handler(label, timestamp0, timestamp1_or_async_id, flow_id_count, flow_ids,
53 gTimelineEventHandler = handler;
57 return static_cast<bool>(
58 gTimelineEventHandler.load(std::memory_order_relaxed));
62 return gTimelineMicrosSource.load()();
66 gTimelineMicrosSource =
source;
70 static std::atomic_size_t last_item;
76 int64_t timestamp_micros,
79 const uint64_t* flow_ids,
81 const std::vector<const char*>& c_names,
82 const std::vector<std::string>&
values) {
85 std::vector<const char*> c_values;
97 reinterpret_cast<const int64_t*
>(flow_ids),
100 const_cast<const char**
>(c_names.data()),
108 size_t flow_id_count,
109 const uint64_t* flow_ids,
111 const std::vector<const char*>& c_names,
112 const std::vector<std::string>&
values) {
115 gTimelineMicrosSource.load()(),
127 size_t flow_id_count,
128 const uint64_t* flow_ids) {
129 FlutterTimelineEvent(
name,
130 gTimelineMicrosSource.load()(),
133 reinterpret_cast<const int64_t*
>(flow_ids),
143 size_t flow_id_count,
144 const uint64_t* flow_ids,
147 const char* arg_names[] = {arg1_name};
148 const char* arg_values[] = {arg1_val};
149 FlutterTimelineEvent(
name,
150 gTimelineMicrosSource.load()(),
153 reinterpret_cast<const int64_t*
>(flow_ids),
163 size_t flow_id_count,
164 const uint64_t* flow_ids,
169 const char* arg_names[] = {arg1_name, arg2_name};
170 const char* arg_values[] = {arg1_val, arg2_val};
171 FlutterTimelineEvent(
name,
172 gTimelineMicrosSource.load()(),
175 reinterpret_cast<const int64_t*
>(flow_ids),
184 FlutterTimelineEvent(
name,
185 gTimelineMicrosSource.load()(),
199 size_t flow_id_count,
200 const uint64_t* flow_ids) {
201 FlutterTimelineEvent(
name,
202 gTimelineMicrosSource.load()(),
205 reinterpret_cast<const int64_t*
>(flow_ids),
216 FlutterTimelineEvent(
name,
217 gTimelineMicrosSource.load()(),
231 size_t flow_id_count,
232 const uint64_t* flow_ids,
235 const char* arg_names[] = {arg1_name};
236 const char* arg_values[] = {arg1_val};
237 FlutterTimelineEvent(
name,
238 gTimelineMicrosSource.load()(),
241 reinterpret_cast<const int64_t*
>(flow_ids),
254 const char* arg_names[] = {arg1_name};
255 const char* arg_values[] = {arg1_val};
256 FlutterTimelineEvent(
name,
257 gTimelineMicrosSource.load()(),
270 size_t flow_id_count,
271 const uint64_t* flow_ids) {
272 FlutterTimelineEvent(
name,
273 gTimelineMicrosSource.load()(),
276 reinterpret_cast<const int64_t*
>(flow_ids),
286 size_t flow_id_count,
287 const uint64_t* flow_ids,
290 const char* arg_names[] = {arg1_name};
291 const char* arg_values[] = {arg1_val};
292 FlutterTimelineEvent(
name,
293 gTimelineMicrosSource.load()(),
296 reinterpret_cast<const int64_t*
>(flow_ids),
306 size_t flow_id_count,
307 const uint64_t* flow_ids,
312 const char* arg_names[] = {arg1_name, arg2_name};
313 const char* arg_values[] = {arg1_val, arg2_val};
314 FlutterTimelineEvent(
name,
315 gTimelineMicrosSource.load()(),
318 reinterpret_cast<const int64_t*
>(flow_ids),
329 FlutterTimelineEvent(
name,
330 gTimelineMicrosSource.load()(),
344 FlutterTimelineEvent(
name,
345 gTimelineMicrosSource.load()(),
357 FlutterTimelineEvent(
name,
358 gTimelineMicrosSource.load()(),
391 int64_t timestamp_micros,
393 size_t flow_id_count,
394 const uint64_t* flow_ids,
396 const std::vector<const char*>& c_names,
397 const std::vector<std::string>&
values) {}
402 size_t flow_id_count,
403 const uint64_t* flow_ids,
405 const std::vector<const char*>& c_names,
406 const std::vector<std::string>&
values) {}
410 size_t flow_id_count,
411 const uint64_t* flow_ids) {}
415 size_t flow_id_count,
416 const uint64_t* flow_ids,
422 size_t flow_id_count,
423 const uint64_t* flow_ids,
439 size_t flow_id_count,
440 const uint64_t* flow_ids) {}
449 size_t flow_id_count,
450 const uint64_t* flow_ids,
462 size_t flow_id_count,
463 const uint64_t* flow_ids) {}
467 size_t flow_id_count,
468 const uint64_t* flow_ids,
474 size_t flow_id_count,
475 const uint64_t* flow_ids,
A trie for looking for ASCII prefixes.
bool Query(const char *argument)
Returns true if argument is prefixed by the contents of the trie.
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
static const char * begin(const StringSlice &s)
static float min(float r, float g, float b)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap The size limit in megabytes for the Dart VM old gen heap space enable Enable the Impeller renderer on supported platforms Ignored if Impeller is not supported on the platform enable vulkan Enable loading Vulkan validation layers The layers must be available to the application and loadable On non Vulkan this flag does nothing enable vulkan gpu tracing
DEF_SWITCHES_START aot vmservice shared library name
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia allowlist
void TraceEventFlowEnd0(TraceArg category_group, TraceArg name, TraceIDArg id)
void TraceEventInstant0(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids)
void TraceEventFlowBegin0(TraceArg category_group, TraceArg name, TraceIDArg id)
bool TraceHasTimelineEventHandler()
void TraceEventAsyncBegin0(TraceArg category_group, TraceArg name, TraceIDArg id, size_t flow_id_count, const uint64_t *flow_ids)
void TraceSetAllowlist(const std::vector< std::string > &allowlist)
void TraceEventAsyncEnd0(TraceArg category_group, TraceArg name, TraceIDArg id)
void TraceEvent0(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids)
void TraceEventInstant1(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids, TraceArg arg1_name, TraceArg arg1_val)
int64_t(*)() TimelineMicrosSource
void TraceEventAsyncBegin1(TraceArg category_group, TraceArg name, TraceIDArg id, size_t flow_id_count, const uint64_t *flow_ids, TraceArg arg1_name, TraceArg arg1_val)
void TraceTimelineEvent(TraceArg category_group, TraceArg name, int64_t timestamp_micros, TraceIDArg identifier, size_t flow_id_count, const uint64_t *flow_ids, Dart_Timeline_Event_Type type, const std::vector< const char * > &c_names, const std::vector< std::string > &values)
void TraceSetTimelineEventHandler(TimelineEventHandler handler)
void TraceSetTimelineMicrosSource(TimelineMicrosSource source)
void TraceEvent2(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids, TraceArg arg1_name, TraceArg arg1_val, TraceArg arg2_name, TraceArg arg2_val)
void TraceEventAsyncEnd1(TraceArg category_group, TraceArg name, TraceIDArg id, TraceArg arg1_name, TraceArg arg1_val)
void TraceEventEnd(TraceArg name)
void TraceEventInstant2(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids, TraceArg arg1_name, TraceArg arg1_val, TraceArg arg2_name, TraceArg arg2_val)
int64_t TraceGetTimelineMicros()
void TraceEvent1(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids, TraceArg arg1_name, TraceArg arg1_val)
void(* TimelineEventHandler)(const char *, int64_t, int64_t, intptr_t, const int64_t *, Dart_Timeline_Event_Type, intptr_t, const char **, const char **)
void TraceEventAsyncComplete(TraceArg category_group, TraceArg name, TimePoint begin, TimePoint end)
void TraceEventFlowStep0(TraceArg category_group, TraceArg name, TraceIDArg id)