From 31c3d0927b6cf16fa187a96b69e0120d1dd8c939 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 19 Aug 2024 10:40:07 -0700 Subject: [PATCH] Do not cancel the VmService's subscription to the isolate event stream in FlutterVmService.findExtensionIsolate (#153607) The stream subscriptions in the device's VmService are used by other parts of FlutterVmService and other components throughout flutter_tools. Components that listen to streams should not call VmService.streamCancel because that will interfere with other users who still want the events. See https://github.com/flutter/flutter/issues/153049 See https://github.com/flutter/flutter/issues/153563 --- packages/flutter_tools/lib/src/vmservice.dart | 5 --- .../integration_test_device_test.dart | 6 --- .../resident_devtools_handler_test.dart | 32 ---------------- .../test/general.shard/vmservice_test.dart | 37 ------------------- .../integration.shard/hot_reload_test.dart | 2 +- 5 files changed, 1 insertion(+), 81 deletions(-) diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index df5c969f42b..64be04caba1 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -986,11 +986,6 @@ class FlutterVmService { throw VmServiceDisappearedException(); } finally { await isolateEvents.cancel(); - try { - await service.streamCancel(vm_service.EventStreams.kIsolate); - } on vm_service.RPCError { - // It's ok for cleanup to fail, such as when the service disappears. - } } } diff --git a/packages/flutter_tools/test/general.shard/integration_test_device_test.dart b/packages/flutter_tools/test/general.shard/integration_test_device_test.dart index c3cf3cbe16d..cf5e47b2c10 100644 --- a/packages/flutter_tools/test/general.shard/integration_test_device_test.dart +++ b/packages/flutter_tools/test/general.shard/integration_test_device_test.dart @@ -96,12 +96,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), const FakeVmServiceRequest( method: 'streamListen', args: { diff --git a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart index d25d9134fd2..e99ae741efc 100644 --- a/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_devtools_handler_test.dart @@ -153,12 +153,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), listViews, listViews, const FakeVmServiceRequest( @@ -224,12 +218,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), const FakeVmServiceRequest( method: 'ext.flutter.activeDevToolsServerAddress', args: { @@ -270,13 +258,6 @@ void main() { method: kListViewsMethod, error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), - ), ], httpAddress: Uri.parse('http://localhost:1234')); final FakeFlutterDevice device = FakeFlutterDevice() @@ -311,12 +292,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), listViews, listViews, const FakeVmServiceRequest( @@ -346,13 +321,6 @@ void main() { method: kListViewsMethod, error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), - ), ], httpAddress: Uri.parse('http://localhost:5678')); await handler.serveAndAnnounceDevTools( diff --git a/packages/flutter_tools/test/general.shard/vmservice_test.dart b/packages/flutter_tools/test/general.shard/vmservice_test.dart index 683ebeef75e..d4e7f901402 100644 --- a/packages/flutter_tools/test/general.shard/vmservice_test.dart +++ b/packages/flutter_tools/test/general.shard/vmservice_test.dart @@ -535,12 +535,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), ]); final vm_service.IsolateRef isolateRef = await fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName); @@ -592,12 +586,6 @@ void main() { 'isolateId': '2', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), ]); final vm_service.IsolateRef isolateRef = await fakeVmServiceHost.vmService.findExtensionIsolate(otherExtensionName); @@ -644,12 +632,6 @@ void main() { isolate: isolate2, ), ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), ]); final vm_service.IsolateRef isolateRef = await fakeVmServiceHost.vmService.findExtensionIsolate(otherExtensionName); @@ -674,12 +656,6 @@ void main() { 'isolateId': '1', }, ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), ]); final vm_service.IsolateRef isolateRef = await fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName); @@ -710,12 +686,6 @@ void main() { timestamp: 1, ), ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - ), ]); final vm_service.IsolateRef isolateRef = await fakeVmServiceHost.vmService.findExtensionIsolate(kExtensionName); @@ -734,13 +704,6 @@ void main() { method: kListViewsMethod, error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), ), - const FakeVmServiceRequest( - method: 'streamCancel', - args: { - 'streamId': 'Isolate', - }, - error: FakeRPCError(code: RPCErrorCodes.kServiceDisappeared), - ), ]); expect( diff --git a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart index 0c3d0b07010..1108c032cf4 100644 --- a/packages/flutter_tools/test/integration.shard/hot_reload_test.dart +++ b/packages/flutter_tools/test/integration.shard/hot_reload_test.dart @@ -81,7 +81,7 @@ void main() { }); testWithoutContext('hot restart works without error', () async { - await flutter.run(verbose: true, noDevtools: true); + await flutter.run(verbose: true); await flutter.hotRestart(); });