Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterTracing Class Reference

#include <FlutterTracing.h>

Inheritance diagram for FlutterTracing:

Instance Methods

(instancetype) - NS_UNAVAILABLE
 

Class Methods

(void) + tracePlatformVsyncWithStartTime:targetTime:
 
(void) + traceAsyncBegin:eventID:
 
(void) + traceAsyncEnd:eventID:
 
(void) + beginSection:
 
(void) + endSection:
 

Detailed Description

Provides utility methods to record tracing events to the Flutter timeline.

This class wraps the C++ fml/trace_event.h macros, exposing them as Objective-C methods. It is used to instrument Objective-C and Swift code with duration events, asynchronous events, and custom flow events.

Events recorded are sent to the Dart VM timeline and can be visualized using Flutter DevTools.

In Swift, this class is available as Tracing.

Definition at line 25 of file FlutterTracing.h.

Method Documentation

◆ beginSection:

+ (void) beginSection: (NSString*)  name

Starts a thread-local manual tracing section.

This is a low-level API. In Swift code, consider using Tracing.withTrace or Tracing.beginScope which are safer and more idiomatic.

Every call to beginSection: must be paired with a corresponding call to endSection: with the matching name on the same thread.

Parameters
nameThe name of the tracing section.

Definition at line 10 of file FlutterTracing.mm.

30 :(NSString*)name {
31 ::fml::tracing::TraceEvent0("flutter", [name UTF8String] ?: "", 0, nullptr);
32}
const char * name
Definition fuchsia.cc:50
void TraceEvent0(TraceArg category_group, TraceArg name, size_t flow_id_count, const uint64_t *flow_ids)

References TRACE_EVENT2_INT.

◆ endSection:

+ (void) endSection: (NSString*)  name

Ends a thread-local manual tracing section.

This must be called to end a section started by beginSection: with the matching name.

Parameters
nameThe name of the tracing section.

Definition at line 10 of file FlutterTracing.mm.

34 :(NSString*)name {
35 ::fml::tracing::TraceEventEnd([name UTF8String] ?: "");
36}
void TraceEventEnd(TraceArg name)

◆ NS_UNAVAILABLE

- (instancetype) NS_UNAVAILABLE

◆ traceAsyncBegin:eventID:

+ (void) traceAsyncBegin: (NSString*)  name
eventID: (int64_t)  eventID 

Traces the beginning of an asynchronous event.

Asynchronous events are used to trace operations that span multiple threads or are not bound to a single scope. Corresponding begin and end events must have matching names and event IDs.

Parameters
nameThe name of the event.
eventIDA unique identifier used to associate this begin event with its corresponding end event.

Definition at line 10 of file FlutterTracing.mm.

22 :(NSString*)name eventID:(int64_t)eventID {
23 TRACE_EVENT_ASYNC_BEGIN0("flutter", [name UTF8String] ?: "", eventID);
24}
#define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id)

◆ traceAsyncEnd:eventID:

+ (void) traceAsyncEnd: (NSString*)  name
eventID: (int64_t)  eventID 

Traces the end of an asynchronous event.

Asynchronous events are used to trace operations that span multiple threads or are not bound to a single scope. Corresponding begin and end events must have matching names and event IDs.

Parameters
nameThe name of the event.
eventIDA unique identifier used to associate this end event with its corresponding begin event.

Definition at line 10 of file FlutterTracing.mm.

26 :(NSString*)name eventID:(int64_t)eventID {
27 TRACE_EVENT_ASYNC_END0("flutter", [name UTF8String] ?: "", eventID);
28}
#define TRACE_EVENT_ASYNC_END0(category_group, name, id)

◆ tracePlatformVsyncWithStartTime:targetTime:

+ (void) tracePlatformVsyncWithStartTime: (NSTimeInterval)  startTime
targetTime: (NSTimeInterval)  targetTime 

Traces a platform vsync event with the given start and target times.

This method is used to instrument platform-specific vsync signals. It records the frame start time and target time to the timeline, converted to microseconds.

Parameters
startTimeThe start time of the vsync tick.
targetTimeThe target time of the next vsync tick.

Definition at line 10 of file FlutterTracing.mm.

14 :(NSTimeInterval)startTime
15 targetTime:(NSTimeInterval)targetTime {
16 int64_t startTimeMicroseconds = (int64_t)(startTime * 1000000);
17 int64_t targetTimeMicroseconds = (int64_t)(targetTime * 1000000);
18 TRACE_EVENT2_INT("flutter", "PlatformVsync", "frame_start_time", startTimeMicroseconds,
19 "frame_target_time", targetTimeMicroseconds);
20}
#define TRACE_EVENT2_INT(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)

The documentation for this class was generated from the following files: