From ebae4b81a2f6c533e9d4618ac257a0eedbef9af3 Mon Sep 17 00:00:00 2001 From: Kenzie Davisson Date: Thu, 1 May 2025 10:56:14 -0700 Subject: [PATCH 1/4] Do not await service extension call in the performance screen --- .../performance/performance_controller.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart index e097bf052b9..cfd1da27133 100644 --- a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart +++ b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart @@ -124,9 +124,17 @@ class PerformanceController extends DevToolsScreenController if (serviceConnection.serviceManager.connectedApp?.isFlutterAppNow ?? false) { - final impellerEnabledResponse = await serviceConnection.serviceManager - .callServiceExtensionOnMainIsolate(registrations.isImpellerEnabled); - _impellerEnabled = impellerEnabledResponse.json?['enabled'] == true; + // Do not await this future because this will hang if the app is paused + // upon connection. + unawaited( + serviceConnection.serviceManager + .callServiceExtensionOnMainIsolate( + registrations.isImpellerEnabled, + ) + .then((response) { + _impellerEnabled = response.json?['enabled'] == true; + }), + ); } else { _impellerEnabled = false; } From 88adfa0229369fdef09a0b997b88c60623c77695 Mon Sep 17 00:00:00 2001 From: Kenzie Davisson Date: Thu, 1 May 2025 11:06:57 -0700 Subject: [PATCH 2/4] use value listenable --- .../flutter_frames/flutter_frames_chart.dart | 63 +++++++++++-------- .../performance/performance_controller.dart | 9 +-- .../flutter_frames_chart_test.dart | 2 +- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/packages/devtools_app/lib/src/screens/performance/panes/flutter_frames/flutter_frames_chart.dart b/packages/devtools_app/lib/src/screens/performance/panes/flutter_frames/flutter_frames_chart.dart index 0ed3c6f5d9a..1a42f8bcf2d 100644 --- a/packages/devtools_app/lib/src/screens/performance/panes/flutter_frames/flutter_frames_chart.dart +++ b/packages/devtools_app/lib/src/screens/performance/panes/flutter_frames/flutter_frames_chart.dart @@ -7,6 +7,7 @@ import 'dart:math' as math; import 'package:devtools_app_shared/ui.dart'; import 'package:devtools_app_shared/utils.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import '../../../../shared/analytics/analytics.dart' as ga; @@ -39,7 +40,7 @@ class FlutterFramesChart extends StatelessWidget { final bool showingOfflineData; - final bool impellerEnabled; + final ValueListenable impellerEnabled; @override Widget build(BuildContext context) { @@ -86,7 +87,7 @@ class _FlutterFramesChart extends StatefulWidget { final bool showingOfflineData; - final bool impellerEnabled; + final ValueListenable impellerEnabled; static double get frameNumberSectionHeight => scaleByFontFactor(20.0); @@ -203,7 +204,7 @@ class FramesChart extends StatefulWidget { final BoxConstraints constraints; - final bool impellerEnabled; + final ValueListenable impellerEnabled; @override State createState() => _FramesChartState(); @@ -346,13 +347,18 @@ class _FramesChartState extends State with AutoDisposeMixin { chartAxisPainter, Padding(padding: EdgeInsets.only(left: _yAxisUnitsSpace), child: chart), fpsLinePainter, - Positioned( - right: denseSpacing, - top: densePadding, - child: Text( - 'Engine: ${widget.impellerEnabled ? 'Impeller' : 'Skia'}', - style: themeData.subtleChartTextStyle, - ), + ValueListenableBuilder( + valueListenable: widget.impellerEnabled, + builder: (context, impellerEnabled, child) { + return Positioned( + right: denseSpacing, + top: densePadding, + child: Text( + 'Engine: ${impellerEnabled ? 'Impeller' : 'Skia'}', + style: themeData.subtleChartTextStyle, + ), + ); + }, ), ], ); @@ -382,7 +388,7 @@ class FramesChartControls extends StatelessWidget { final bool showingOfflineData; - final bool impellerEnabled; + final ValueListenable impellerEnabled; @override Widget build(BuildContext context) { @@ -408,21 +414,26 @@ class FramesChartControls extends StatelessWidget { ); }, ), - Legend( - dense: true, - entries: [ - LegendEntry(terse ? 'UI' : 'Frame Time (UI)', mainUiColor), - LegendEntry( - terse ? 'Raster' : 'Frame Time (Raster)', - mainRasterColor, - ), - LegendEntry(terse ? 'Jank' : 'Jank (slow frame)', uiJankColor), - if (!impellerEnabled) - LegendEntry( - 'Shader Compilation', - shaderCompilationColor.background, - ), - ], + ValueListenableBuilder( + valueListenable: impellerEnabled, + builder: (context, impellerEnabled, child) { + return Legend( + dense: true, + entries: [ + LegendEntry(terse ? 'UI' : 'Frame Time (UI)', mainUiColor), + LegendEntry( + terse ? 'Raster' : 'Frame Time (Raster)', + mainRasterColor, + ), + LegendEntry(terse ? 'Jank' : 'Jank (slow frame)', uiJankColor), + if (!impellerEnabled) + LegendEntry( + 'Shader Compilation', + shaderCompilationColor.background, + ), + ], + ); + }, ), AverageFPS( frames: frames, diff --git a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart index cfd1da27133..a4631aea79d 100644 --- a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart +++ b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart @@ -9,6 +9,7 @@ import 'dart:async'; import 'package:devtools_app_shared/service.dart'; import 'package:devtools_app_shared/utils.dart'; +import 'package:flutter/foundation.dart'; import 'package:vm_service/vm_service.dart'; import '../../service/service_registrations.dart' as registrations; @@ -83,8 +84,8 @@ class PerformanceController extends DevToolsScreenController /// any selection modifications that occur while the data is displayed. OfflinePerformanceData? offlinePerformanceData; - bool get impellerEnabled => _impellerEnabled; - bool _impellerEnabled = false; + ValueListenable get impellerEnabled => _impellerEnabled; + final _impellerEnabled = ValueNotifier(false); Future get initialized => _initialized.future; final _initialized = Completer(); @@ -132,11 +133,11 @@ class PerformanceController extends DevToolsScreenController registrations.isImpellerEnabled, ) .then((response) { - _impellerEnabled = response.json?['enabled'] == true; + _impellerEnabled.value = response.json?['enabled'] == true; }), ); } else { - _impellerEnabled = false; + _impellerEnabled.value = false; } enhanceTracingController.init(); diff --git a/packages/devtools_app/test/screens/performance/flutter_frames/flutter_frames_chart_test.dart b/packages/devtools_app/test/screens/performance/flutter_frames/flutter_frames_chart_test.dart index a7440db23fa..b0d63ca2370 100644 --- a/packages/devtools_app/test/screens/performance/flutter_frames/flutter_frames_chart_test.dart +++ b/packages/devtools_app/test/screens/performance/flutter_frames/flutter_frames_chart_test.dart @@ -29,7 +29,7 @@ void main() { FlutterFramesChart( framesController, showingOfflineData: showingOfflineData, - impellerEnabled: impellerEnabled, + impellerEnabled: FixedValueListenable(impellerEnabled), ), ), ); From af26c053a5a7d56f078a38878a32bab7e53477cd Mon Sep 17 00:00:00 2001 From: Kenzie Davisson Date: Thu, 1 May 2025 11:08:36 -0700 Subject: [PATCH 3/4] rnotes --- packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md | 3 ++- 1 file changed, 2 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 5673a98406e..a2f41894e59 100644 --- a/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md +++ b/packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md @@ -25,7 +25,8 @@ TODO: Remove this section if there are not any general updates. ## Performance updates -TODO: Remove this section if there are not any general updates. +- Fixes a bug where the Performance page would hang when connected to a paused +Flutter app. - [#9162](https://github.com/flutter/devtools/pull/9162) ## CPU profiler updates From 8264e0b2fd4262982419a66436975694849e48be Mon Sep 17 00:00:00 2001 From: Kenzie Davisson Date: Thu, 1 May 2025 11:31:55 -0700 Subject: [PATCH 4/4] add missing dispose --- .../lib/src/screens/performance/performance_controller.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart index a4631aea79d..c15d9311494 100644 --- a/packages/devtools_app/lib/src/screens/performance/performance_controller.dart +++ b/packages/devtools_app/lib/src/screens/performance/performance_controller.dart @@ -273,6 +273,7 @@ class PerformanceController extends DevToolsScreenController _applyToFeatureControllers((c) => c.dispose()); enhanceTracingController.dispose(); rebuildCountModel.dispose(); + _impellerEnabled.dispose(); super.dispose(); }