From c19167c0c9abd960b74373e858a58f56898e6f28 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 27 Jul 2026 09:07:52 -0700 Subject: [PATCH 1/4] Trigger re-layout when resizing CPU flame chart --- packages/devtools_app/lib/src/shared/charts/flame_chart.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/devtools_app/lib/src/shared/charts/flame_chart.dart b/packages/devtools_app/lib/src/shared/charts/flame_chart.dart index bff073a30dd..bd51229539d 100644 --- a/packages/devtools_app/lib/src/shared/charts/flame_chart.dart +++ b/packages/devtools_app/lib/src/shared/charts/flame_chart.dart @@ -269,6 +269,10 @@ abstract class FlameChartState< verticalControllerGroup.resetScroll(); zoomController.reset(); verticalExtentDelegate.recompute(); + } else if (widget.containerWidth != oldWidget.containerWidth || + widget.containerHeight != oldWidget.containerHeight) { + initFlameChartElements(); + verticalExtentDelegate.recompute(); } FocusScope.of(context).requestFocus(focusNode); super.didUpdateWidget(oldWidget); From 4c71cb67431608d801cf89501793ca2692add79a Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 27 Jul 2026 09:55:25 -0700 Subject: [PATCH 2/4] test --- .../release_notes/NEXT_RELEASE_NOTES.md | 2 +- .../test/shared/charts/flame_chart_test.dart | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md index 8c84a48f832..799372e1905 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md @@ -27,7 +27,7 @@ TODO: Remove this section if there are not any updates. ## CPU profiler updates -TODO: Remove this section if there are not any updates. +- Fixed a bug where resizing the CPU flame chart changes the timing values across the top of the chart. [TODO](https://github.com/flutter/devtools/pull/TODO) ## Memory updates diff --git a/packages/devtools_app/test/shared/charts/flame_chart_test.dart b/packages/devtools_app/test/shared/charts/flame_chart_test.dart index e250a77aab5..228484c0c39 100644 --- a/packages/devtools_app/test/shared/charts/flame_chart_test.dart +++ b/packages/devtools_app/test/shared/charts/flame_chart_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd. import 'package:devtools_app/devtools_app.dart'; +import 'package:devtools_app/src/screens/profiler/cpu_profile_transformer.dart'; import 'package:devtools_app/src/screens/profiler/cpu_profiler_controller.dart'; import 'package:devtools_app/src/screens/profiler/panes/cpu_flame_chart.dart'; import 'package:devtools_app/src/shared/charts/flame_chart.dart'; @@ -624,6 +625,56 @@ void main() { ); }); }); + + testWidgets('re-lays out elements when container width changes', ( + WidgetTester tester, + ) async { + final transformer = CpuProfileTransformer(); + final cpuProfileData = CpuProfileData.fromJson(cpuProfileResponseJson); + await tester.runAsync(() async { + await transformer.processData(cpuProfileData, processId: 'test'); + }); + + flameChart = CpuProfileFlameChart( + data: cpuProfileData, + width: 1000.0, + height: 1000.0, + selectionNotifier: ValueNotifier(null), + searchMatchesNotifier: controller.searchMatches, + activeSearchMatchNotifier: controller.activeSearchMatch, + onDataSelected: (_) {}, + ); + + await pumpFlameChart(tester); + expect(find.byWidget(flameChart), findsOneWidget); + final FlameChartState state = tester.state(find.byWidget(flameChart)); + + // Find first row that has nodes. + final rowWithNodes = state.rows.firstWhere((row) => row.nodes.isNotEmpty); + final node = rowWithNodes.nodes[0]; + final initialNodeWidth = node.rect.width; + expect(initialNodeWidth, greaterThan(0.0)); + + // Update the flame chart with a new width. + flameChart = CpuProfileFlameChart( + data: cpuProfileData, + width: 2000.0, + height: 1000.0, + selectionNotifier: ValueNotifier(null), + searchMatchesNotifier: controller.searchMatches, + activeSearchMatchNotifier: controller.activeSearchMatch, + onDataSelected: (_) {}, + ); + await pumpFlameChart(tester); + await tester.pumpAndSettle(); + + final updatedRowWithNodes = state.rows.firstWhere( + (row) => row.nodes.isNotEmpty, + ); + final updatedNode = updatedRowWithNodes.nodes[0]; + expect(updatedNode.rect.width, isNot(equals(initialNodeWidth))); + expect(updatedNode.rect.width, greaterThan(initialNodeWidth)); + }); }); group('ScrollingFlameChartRow', () { From 64e7fa0fa2e445ee219429737bbe11ad6de8b10e Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 27 Jul 2026 09:56:50 -0700 Subject: [PATCH 3/4] notes --- packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md index 799372e1905..a147f4cc9b3 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md @@ -27,7 +27,9 @@ TODO: Remove this section if there are not any updates. ## CPU profiler updates -- Fixed a bug where resizing the CPU flame chart changes the timing values across the top of the chart. [TODO](https://github.com/flutter/devtools/pull/TODO) +* Fixed a bug where resizing the CPU flame chart changes the timing values + across the top of the chart. + [#9915](https://github.com/flutter/devtools/pull/9915) ## Memory updates @@ -40,7 +42,7 @@ TODO: Remove this section if there are not any updates. ## Network profiler updates -- Fixed exported response status in HAR files so that they parse as integers +* Fixed exported response status in HAR files so that they parse as integers instead of strings. [#9900](https://github.com/flutter/devtools/pull/9900) ## Logging updates From 550a7a3ea0ed66a313b817e9a74910d885f52bfb Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 27 Jul 2026 14:48:00 -0700 Subject: [PATCH 4/4] feedback --- packages/devtools_app/lib/src/shared/charts/flame_chart.dart | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/devtools_app/lib/src/shared/charts/flame_chart.dart b/packages/devtools_app/lib/src/shared/charts/flame_chart.dart index bd51229539d..c33243e09fe 100644 --- a/packages/devtools_app/lib/src/shared/charts/flame_chart.dart +++ b/packages/devtools_app/lib/src/shared/charts/flame_chart.dart @@ -269,8 +269,7 @@ abstract class FlameChartState< verticalControllerGroup.resetScroll(); zoomController.reset(); verticalExtentDelegate.recompute(); - } else if (widget.containerWidth != oldWidget.containerWidth || - widget.containerHeight != oldWidget.containerHeight) { + } else if (widget.containerWidth != oldWidget.containerWidth) { initFlameChartElements(); verticalExtentDelegate.recompute(); }