@@ -127,7 +127,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
127
127
SchedulerBinding .instance.addPostFrameCallback ((timeStamp) {
128
128
approximationEndTimestamp = DateTime .now ();
129
129
approximationDurationMillis =
130
- approximationEndTimestamp! .millisecond - startTime.millisecond ;
130
+ approximationEndTimestamp! .millisecondsSinceEpoch - startTime.millisecondsSinceEpoch ;
131
131
});
132
132
133
133
SentryDisplayTracker ().startTimeout (routeName ?? 'Unknown' , () {
@@ -139,6 +139,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
139
139
'time_to_initial_display' , approximationDurationMillis! ,
140
140
unit: DurationSentryMeasurementUnit .milliSecond);
141
141
ttidSpan? .finish (endTimestamp: approximationEndTimestamp! );
142
+ print ('finished already' );
142
143
});
143
144
}
144
145
@@ -276,17 +277,29 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
276
277
return ;
277
278
}
278
279
279
- startTime = DateTime .now ();
280
- ttidSpan = _transaction2? .startChild ('ui.load.initial_display' , description: '$name initial display' );
281
- ttidSpan? .origin = 'auto.ui.time_to_display' ;
280
+ if (name == 'root ("/")' ) {
281
+ // root ttid spans have to align with app start
282
+ // so the ttid instrumentation needs to be different here.
283
+ startTime = DateTime .now ();
284
+ ttidSpan = _transaction2? .startChild ('ui.load.initial_display' , description: '$name initial display' , startTimestamp: startTime);
285
+ ttidSpan? .origin = 'auto.ui.time_to_display' ;
286
+ } else {
287
+ startTime = DateTime .now ();
288
+ ttidSpan = _transaction2? .startChild ('ui.load.initial_display' , description: '$name initial display' , startTimestamp: startTime);
289
+ ttidSpan? .origin = 'auto.ui.time_to_display' ;
290
+ }
282
291
283
292
// TODO: Needs to finish max within 30 seconds
284
293
// If timeout exceeds then it will finish with status deadline exceeded
285
294
// What to do if root also has TTFD but it's not finished yet and we start navigating to another?
286
295
// How to track the time that 30 sec have passed?
296
+ //
297
+ // temporarily disable ttfd for root since it somehow swallows other spans
298
+ // e.g the complex operation span in autoclosescreen
287
299
if ((_hub.options as SentryFlutterOptions ).enableTimeToFullDisplayTracing && name != 'root ("/")' ) {
288
300
ttfdStopwatch = Stopwatch ()..start ();
289
- ttfdSpan = _transaction2? .startChild ('ui.load.full_display' , description: '$name full display' );
301
+ ttfdStartTime = DateTime .now ();
302
+ ttfdSpan = _transaction2? .startChild ('ui.load.full_display' , description: '$name full display' , startTimestamp: ttfdStartTime);
290
303
}
291
304
292
305
if (arguments != null ) {
0 commit comments