Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,7 +40,7 @@ class FlutterFramesChart extends StatelessWidget {

final bool showingOfflineData;

final bool impellerEnabled;
final ValueListenable<bool> impellerEnabled;

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -86,7 +87,7 @@ class _FlutterFramesChart extends StatefulWidget {

final bool showingOfflineData;

final bool impellerEnabled;
final ValueListenable<bool> impellerEnabled;

static double get frameNumberSectionHeight => scaleByFontFactor(20.0);

Expand Down Expand Up @@ -203,7 +204,7 @@ class FramesChart extends StatefulWidget {

final BoxConstraints constraints;

final bool impellerEnabled;
final ValueListenable<bool> impellerEnabled;

@override
State<FramesChart> createState() => _FramesChartState();
Expand Down Expand Up @@ -346,13 +347,18 @@ class _FramesChartState extends State<FramesChart> 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,
),
);
},
),
],
);
Expand Down Expand Up @@ -382,7 +388,7 @@ class FramesChartControls extends StatelessWidget {

final bool showingOfflineData;

final bool impellerEnabled;
final ValueListenable<bool> impellerEnabled;

@override
Widget build(BuildContext context) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<bool> get impellerEnabled => _impellerEnabled;
final _impellerEnabled = ValueNotifier<bool>(false);

Future<void> get initialized => _initialized.future;
final _initialized = Completer<void>();
Expand Down Expand Up @@ -124,11 +125,19 @@ 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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth auditing the locations where we invoke service extensions to make sure we're not awaiting responses anywhere that could possibly cause a hang.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed #9164 to track

registrations.isImpellerEnabled,
)
.then((response) {
_impellerEnabled.value = response.json?['enabled'] == true;
}),
);
} else {
_impellerEnabled = false;
_impellerEnabled.value = false;
}

enhanceTracingController.init();
Expand Down Expand Up @@ -264,6 +273,7 @@ class PerformanceController extends DevToolsScreenController
_applyToFeatureControllers((c) => c.dispose());
enhanceTracingController.dispose();
rebuildCountModel.dispose();
_impellerEnabled.dispose();
super.dispose();
}

Expand Down
3 changes: 2 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void main() {
FlutterFramesChart(
framesController,
showingOfflineData: showingOfflineData,
impellerEnabled: impellerEnabled,
impellerEnabled: FixedValueListenable(impellerEnabled),
),
),
);
Expand Down