flutter / flutter/devtools

Automatically select main isolate instead of the test runner isolate when connecting to test runs

Đang mở
#9,747 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
cross-screen P2
Ngôn ngữ chính
Dart
Star
1.7k
Fork
404
Merge trung bình
6 ngày 17 giờ
Pull request đã merge (30 ngày)
18

Mô tả

I don't know if this is a DevTools issue or something else, but I'm also not sure how to determine which.

When running tests, CPU profiling never seems to collect any data. For example given a sample project with a `bin/main.dart` that calls a function in `lib` that blocks for 5s, and a test that does the same:

## bin/main.dart

```dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;

void main(List arguments) {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
}
```

## lib/cpu_profile.dart

```dart
int calculate() {
var start = DateTime.now();
while (start.difference(DateTime.now()).inSeconds.abs() < 5) {}
return 6 * 7;
}
```

## test/cpu_profile_test.dart

```dart
import 'package:cpu_profile/cpu_profile.dart' as cpu_profile;
import 'package:test/test.dart';

void main() {
test('calculate', () {
print('starting'); // breakpoint
cpu_profile.calculate();
print('done!'); // breakpoint
});
}
```

For `bin/main.dart`:

- Open `bin/main.dart`
- Add breakpoints on the marked lines
- Run in debug mode and hit the first breakpoint
- Open DevTools CPU profile, enable profiling, and start recording
- Resume execution and wait for it to hit the second breakpoint
- Stop CPU profiling and observe the results

Image

Perform the same steps but using the test instead, and the profiler doesn't show any data:

Image

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Reproduce the issue with bin/main.dart and test/cpu_profile_test.dart, following the breakpoint and CPU profiling steps in the report. Start by tracing how DevTools connects to a test run and selects an isolate; done means profiling the test run captures the work in cpu_profile.calculate() and shows data like the standalone program.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
dart
Lĩnh vực
devtools, performance, testing
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.