flutter / flutter/devtools

Can't record past event using the dart:developer Timeline and TimelineTask APIs

Ouverte
#5,835 21 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
P2 performance > perfetto
Langage dominant
Dart
Étoiles
1.7k
Forks
404
Merge moyen
6 j 17 h
PR mergées (30 j)
18

Description

I thought it would be useful to be able to use the DevTools performance page for debugging performance issues with the analysis server. The server already has some classes that record performance internally that map fairly closely onto the TimelineTask class used for the Performance page.

However, when using it I can't get the parent/child relationship to show up in the graphs so it's a little tricky to follow what's happening.

It's possible I'm using it wrong (or have the wrong expectations).

Here's a small repro. The code just runs some nested async tasks, and uses `TimelineTask` to record them. Each nested task has its `parent` provided.

```dart
import 'dart:developer';

const levelNames = ['zero', 'one', 'two', 'three', 'four', 'five'];

Future main() async {
print('Open DevTols performance page, filter to just Dart events, '
'then resume, wait for break, click Refresh');
debugger();

var rootTask = TimelineTask();
rootTask.start('root');
await doWork(1, rootTask);
rootTask.finish();

debugger();
}

Future doWork(int level, TimelineTask parent) async {
final task = TimelineTask(parent: parent);
task.start('level ${levelNames[level]}');
await Future.delayed(const Duration(milliseconds: 200));

if (level < 5) {
await doWork(level + 1, task);
}
task.finish();
}
```

When I review this in the performance page, it looks like this (both the new and legacy views are essentially the same):

![Screenshot 2023-05-22 at 14 53 44](https://github.com/flutter/devtools/assets/1078012/cf38f6a1-b67f-4a67-8297-b73031e52c4d)

The top-to-bottom ordering of the categories is not as I'd expect (it looks alphabetical), and there's no indication of which bars are children of other bars (although it's fairly clear in this case, when each async tasks have `await`s that could allow other code to run, this relationship would be important).

I was expecting/hoping for it to look more like this chart from the docs page:

![image](https://github.com/flutter/devtools/assets/1078012/f7b38ee3-2cab-467f-949a-f5e33f761fe8)

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.