Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e7c3660

Browse files
committed
Handle breaking change to Dart_TimelineEvent Embedder API
This CL handles the changes made to Dart_TimelineEvent in https://dart-review.googlesource.com/c/sdk/+/302963
1 parent 59dfac7 commit e7c3660

15 files changed

+269
-72
lines changed

flow/frame_timings.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
#include "flutter/fml/time/time_delta.h"
1515
#include "flutter/fml/time/time_point.h"
1616

17-
#define TRACE_EVENT_WITH_FRAME_NUMBER(recorder, category_group, name) \
18-
TRACE_EVENT1(category_group, name, "frame_number", \
19-
recorder->GetFrameNumberTraceArg())
17+
#define TRACE_EVENT_WITH_FRAME_NUMBER(recorder, category_group, name, \
18+
flow_id_count, flow_ids) \
19+
TRACE_EVENT1_WITH_FLOW_IDS(category_group, name, flow_id_count, flow_ids, \
20+
"frame_number", \
21+
recorder->GetFrameNumberTraceArg())
2022

2123
namespace flutter {
2224

fml/trace_event.cc

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ std::atomic<TimelineMicrosSource> gTimelineMicrosSource = DefaultMicrosSource;
3030
inline void FlutterTimelineEvent(const char* label,
3131
int64_t timestamp0,
3232
int64_t timestamp1_or_async_id,
33+
intptr_t flow_id_count,
34+
const int64_t* flow_ids,
3335
Dart_Timeline_Event_Type type,
3436
intptr_t argument_count,
3537
const char** argument_names,
3638
const char** argument_values) {
3739
TimelineEventHandler handler =
3840
gTimelineEventHandler.load(std::memory_order_relaxed);
3941
if (handler && gAllowlist.Query(label)) {
40-
handler(label, timestamp0, timestamp1_or_async_id, type, argument_count,
41-
argument_names, argument_values);
42+
handler(label, timestamp0, timestamp1_or_async_id, flow_id_count, flow_ids,
43+
type, argument_count, argument_names, argument_values);
4244
}
4345
}
4446
} // namespace
@@ -73,6 +75,8 @@ void TraceTimelineEvent(TraceArg category_group,
7375
TraceArg name,
7476
int64_t timestamp_micros,
7577
TraceIDArg identifier,
78+
size_t flow_id_count,
79+
const uint64_t* flow_ids,
7680
Dart_Timeline_Event_Type type,
7781
const std::vector<const char*>& c_names,
7882
const std::vector<std::string>& values) {
@@ -86,36 +90,47 @@ void TraceTimelineEvent(TraceArg category_group,
8690
}
8791

8892
FlutterTimelineEvent(
89-
name, // label
90-
timestamp_micros, // timestamp0
91-
identifier, // timestamp1_or_async_id
92-
type, // event type
93-
argument_count, // argument_count
94-
const_cast<const char**>(c_names.data()), // argument_names
95-
c_values.data() // argument_values
93+
name, // label
94+
timestamp_micros, // timestamp0
95+
identifier, // timestamp1_or_async_id
96+
flow_id_count, // flow_id_count
97+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
98+
type, // event type
99+
argument_count, // argument_count
100+
const_cast<const char**>(c_names.data()), // argument_names
101+
c_values.data() // argument_values
96102
);
97103
}
98104

99105
void TraceTimelineEvent(TraceArg category_group,
100106
TraceArg name,
101107
TraceIDArg identifier,
108+
size_t flow_id_count,
109+
const uint64_t* flow_ids,
102110
Dart_Timeline_Event_Type type,
103111
const std::vector<const char*>& c_names,
104112
const std::vector<std::string>& values) {
105113
TraceTimelineEvent(category_group, // group
106114
name, // name
107115
gTimelineMicrosSource.load()(), // timestamp_micros
108116
identifier, // identifier
117+
flow_id_count, // flow_id_count
118+
flow_ids, // flow_ids
109119
type, // type
110120
c_names, // names
111121
values // values
112122
);
113123
}
114124

115-
void TraceEvent0(TraceArg category_group, TraceArg name) {
125+
void TraceEvent0(TraceArg category_group,
126+
TraceArg name,
127+
size_t flow_id_count,
128+
const uint64_t* flow_ids) {
116129
FlutterTimelineEvent(name, // label
117130
gTimelineMicrosSource.load()(), // timestamp0
118-
0, // timestamp1_or_async_id
131+
0, // timestamp1_or_async_id
132+
flow_id_count, // flow_id_count
133+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
119134
Dart_Timeline_Event_Begin, // event type
120135
0, // argument_count
121136
nullptr, // argument_names
@@ -125,13 +140,17 @@ void TraceEvent0(TraceArg category_group, TraceArg name) {
125140

126141
void TraceEvent1(TraceArg category_group,
127142
TraceArg name,
143+
size_t flow_id_count,
144+
const uint64_t* flow_ids,
128145
TraceArg arg1_name,
129146
TraceArg arg1_val) {
130147
const char* arg_names[] = {arg1_name};
131148
const char* arg_values[] = {arg1_val};
132149
FlutterTimelineEvent(name, // label
133150
gTimelineMicrosSource.load()(), // timestamp0
134-
0, // timestamp1_or_async_id
151+
0, // timestamp1_or_async_id
152+
flow_id_count, // flow_id_count
153+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
135154
Dart_Timeline_Event_Begin, // event type
136155
1, // argument_count
137156
arg_names, // argument_names
@@ -141,6 +160,8 @@ void TraceEvent1(TraceArg category_group,
141160

142161
void TraceEvent2(TraceArg category_group,
143162
TraceArg name,
163+
size_t flow_id_count,
164+
const uint64_t* flow_ids,
144165
TraceArg arg1_name,
145166
TraceArg arg1_val,
146167
TraceArg arg2_name,
@@ -149,7 +170,9 @@ void TraceEvent2(TraceArg category_group,
149170
const char* arg_values[] = {arg1_val, arg2_val};
150171
FlutterTimelineEvent(name, // label
151172
gTimelineMicrosSource.load()(), // timestamp0
152-
0, // timestamp1_or_async_id
173+
0, // timestamp1_or_async_id
174+
flow_id_count, // flow_id_count
175+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
153176
Dart_Timeline_Event_Begin, // event type
154177
2, // argument_count
155178
arg_names, // argument_names
@@ -161,6 +184,8 @@ void TraceEventEnd(TraceArg name) {
161184
FlutterTimelineEvent(name, // label
162185
gTimelineMicrosSource.load()(), // timestamp0
163186
0, // timestamp1_or_async_id
187+
0, // flow_id_count
188+
nullptr, // flow_ids
164189
Dart_Timeline_Event_End, // event type
165190
0, // argument_count
166191
nullptr, // argument_names
@@ -170,10 +195,14 @@ void TraceEventEnd(TraceArg name) {
170195

171196
void TraceEventAsyncBegin0(TraceArg category_group,
172197
TraceArg name,
173-
TraceIDArg id) {
198+
TraceIDArg id,
199+
size_t flow_id_count,
200+
const uint64_t* flow_ids) {
174201
FlutterTimelineEvent(name, // label
175202
gTimelineMicrosSource.load()(), // timestamp0
176-
id, // timestamp1_or_async_id
203+
id, // timestamp1_or_async_id
204+
flow_id_count, // flow_id_count
205+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
177206
Dart_Timeline_Event_Async_Begin, // event type
178207
0, // argument_count
179208
nullptr, // argument_names
@@ -187,6 +216,8 @@ void TraceEventAsyncEnd0(TraceArg category_group,
187216
FlutterTimelineEvent(name, // label
188217
gTimelineMicrosSource.load()(), // timestamp0
189218
id, // timestamp1_or_async_id
219+
0, // flow_id_count
220+
nullptr, // flow_ids
190221
Dart_Timeline_Event_Async_End, // event type
191222
0, // argument_count
192223
nullptr, // argument_names
@@ -197,13 +228,17 @@ void TraceEventAsyncEnd0(TraceArg category_group,
197228
void TraceEventAsyncBegin1(TraceArg category_group,
198229
TraceArg name,
199230
TraceIDArg id,
231+
size_t flow_id_count,
232+
const uint64_t* flow_ids,
200233
TraceArg arg1_name,
201234
TraceArg arg1_val) {
202235
const char* arg_names[] = {arg1_name};
203236
const char* arg_values[] = {arg1_val};
204237
FlutterTimelineEvent(name, // label
205238
gTimelineMicrosSource.load()(), // timestamp0
206-
id, // timestamp1_or_async_id
239+
id, // timestamp1_or_async_id
240+
flow_id_count, // flow_id_count
241+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
207242
Dart_Timeline_Event_Async_Begin, // event type
208243
1, // argument_count
209244
arg_names, // argument_names
@@ -221,17 +256,24 @@ void TraceEventAsyncEnd1(TraceArg category_group,
221256
FlutterTimelineEvent(name, // label
222257
gTimelineMicrosSource.load()(), // timestamp0
223258
id, // timestamp1_or_async_id
259+
0, // flow_id_count
260+
nullptr, // flow_ids
224261
Dart_Timeline_Event_Async_End, // event type
225262
1, // argument_count
226263
arg_names, // argument_names
227264
arg_values // argument_values
228265
);
229266
}
230267

231-
void TraceEventInstant0(TraceArg category_group, TraceArg name) {
268+
void TraceEventInstant0(TraceArg category_group,
269+
TraceArg name,
270+
size_t flow_id_count,
271+
const uint64_t* flow_ids) {
232272
FlutterTimelineEvent(name, // label
233273
gTimelineMicrosSource.load()(), // timestamp0
234-
0, // timestamp1_or_async_id
274+
0, // timestamp1_or_async_id
275+
flow_id_count, // flow_id_count
276+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
235277
Dart_Timeline_Event_Instant, // event type
236278
0, // argument_count
237279
nullptr, // argument_names
@@ -241,13 +283,17 @@ void TraceEventInstant0(TraceArg category_group, TraceArg name) {
241283

242284
void TraceEventInstant1(TraceArg category_group,
243285
TraceArg name,
286+
size_t flow_id_count,
287+
const uint64_t* flow_ids,
244288
TraceArg arg1_name,
245289
TraceArg arg1_val) {
246290
const char* arg_names[] = {arg1_name};
247291
const char* arg_values[] = {arg1_val};
248292
FlutterTimelineEvent(name, // label
249293
gTimelineMicrosSource.load()(), // timestamp0
250-
0, // timestamp1_or_async_id
294+
0, // timestamp1_or_async_id
295+
flow_id_count, // flow_id_count
296+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
251297
Dart_Timeline_Event_Instant, // event type
252298
1, // argument_count
253299
arg_names, // argument_names
@@ -257,6 +303,8 @@ void TraceEventInstant1(TraceArg category_group,
257303

258304
void TraceEventInstant2(TraceArg category_group,
259305
TraceArg name,
306+
size_t flow_id_count,
307+
const uint64_t* flow_ids,
260308
TraceArg arg1_name,
261309
TraceArg arg1_val,
262310
TraceArg arg2_name,
@@ -265,7 +313,9 @@ void TraceEventInstant2(TraceArg category_group,
265313
const char* arg_values[] = {arg1_val, arg2_val};
266314
FlutterTimelineEvent(name, // label
267315
gTimelineMicrosSource.load()(), // timestamp0
268-
0, // timestamp1_or_async_id
316+
0, // timestamp1_or_async_id
317+
flow_id_count, // flow_id_count
318+
reinterpret_cast<const int64_t*>(flow_ids), // flow_ids
269319
Dart_Timeline_Event_Instant, // event type
270320
2, // argument_count
271321
arg_names, // argument_names
@@ -278,7 +328,9 @@ void TraceEventFlowBegin0(TraceArg category_group,
278328
TraceIDArg id) {
279329
FlutterTimelineEvent(name, // label
280330
gTimelineMicrosSource.load()(), // timestamp0
281-
id, // timestamp1_or_async_id
331+
id, // timestamp1_or_async_id
332+
0, // flow_id_count
333+
nullptr, // flow_ids
282334
Dart_Timeline_Event_Flow_Begin, // event type
283335
0, // argument_count
284336
nullptr, // argument_names
@@ -292,6 +344,8 @@ void TraceEventFlowStep0(TraceArg category_group,
292344
FlutterTimelineEvent(name, // label
293345
gTimelineMicrosSource.load()(), // timestamp0
294346
id, // timestamp1_or_async_id
347+
0, // flow_id_count
348+
nullptr, // flow_ids
295349
Dart_Timeline_Event_Flow_Step, // event type
296350
0, // argument_count
297351
nullptr, // argument_names
@@ -303,6 +357,8 @@ void TraceEventFlowEnd0(TraceArg category_group, TraceArg name, TraceIDArg id) {
303357
FlutterTimelineEvent(name, // label
304358
gTimelineMicrosSource.load()(), // timestamp0
305359
id, // timestamp1_or_async_id
360+
0, // flow_id_count
361+
nullptr, // flow_ids
306362
Dart_Timeline_Event_Flow_End, // event type
307363
0, // argument_count
308364
nullptr, // argument_names

0 commit comments

Comments
 (0)