diff --git a/packages/flutter_tools/lib/src/base/dds.dart b/packages/flutter_tools/lib/src/base/dds.dart index 673b60aaa1..08d25b3abf 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 @@ -36,6 +37,7 @@ class DartDevelopmentService { int? hostPort, bool? ipv6, bool? disableServiceAuthCodes, + bool cacheStartupProfile = false, }) async { final Uri ddsUri = Uri( scheme: 'http', @@ -52,6 +54,8 @@ class DartDevelopmentService { serviceUri: ddsUri, enableAuthCodes: disableServiceAuthCodes != true, ipv6: ipv6 == true, + // Enables caching of CPU samples collected during application startup. + cachedUserTags: cacheStartupProfile ? const ['AppStartUp'] : const [], ); unawaited(_ddsInstance?.done.whenComplete(() { if (!_completer.isCompleted) { diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index 78e79c2463..f38a2b44af 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -70,6 +70,7 @@ Future _kDefaultDartDevelopmentServiceStarter( ipv6: true, disableServiceAuthCodes: disableServiceAuthCodes, logger: globals.logger, + cacheStartupProfile: true, ); } diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 006d2776db..aaeb626f1d 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -267,6 +267,7 @@ class FlutterDevice { ipv6: ipv6, disableServiceAuthCodes: disableServiceAuthCodes, logger: globals.logger, + cacheStartupProfile: true, ); } on dds.DartDevelopmentServiceException catch (e, st) { if (!allowExistingDdsInstance || diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index 14151cefc9..b583de559e 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart @@ -772,6 +772,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService int hostPort, bool ipv6, bool disableServiceAuthCodes, + bool cacheStartupProfile = false, }) async {} @override diff --git a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart index 403ded6f41..16d453af7c 100644 --- a/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart +++ b/packages/flutter_tools/test/general.shard/drive/drive_service_test.dart @@ -590,6 +590,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService int hostPort, bool ipv6, bool disableServiceAuthCodes, + bool cacheStartupProfile = false, }) async { started = true; } diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart index 31997d73e2..a94390cf7c 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart @@ -932,6 +932,7 @@ class FakeDartDevelopmentService extends Fake implements DartDevelopmentService int hostPort, bool ipv6, bool disableServiceAuthCodes, + bool cacheStartupProfile = false, }) async {} @override 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 6084bec0c7..68d64f735b 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -1809,11 +1809,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.', ); @@ -1856,11 +1857,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; }; @@ -1887,11 +1889,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(