Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
FlutterTracing.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERTRACING_H_
6#define FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERTRACING_H_
7
8#import <Foundation/Foundation.h>
9
11
12/**
13 * Provides utility methods to record tracing events to the Flutter timeline.
14 *
15 * This class wraps the C++ `fml/trace_event.h` macros, exposing them as Objective-C
16 * methods. It is used to instrument Objective-C and Swift code with duration
17 * events, asynchronous events, and custom flow events.
18 *
19 * Events recorded are sent to the Dart VM timeline and can be visualized using
20 * Flutter DevTools.
21 *
22 * In Swift, this class is available as `Tracing`.
23 */
24NS_SWIFT_NAME(Tracing)
25@interface FlutterTracing : NSObject
26
27- (instancetype)init NS_UNAVAILABLE;
28
29/**
30 * Traces a platform vsync event with the given start and target times.
31 *
32 * This method is used to instrument platform-specific vsync signals. It records the
33 * frame start time and target time to the timeline, converted to microseconds.
34 *
35 * @param startTime The start time of the vsync tick.
36 * @param targetTime The target time of the next vsync tick.
37 */
38+ (void)tracePlatformVsyncWithStartTime:(NSTimeInterval)startTime
39 targetTime:(NSTimeInterval)targetTime;
40
41/**
42 * Traces the beginning of an asynchronous event.
43 *
44 * Asynchronous events are used to trace operations that span multiple threads or
45 * are not bound to a single scope. Corresponding begin and end events must have
46 * matching names and event IDs.
47 *
48 * @param name The name of the event.
49 * @param eventID A unique identifier used to associate this begin event with its corresponding end
50 * event.
51 */
52+ (void)traceAsyncBegin:(NSString*)name eventID:(int64_t)eventID;
53
54/**
55 * Traces the end of an asynchronous event.
56 *
57 * Asynchronous events are used to trace operations that span multiple threads or
58 * are not bound to a single scope. Corresponding begin and end events must have
59 * matching names and event IDs.
60 *
61 * @param name The name of the event.
62 * @param eventID A unique identifier used to associate this end event with its corresponding begin
63 * event.
64 */
65+ (void)traceAsyncEnd:(NSString*)name eventID:(int64_t)eventID;
66
67/**
68 * Starts a thread-local manual tracing section.
69 *
70 * This is a low-level API. In Swift code, consider using `Tracing.withTrace` or
71 * `Tracing.beginScope` which are safer and more idiomatic.
72 *
73 * Every call to `beginSection:` must be paired with a corresponding call to
74 * `endSection:` with the matching name on the same thread.
75 *
76 * @param name The name of the tracing section.
77 */
78+ (void)beginSection:(NSString*)name;
79
80/**
81 * Ends a thread-local manual tracing section.
82 *
83 * This must be called to end a section started by `beginSection:` with the matching name.
84 *
85 * @param name The name of the tracing section.
86 */
87+ (void)endSection:(NSString*)name;
88
89@end
90
92
93#endif // FLUTTER_SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERTRACING_H_
#define NS_ASSUME_NONNULL_BEGIN
#define NS_ASSUME_NONNULL_END
instancetype init NS_UNAVAILABLE