Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#9,747 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

  • #9756 來自 @rishika0212 —— 已關閉,未合併

評估

難度
3/5
預估耗時
1-2 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
dart

研究方向

按照報告中的中斷點和 CPU 分析步驟,使用 bin/main.dart 和 test/cpu_profile_test.dart 重現此問題。首先追蹤 DevTools 如何連線到測試執行並選取一個 isolate;當對測試執行進行分析能夠擷取 cpu_profile.calculate() 中的工作,並顯示如同獨立程式的資料時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

devtools-cross-screen P2

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

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

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

lib/cpu_profile.dart

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

test/cpu_profile_test.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
主要語言
Dart
星號
1.7k
分支
407
平均合併
3 天 14 小時
30 天內合併 PR
15

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

flutter/devtools 的其他 Issue

查看 flutter/devtools 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。