From 619121b095d9b506451387bde027038e7a986ab8 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Wed, 8 Sep 2021 20:22:04 -0400 Subject: [PATCH] Enable caching of CPU samples collected at application startup (#89600) --- packages/flutter_tools/lib/src/base/dds.dart | 3 +++ .../test/general.shard/resident_runner_test.dart | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/dds.dart b/packages/flutter_tools/lib/src/base/dds.dart index 673b60aaa1..145297a392 100644 --- a/packages/flutter_tools/lib/src/base/dds.dart +++ b/packages/flutter_tools/lib/src/base/dds.dart @@ -17,6 +17,7 @@ Future Function( bool enableAuthCodes, bool ipv6, Uri? serviceUri, + List cachedUserTags, }) ddsLauncherCallback = dds.DartDevelopmentService.startDartDevelopmentService; /// Helper class to launch a [dds.DartDevelopmentService]. Allows for us to @@ -52,6 +53,8 @@ class DartDevelopmentService { serviceUri: ddsUri, enableAuthCodes: disableServiceAuthCodes != true, ipv6: ipv6 == true, + // Enables caching of CPU samples collected during application startup. + cachedUserTags: const ['AppStartUp'], ); unawaited(_ddsInstance?.done.whenComplete(() { if (!_completer.isCompleted) { 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 c40ab56afd..b1f0c46351 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -1806,11 +1806,12 @@ void main() { fakeVmServiceHost = FakeVmServiceHost(requests: []); final FakeDevice device = FakeDevice() ..dds = DartDevelopmentService(); - ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) { + ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List cachedUserTags}) { expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(enableAuthCodes, isTrue); expect(ipv6, isFalse); expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0)); + expect(cachedUserTags, ['AppStartUp']); throw FakeDartDevelopmentServiceException(message: 'Existing VM service clients prevent DDS from taking control.', ); @@ -1853,11 +1854,12 @@ void main() { final FakeDevice device = FakeDevice() ..dds = DartDevelopmentService(); final Completerdone = Completer(); - ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) async { + ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List cachedUserTags}) async { expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(enableAuthCodes, isFalse); expect(ipv6, isTrue); expect(serviceUri, Uri(scheme: 'http', host: '::1', port: 0)); + expect(cachedUserTags, ['AppStartUp']); done.complete(); return null; }; @@ -1884,11 +1886,12 @@ void main() { // See https://github.com/flutter/flutter/issues/72385 for context. final FakeDevice device = FakeDevice() ..dds = DartDevelopmentService(); - ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri}) { + ddsLauncherCallback = (Uri uri, {bool enableAuthCodes, bool ipv6, Uri serviceUri, List cachedUserTags}) { expect(uri, Uri(scheme: 'foo', host: 'bar')); expect(enableAuthCodes, isTrue); expect(ipv6, isFalse); expect(serviceUri, Uri(scheme: 'http', host: '127.0.0.1', port: 0)); + expect(cachedUserTags, ['AppStartUp']); throw FakeDartDevelopmentServiceException(message: 'No URI'); }; final TestFlutterDevice flutterDevice = TestFlutterDevice(