Skip to content

Commit 8efcaed

Browse files
Disable the Raster Stats tool for Impeller (#6616)
1 parent da7b9f7 commit 8efcaed

File tree

16 files changed

+116
-19
lines changed

16 files changed

+116
-19
lines changed

packages/devtools_app/lib/devtools_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export 'src/service/json_to_service_cache.dart';
5757
export 'src/service/resolved_uri_manager.dart';
5858
export 'src/service/service_extensions.dart';
5959
export 'src/service/service_manager.dart';
60+
export 'src/service/service_registrations.dart';
6061
export 'src/service/timeline_streams.dart';
6162
export 'src/service/vm_flags.dart';
6263
export 'src/service/vm_service_wrapper.dart';

packages/devtools_app/lib/src/screens/performance/panes/frame_analysis/frame_hints.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ class ShaderCompilationHint extends StatelessWidget {
370370
LinkTextSpan(
371371
link: Link(
372372
display: 'Impeller',
373-
url: impellerWikiUrl,
373+
url: impellerDocsUrl,
374374
gaScreenName: gac.performance,
375375
gaSelectedItemDescription:
376-
gac.PerformanceDocs.impellerWikiLink.name,
376+
gac.PerformanceDocs.impellerDocsLink.name,
377377
),
378378
context: context,
379379
),

packages/devtools_app/lib/src/screens/performance/panes/raster_stats/raster_stats.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,48 @@ import '../../../../shared/globals.dart';
1414
import '../../../../shared/primitives/utils.dart';
1515
import '../../../../shared/table/table.dart';
1616
import '../../../../shared/table/table_data.dart';
17+
import '../../performance_utils.dart';
1718
import 'raster_stats_controller.dart';
1819
import 'raster_stats_model.dart';
1920

2021
class RasterStatsView extends StatelessWidget {
2122
const RasterStatsView({
2223
super.key,
2324
required this.rasterStatsController,
25+
required this.impellerEnabled,
2426
});
2527

2628
final RasterStatsController rasterStatsController;
2729

30+
final bool impellerEnabled;
31+
2832
@override
2933
Widget build(BuildContext context) {
34+
if (impellerEnabled) {
35+
return Center(
36+
child: RichText(
37+
textAlign: TextAlign.center,
38+
text: TextSpan(
39+
text: 'The Raster Stats tool is not currently available for the '
40+
'Impeller backend.\nLearn more about the status of ',
41+
style: Theme.of(context).regularTextStyle,
42+
children: [
43+
LinkTextSpan(
44+
link: Link(
45+
display: 'Impeller',
46+
url: impellerDocsUrl,
47+
gaScreenName: gac.performance,
48+
gaSelectedItemDescription:
49+
gac.PerformanceDocs.impellerDocsLinkFromRasterStats.name,
50+
),
51+
context: context,
52+
),
53+
const TextSpan(text: '.'),
54+
],
55+
),
56+
),
57+
);
58+
}
3059
return Column(
3160
children: [
3261
if (!offlineController.offlineMode.value)

packages/devtools_app/lib/src/screens/performance/panes/raster_stats/raster_stats_controller.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class RasterStatsController extends PerformanceFeatureController {
4141
setData(rasterStats);
4242
} catch (e, st) {
4343
_log.shout('Error collecting raster stats: $e', e, st);
44+
notificationService.pushError(
45+
'Error collecting raster stats: $e',
46+
stackTrace: st.toString(),
47+
);
4448
clearData();
4549
} finally {
4650
_loadingSnapshot.value = false;

packages/devtools_app/lib/src/screens/performance/performance_controller.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:async';
77
import 'package:devtools_app_shared/utils.dart';
88
import 'package:vm_service/vm_service.dart';
99

10+
import '../../service/service_registrations.dart' as registrations;
1011
import '../../shared/diagnostics/inspector_service.dart';
1112
import '../../shared/feature_flags.dart';
1213
import '../../shared/globals.dart';
@@ -98,6 +99,9 @@ class PerformanceController extends DisposableController
9899
/// in selected timeline event, selected frame, etc.).
99100
PerformanceData? offlinePerformanceData;
100101

102+
bool get impellerEnabled => _impellerEnabled;
103+
late final bool _impellerEnabled;
104+
101105
final _initialized = Completer<void>();
102106

103107
Future<void> get initialized => _initialized.future;
@@ -115,6 +119,17 @@ class PerformanceController extends DisposableController
115119
if (!offlineController.offlineMode.value) {
116120
await serviceConnection.serviceManager.onServiceAvailable;
117121

122+
if (serviceConnection.serviceManager.connectedApp?.isFlutterAppNow ??
123+
false) {
124+
final impellerEnabledResponse = await serviceConnection.serviceManager
125+
.callServiceExtensionOnMainIsolate(
126+
registrations.isImpellerEnabled,
127+
);
128+
_impellerEnabled = impellerEnabledResponse.json?['enabled'] == true;
129+
} else {
130+
_impellerEnabled = false;
131+
}
132+
118133
enhanceTracingController.init();
119134

120135
// Listen for Flutter.Frame events with frame timing data.

packages/devtools_app/lib/src/screens/performance/performance_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void debugTraceEventCallback(VoidCallback callback) {
8787

8888
const preCompileShadersDocsUrl = 'https://docs.flutter.dev/perf/shader';
8989

90-
const impellerWikiUrl = 'https://github.com/flutter/flutter/wiki/Impeller';
90+
const impellerDocsUrl = 'https://docs.flutter.dev/perf/impeller';
9191

9292
extension TraceEventExtension on TraceEvent {
9393
bool get isThreadNameEvent =>

packages/devtools_app/lib/src/screens/performance/tabbed_performance_view.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ class _TabbedPerformanceViewState extends State<TabbedPerformanceView>
152152
child: Center(
153153
child: RasterStatsView(
154154
rasterStatsController: controller.rasterStatsController,
155+
impellerEnabled: controller.impellerEnabled,
155156
),
156157
),
157158
),

packages/devtools_app/lib/src/service/service_registrations.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,7 @@ const renderFrameWithRasterStats = '_flutter.renderFrameWithRasterStats';
5858

5959
/// Dwds listens to events for recording end-to-end analytics.
6060
const dwdsSendEvent = 'ext.dwds.sendEvent';
61+
62+
/// Service extension that returns whether or not the Impeller rendering engine
63+
/// is being used (if false, the app is using SKIA).
64+
const isImpellerEnabled = 'ext.ui.window.impellerEnabled';

packages/devtools_app/lib/src/shared/analytics/constants/_performance_constants.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum PerformanceDocs {
5050
intrinsicOperationsDocs,
5151
shaderCompilationDocs,
5252
shaderCompilationDocsTooltipLink,
53-
impellerWikiLink,
53+
impellerDocsLink,
54+
impellerDocsLinkFromRasterStats,
5455
platformChannelsDocs,
5556
}

packages/devtools_app/lib/src/shared/banner_messages.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ class ShaderJankMessage {
355355
LinkTextSpan(
356356
link: Link(
357357
display: 'Impeller',
358-
url: impellerWikiUrl,
358+
url: impellerDocsUrl,
359359
gaScreenName: screenId,
360360
gaSelectedItemDescription:
361-
gac.PerformanceDocs.impellerWikiLink.name,
361+
gac.PerformanceDocs.impellerDocsLink.name,
362362
),
363363
context: context,
364364
style: theme.errorMessageLinkStyle,

packages/devtools_app/lib/src/shared/common_widgets.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,7 @@ class CenteredMessage extends StatelessWidget {
976976
@override
977977
Widget build(BuildContext context) {
978978
return Center(
979-
child: Text(
980-
message,
981-
style: Theme.of(context).textTheme.titleLarge,
982-
),
979+
child: Text(message),
983980
);
984981
}
985982
}

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ video provides a brief tutorial for each DevTools screen.
1919

2020
* Fix a bug with service extension states not being cleared on app disconnect.
2121
[#6547](https://github.com/flutter/devtools/pull/6547)
22-
- Improved styling of bottom status bar when connected to an app. [#6525](https://github.com/flutter/devtools/pull/6525)
22+
* Improved styling of bottom status bar when connected to an app. [#6525](https://github.com/flutter/devtools/pull/6525)
2323

2424
## Inspector updates
2525

@@ -28,7 +28,7 @@ TODO: Remove this section if there are not any general updates.
2828
## Performance updates
2929

3030
* Added an option in the "Enhance Tracing" menu for tracking platform channel
31-
activity. This is useful for apps with plugins.
31+
activity. This is useful for apps with plugins. [#6515](https://github.com/flutter/devtools/pull/6515)
3232

3333
![Track platform channels setting](images/track_platform_channels.png "Track platform channels setting")
3434

@@ -37,6 +37,10 @@ previously saved from DevTools can be reloaded for viewing from this screen. [#6
3737
* Added an "Open" button to the Performance controls for loading data that was previously saved
3838
from DevTools. [#6567](https://github.com/flutter/devtools/pull/6567)
3939

40+
![Open file button on the performance screen](images/open_file_performance_screen.png "Open file button on the performance screen")
41+
42+
* Disable the Raster Stats tool for the Impeller backend since it is not supported. [#6616](https://github.com/flutter/devtools/pull/6616)
43+
4044
## CPU profiler updates
4145

4246
* Tree guidelines are now always enabled for the "Bottom Up" and "Call Tree" tabs. [#6534](https://github.com/flutter/devtools/pull/6534)
@@ -55,7 +59,7 @@ TODO: Remove this section if there are not any general updates.
5559

5660
## Network profiler updates
5761

58-
* Network statuses now show with an error color when the request failed [#6527](https://github.com/flutter/devtools/pull/6527)
62+
* Network statuses now show with an error color when the request failed. [#6527](https://github.com/flutter/devtools/pull/6527)
5963

6064
## Logging updates
6165

@@ -68,7 +72,7 @@ TODO: Remove this section if there are not any general updates.
6872
## VS Code Sidebar updates
6973

7074
* When using VS Code with a light theme, the embedded sidebar provided by DevTools will now also show in the light
71-
theme [#6581](https://github.com/flutter/devtools/pull/6581)
75+
theme. [#6581](https://github.com/flutter/devtools/pull/6581)
7276

7377
## Full commit history
7478

Loading

packages/devtools_app/test/performance/raster_stats/raster_stats_controller_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void main() {
2929
);
3030
setGlobal(ServiceConnectionManager, mockServiceConnection);
3131
setGlobal(IdeTheme, IdeTheme());
32+
setGlobal(NotificationService, NotificationService());
3233

3334
controller =
3435
RasterStatsController(createMockPerformanceControllerWithDefaults());

packages/devtools_app/test/performance/raster_stats/raster_stats_test.dart

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ void main() {
3232
await controller.collectRasterStats();
3333
});
3434

35-
Future<void> pumpRenderingLayerVisualizer(WidgetTester tester) async {
35+
Future<void> pumpRasterStatsView(
36+
WidgetTester tester, {
37+
bool impellerEnabled = false,
38+
}) async {
3639
await tester.pumpWidget(
3740
wrap(
3841
RasterStatsView(
3942
rasterStatsController: controller,
43+
impellerEnabled: impellerEnabled,
4044
),
4145
),
4246
);
@@ -45,7 +49,7 @@ void main() {
4549

4650
testWidgets('renders in empty state', (WidgetTester tester) async {
4751
controller.clearData();
48-
await pumpRenderingLayerVisualizer(tester);
52+
await pumpRasterStatsView(tester);
4953

5054
expect(find.byType(LayerSnapshotTable), findsNothing);
5155
expect(find.byType(LayerImage), findsNothing);
@@ -58,7 +62,7 @@ void main() {
5862
});
5963

6064
testWidgets('renders with data', (tester) async {
61-
await pumpRenderingLayerVisualizer(tester);
65+
await pumpRasterStatsView(tester);
6266

6367
expect(find.byType(LayerSnapshotTable), findsOneWidget);
6468
expect(find.richText('Layer'), findsOneWidget);
@@ -79,8 +83,23 @@ void main() {
7983
);
8084
});
8185

86+
testWidgets('renders for Impeller', (WidgetTester tester) async {
87+
controller.clearData();
88+
await pumpRasterStatsView(tester, impellerEnabled: true);
89+
90+
expect(find.byType(LayerSnapshotTable), findsNothing);
91+
expect(find.byType(LayerImage), findsNothing);
92+
expect(
93+
find.richTextContaining(
94+
'The Raster Stats tool is not currently available for the '
95+
'Impeller backend.',
96+
),
97+
findsOneWidget,
98+
);
99+
});
100+
82101
testWidgets('can change layer selection', (tester) async {
83-
await pumpRenderingLayerVisualizer(tester);
102+
await pumpRasterStatsView(tester);
84103

85104
final rasterStats = controller.rasterStats.value!;
86105
final layers = rasterStats.layerSnapshots;

packages/devtools_test/lib/src/mocks/fake_service_manager.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class FakeServiceManager extends Fake
104104
this.availableServices = const [],
105105
this.availableLibraries = const [],
106106
this.onVmServiceOpened,
107-
}) {
107+
Map<String, Response>? serviceExtensionResponses,
108+
}) : serviceExtensionResponses =
109+
serviceExtensionResponses ?? _defaultServiceExtensionResponses {
108110
this.service = service ?? createFakeService();
109111
mockConnectedApp(
110112
connectedApp!,
@@ -149,6 +151,12 @@ class FakeServiceManager extends Fake
149151

150152
final Function? onVmServiceOpened;
151153

154+
final Map<String, Response> serviceExtensionResponses;
155+
156+
static final _defaultServiceExtensionResponses = <String, Response>{
157+
isImpellerEnabled: Response.parse({'enabled': false})!,
158+
};
159+
152160
@override
153161
VmServiceWrapper? service;
154162

@@ -195,6 +203,19 @@ class FakeServiceManager extends Fake
195203
when(state.isPaused).thenReturn(ValueNotifier(value));
196204
}
197205

206+
@override
207+
Future<Response> callServiceExtensionOnMainIsolate(
208+
String method, {
209+
Map<String, dynamic>? args,
210+
}) async {
211+
if (!serviceExtensionResponses.containsKey(method)) {
212+
throw UnimplementedError(
213+
'Unimplemented response for service extension: $method',
214+
);
215+
}
216+
return serviceExtensionResponses[method]!;
217+
}
218+
198219
@override
199220
ValueListenable<bool> registeredServiceListenable(String name) {
200221
if (availableServices.contains(name)) {

0 commit comments

Comments
 (0)