From 102cd01693ea3fc81aef13e563f1205f57d81e6e Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 29 Jul 2024 13:30:54 -0700 Subject: [PATCH] [flutter_tools] remove raster stats CLI option. (#152501) The raster stats feature is being removed from devtools and the engine. Remove the CLI option as well. Fixes https://github.com/flutter/flutter/issues/144191 Fixes https://github.com/flutter/flutter/issues/132169 --- .../lib/src/base/command_help.dart | 5 -- .../lib/src/resident_runner.dart | 50 ------------------- packages/flutter_tools/lib/src/vmservice.dart | 21 -------- .../resident_runner_helpers.dart | 12 ----- .../general.shard/resident_runner_test.dart | 26 ---------- .../general.shard/terminal_handler_test.dart | 6 --- .../test/general.shard/vmservice_test.dart | 41 --------------- .../overall_experience_test.dart | 1 - 8 files changed, 162 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/command_help.dart b/packages/flutter_tools/lib/src/base/command_help.dart index 982f72787e9..83a56350645 100644 --- a/packages/flutter_tools/lib/src/base/command_help.dart +++ b/packages/flutter_tools/lib/src/base/command_help.dart @@ -124,11 +124,6 @@ class CommandHelp { 'WidgetsApp.showWidgetInspectorOverride', ); - late final CommandHelpOption j = _makeOption( - 'j', - 'Dump frame raster stats for the current frame. (Unsupported for web)', - ); - late final CommandHelpOption k = _makeOption( 'k', 'Toggle CanvasKit rendering.', diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 209b0bd0815..daabad8b910 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -694,52 +694,6 @@ abstract class ResidentHandlers { return true; } - /// Dump frame rasterization metrics for the last rendered frame. - /// - /// The last frames gets re-painted while recording additional tracing info - /// pertaining to the various draw calls issued by the frame. The timings - /// recorded here are not indicative of production performance. The intended - /// use case is to look at the various layers in proportion to see what - /// contributes the most towards raster performance. - Future debugFrameJankMetrics() async { - if (!supportsServiceProtocol) { - return false; - } - for (final FlutterDevice? device in flutterDevices) { - if (device?.targetPlatform == TargetPlatform.web_javascript) { - logger.printWarning('Unable to get jank metrics for web'); - continue; - } - final List views = await device!.vmService!.getFlutterViews(); - try { - for (final FlutterView view in views) { - final Map? rasterData = - await device.vmService!.renderFrameWithRasterStats( - viewId: view.id, - uiIsolateId: view.uiIsolate!.id, - ); - if (rasterData != null) { - final File tempFile = globals.fsUtils.getUniqueFile( - globals.fs.currentDirectory, - 'flutter_jank_metrics', - 'json', - ); - tempFile.writeAsStringSync(jsonEncode(rasterData), flush: true); - logger.printStatus('Wrote jank metrics to ${tempFile.absolute.path}'); - } else { - logger.printWarning('Unable to get jank metrics.'); - } - } - } on vm_service.RPCError catch (err) { - if (err.code != RPCErrorCodes.kServerError || !err.message.contains('Raster status not supported on Impeller backend')) { - rethrow; - } - logger.printWarning('Unable to get jank metrics for Impeller renderer'); - } - } - return true; - } - /// Dump the application's current layer tree to the terminal. Future debugDumpLayerTree() async { if (!supportsServiceProtocol || !isRunningDebug) { @@ -1558,7 +1512,6 @@ abstract class ResidentRunner extends ResidentHandlers { if (isRunningDebug) { commandHelp.g.print(); } - commandHelp.j.print(); } } @@ -1739,9 +1692,6 @@ class TerminalHandler { return residentRunner.debugToggleWidgetInspector(); case 'I': return residentRunner.debugToggleInvertOversizedImages(); - case 'j': - case 'J': - return residentRunner.debugFrameJankMetrics(); case 'L': return residentRunner.debugDumpLayerTree(); case 'o': diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index a3961584aae..196994c8b36 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -28,7 +28,6 @@ const String kFlushUIThreadTasksMethod = '_flutter.flushUIThreadTasks'; const String kRunInViewMethod = '_flutter.runInView'; const String kListViewsMethod = '_flutter.listViews'; const String kScreenshotSkpMethod = '_flutter.screenshotSkp'; -const String kRenderFrameWithRasterStatsMethod = '_flutter.renderFrameWithRasterStats'; const String kReloadAssetFonts = '_flutter.reloadAssetFonts'; const String kFlutterToolAlias = 'Flutter Tools'; @@ -593,26 +592,6 @@ class FlutterVmService { await onRunnable; } - /// Renders the last frame with additional raster tracing enabled. - /// - /// When a frame is rendered using this method it will incur additional cost - /// for rasterization which is not reflective of how long the frame takes in - /// production. This is primarily intended to be used to identify the layers - /// that result in the most raster perf degradation. - Future?> renderFrameWithRasterStats({ - required String? viewId, - required String? uiIsolateId, - }) async { - final vm_service.Response? response = await callMethodWrapper( - kRenderFrameWithRasterStatsMethod, - isolateId: uiIsolateId, - args: { - 'viewId': viewId, - }, - ); - return response?.json; - } - Future flutterDebugDumpApp({ required String isolateId, }) async { diff --git a/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart b/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart index f078cb0696c..165c00d234d 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_helpers.dart @@ -113,18 +113,6 @@ final FakeVmServiceRequest listViews = FakeVmServiceRequest( }, ); -const FakeVmServiceRequest renderFrameRasterStats = FakeVmServiceRequest( - method: kRenderFrameWithRasterStatsMethod, - args: { - 'viewId': 'a', - 'isolateId': '1', - }, - error: FakeRPCError( - code: RPCErrorCodes.kServerError, - error: 'Raster status not supported on Impeller backend', - ), -); - const FakeVmServiceRequest setAssetBundlePath = FakeVmServiceRequest( method: '_flutter.setAssetBundlePath', args: { diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index b0f4f8623ee..ea85a78f270 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -326,31 +326,6 @@ void main() { Usage: () => TestUsage(), })); - testUsingContext('ResidentRunner can handle an RPC exception from debugFrameJankMetrics', () => testbed.run(() async { - fakeVmServiceHost = FakeVmServiceHost(requests: [ - listViews, - listViews, - listViews, - renderFrameRasterStats, - ]); - final Completer futureConnectionInfo = Completer.sync(); - final Completer futureAppStart = Completer.sync(); - unawaited(residentRunner.attach( - appStartedCompleter: futureAppStart, - connectionInfoCompleter: futureConnectionInfo, - )); - await futureAppStart.future; - - final bool result = await residentRunner.debugFrameJankMetrics(); - expect(result, true); - expect((globals.flutterUsage as TestUsage).events, isEmpty); - expect(fakeAnalytics.sentEvents, isEmpty); - expect(fakeVmServiceHost?.hasRemainingExpectations, false); - expect((globals.logger as BufferLogger).warningText, contains('Unable to get jank metrics for Impeller renderer')); - }, overrides: { - Usage: () => TestUsage(), - })); - testUsingContext('ResidentRunner fails its operation if the device initialization is not complete', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, @@ -1335,7 +1310,6 @@ flutter: commandHelp.a, commandHelp.M, commandHelp.g, - commandHelp.j, commandHelp.hWithDetails, commandHelp.c, commandHelp.q, diff --git a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart index b2c5486490f..6a97247298d 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -179,12 +179,6 @@ void main() { await terminalHandler.processTerminalInput('a'); }); - testWithoutContext('j unsupported jank metrics for web', () async { - final TerminalHandler terminalHandler = setUpTerminalHandler([], web: true); - await terminalHandler.processTerminalInput('j'); - expect(terminalHandler.logger.warningText.contains('Unable to get jank metrics for web'), true); - }); - testWithoutContext('a - debugToggleProfileWidgetBuilds without service protocol is skipped', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([], supportsServiceProtocol: false); diff --git a/packages/flutter_tools/test/general.shard/vmservice_test.dart b/packages/flutter_tools/test/general.shard/vmservice_test.dart index 4d76a911f93..951529364f3 100644 --- a/packages/flutter_tools/test/general.shard/vmservice_test.dart +++ b/packages/flutter_tools/test/general.shard/vmservice_test.dart @@ -424,14 +424,6 @@ void main() { method: 'getVMTimeline', error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), ), - const FakeVmServiceRequest( - method: kRenderFrameWithRasterStatsMethod, - args: { - 'viewId': '1', - 'isolateId': '12', - }, - error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), - ), ] ); @@ -452,10 +444,6 @@ void main() { final vm_service.Response? timeline = await fakeVmServiceHost.vmService.getTimeline(); expect(timeline, isNull); - final Map? rasterStats = - await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: '1', uiIsolateId: '12'); - expect(rasterStats, isNull); - expect(fakeVmServiceHost.hasRemainingExpectations, false); }); @@ -480,35 +468,6 @@ void main() { expect(fakeVmServiceHost.hasRemainingExpectations, false); }); - testWithoutContext('renderWithStats forwards stats correctly', () async { - // ignore: always_specify_types - const Map response = { - 'type': 'RenderFrameWithRasterStats', - 'snapshots':[ - // ignore: always_specify_types - { - 'layer_unique_id':1512, - 'duration_micros':477, - 'snapshot':'', - }, - ], - }; - final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost( - requests: [ - const FakeVmServiceRequest(method: kRenderFrameWithRasterStatsMethod, args: { - 'isolateId': 'isolate/123', - 'viewId': 'view/1', - }, jsonResponse: response), - ] - ); - - final Map? rasterStats = - await fakeVmServiceHost.vmService.renderFrameWithRasterStats(viewId: 'view/1', uiIsolateId: 'isolate/123'); - expect(rasterStats, equals(response)); - - expect(fakeVmServiceHost.hasRemainingExpectations, false); - }); - testWithoutContext('getFlutterViews polls until a view is returned', () async { final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost( requests: [ diff --git a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart index 4741c07fe74..ade09027936 100644 --- a/packages/flutter_tools/test/integration.shard/overall_experience_test.dart +++ b/packages/flutter_tools/test/integration.shard/overall_experience_test.dart @@ -345,7 +345,6 @@ void main() { 'a Toggle timeline events for all widget build methods. (debugProfileWidgetBuilds)', 'M Write SkSL shaders to a unique file in the project directory.', 'g Run source code generators.', - 'j Dump frame raster stats for the current frame. (Unsupported for web)', 'h Repeat this help message.', 'd Detach (terminate "flutter run" but leave application running).', 'c Clear the screen',