flutter / flutter/devtools

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

Aperta
#5,835 21 commenti 0 reazioni 0 assegnatari Vedi su GitHub
P2 performance > perfetto
Lingua principale
Dart
Stelle
1.7k
Fork
404
Merge medio
6g 17h
PR unite (30g)
18

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the dart:developer Timeline and TimelineTask APIs and the nested async repro in the issue, then inspect the DevTools Performance page in both new and legacy views. Done means the resulting trace presents the TimelineTask parent/child relationships and ordering as expected, or clearly documents the supported behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
dart
Ambito
observability, performance, tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.