diff --git a/packages/flutter_tools/lib/src/resident_devtools_handler.dart b/packages/flutter_tools/lib/src/resident_devtools_handler.dart index e0b9e55ed3..5274718f78 100644 --- a/packages/flutter_tools/lib/src/resident_devtools_handler.dart +++ b/packages/flutter_tools/lib/src/resident_devtools_handler.dart @@ -166,7 +166,6 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler { try { await flutterDevice.vmService?.findExtensionIsolate( extension, - webIsolate: flutterDevice.targetPlatform == TargetPlatform.web_javascript, ); return flutterDevice; } on VmServiceDisappearedException { diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 849e0d548d..5b4ad7455a 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -405,18 +405,6 @@ class FlutterDevice { return devFS.create(); } - Future> _getCurrentIsolates() async { - if (targetPlatform == TargetPlatform.web_javascript) { - final vm_service.VM vm = await vmService.service.getVM(); - return vm.isolates; - } - final List views = await vmService.getFlutterViews(); - return [ - for (FlutterView view in views) - view.uiIsolate, - ]; - } - Future startEchoingDeviceLog() async { if (_loggingSubscription != null) { return; @@ -699,9 +687,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { final String data = await device.vmService.flutterDebugDumpApp( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); logger.printStatus(data); } @@ -715,9 +704,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { final String data = await device.vmService.flutterDebugDumpRenderTree( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); logger.printStatus(data); } @@ -731,9 +721,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { final String data = await device.vmService.flutterDebugDumpLayerTree( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); logger.printStatus(data); } @@ -749,9 +740,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { final String data = await device.vmService.flutterDebugDumpSemanticsTreeInTraversalOrder( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); logger.printStatus(data); } @@ -767,9 +759,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { final String data = await device.vmService.flutterDebugDumpSemanticsTreeInInverseHitTestOrder( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); logger.printStatus(data); } @@ -783,9 +776,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterToggleDebugPaintSizeEnabled( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -798,9 +792,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterToggleDebugCheckElevationsEnabled( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -818,9 +813,10 @@ abstract class ResidentHandlers { if (device.targetPlatform == TargetPlatform.web_javascript) { continue; } - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterTogglePerformanceOverlayOverride( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -833,9 +829,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterToggleWidgetInspector( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -848,9 +845,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterToggleInvertOversizedImages( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -863,9 +861,10 @@ abstract class ResidentHandlers { return false; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterToggleProfileWidgetBuilds( - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -877,9 +876,9 @@ abstract class ResidentHandlers { if (!supportsServiceProtocol) { return false; } - final List views = await flutterDevices.first._getCurrentIsolates(); + final List views = await flutterDevices.first.vmService.getFlutterViews(); final Brightness current = await flutterDevices.first.vmService.flutterBrightnessOverride( - isolateId: views.first.id, + isolateId: views.first.uiIsolate.id, ); Brightness next; if (current == Brightness.light) { @@ -888,9 +887,10 @@ abstract class ResidentHandlers { next = Brightness.light; } for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterBrightnessOverride( - isolateId: view.id, + isolateId: view.uiIsolate.id, brightness: next, ); } @@ -904,17 +904,18 @@ abstract class ResidentHandlers { if (!supportsServiceProtocol || !isRunningDebug) { return false; } - final List views = await flutterDevices.first._getCurrentIsolates(); + final List views = await flutterDevices.first.vmService.getFlutterViews(); final String from = await flutterDevices .first.vmService.flutterPlatformOverride( - isolateId: views.first.id, + isolateId: views.first.uiIsolate.id, ); final String to = nextPlatform(from); for (final FlutterDevice device in flutterDevices) { - for (final vm_service.IsolateRef view in await device._getCurrentIsolates()) { + final List views = await device.vmService.getFlutterViews(); + for (final FlutterView view in views) { await device.vmService.flutterPlatformOverride( platform: to, - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } } @@ -1003,17 +1004,17 @@ abstract class ResidentHandlers { } Future _toggleDebugBanner(FlutterDevice device, Future Function() cb) async { - List views = []; + List views = []; if (supportsServiceProtocol) { - views = await device._getCurrentIsolates(); + views = await device.vmService.getFlutterViews(); } Future setDebugBanner(bool value) async { try { - for (final vm_service.IsolateRef view in views) { + for (final FlutterView view in views) { await device.vmService.flutterDebugAllowBanner( value, - isolateId: view.id, + isolateId: view.uiIsolate.id, ); } return true; diff --git a/packages/flutter_tools/lib/src/test/integration_test_device.dart b/packages/flutter_tools/lib/src/test/integration_test_device.dart index 72a2f8404b..41c34ec36e 100644 --- a/packages/flutter_tools/lib/src/test/integration_test_device.dart +++ b/packages/flutter_tools/lib/src/test/integration_test_device.dart @@ -78,7 +78,6 @@ class IntegrationTestTestDevice implements TestDevice { globals.printTrace('test $id: Finding the correct isolate with the integration test service extension'); final vm_service.IsolateRef isolateRef = await vmService.findExtensionIsolate( kIntegrationTestMethod, - webIsolate: targetPlatform == TargetPlatform.web_javascript, ); await vmService.service.streamListen(vm_service.EventStreams.kExtension); diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index ba170cf7e9..0bb62bf183 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -845,7 +845,7 @@ class FlutterVmService { /// /// Throws a [VmServiceDisappearedException] should the VM Service disappear /// while making calls to it. - Future findExtensionIsolate(String extensionName, {bool webIsolate = false}) async { + Future findExtensionIsolate(String extensionName) async { try { await service.streamListen(vm_service.EventStreams.kIsolate); } on vm_service.RPCError { @@ -863,7 +863,7 @@ class FlutterVmService { }); try { - final List refs = await _getIsolateRefs(webIsolate); + final List refs = await _getIsolateRefs(); for (final vm_service.IsolateRef ref in refs) { final vm_service.Isolate isolate = await getIsolateOrNull(ref.id); if (isolate != null && isolate.extensionRPCs.contains(extensionName)) { @@ -881,14 +881,7 @@ class FlutterVmService { } } - Future> _getIsolateRefs(bool webIsolate) async { - if (webIsolate) { - final List refs = (await service.getVM()).isolates; - if (refs.isEmpty) { - throw VmServiceDisappearedException(); - } - return refs; - } + Future> _getIsolateRefs() async { final List flutterViews = await getFlutterViews(); if (flutterViews.isEmpty) { throw VmServiceDisappearedException(); 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 ce7881e2a4..08a3e80312 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 @@ -205,11 +205,7 @@ void main() { 'streamId': 'Isolate', } ), - FakeVmServiceRequest( - method: 'getVM', - jsonResponse: fakeVM.toJson(), - args: {}, - ), + listViews, FakeVmServiceRequest( method: 'getIsolate', jsonResponse: isolate.toJson(), 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 675c6bbab7..614d71d54d 100644 --- a/packages/flutter_tools/test/general.shard/terminal_handler_test.dart +++ b/packages/flutter_tools/test/general.shard/terminal_handler_test.dart @@ -81,11 +81,6 @@ final FakeVmServiceRequest listViews = FakeVmServiceRequest( }, ); -final FakeVmServiceRequest getVM = FakeVmServiceRequest( - method: 'getVM', - jsonResponse: fakeVM.toJson(), -); - void main() { testWithoutContext('keyboard input handling single help character', () async { final TestRunner testRunner = TestRunner(); @@ -173,7 +168,7 @@ void main() { testWithoutContext('a - debugToggleProfileWidgetBuilds with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.profileWidgetBuilds', args: { @@ -235,7 +230,7 @@ void main() { testWithoutContext('b - debugToggleBrightness with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.brightnessOverride', args: { @@ -245,7 +240,7 @@ void main() { 'value': 'Brightness.light', } ), - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.brightnessOverride', args: { @@ -315,7 +310,7 @@ void main() { testWithoutContext('i - debugToggleWidgetInspector with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.inspector.show', args: { @@ -348,7 +343,7 @@ void main() { testWithoutContext('I - debugToggleInvertOversizedImages with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.invertOversizedImages', args: { @@ -389,7 +384,7 @@ void main() { testWithoutContext('L - debugDumpLayerTree with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpLayerTree', args: { @@ -472,7 +467,7 @@ void main() { testWithoutContext('o,O - debugTogglePlatform with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ // Request 1. - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.platformOverride', args: { @@ -482,7 +477,7 @@ void main() { 'value': 'iOS' }, ), - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.platformOverride', args: { @@ -494,7 +489,7 @@ void main() { }, ), // Request 2. - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.platformOverride', args: { @@ -504,7 +499,7 @@ void main() { 'value': 'android' }, ), - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.platformOverride', args: { @@ -544,7 +539,7 @@ void main() { testWithoutContext('p - debugToggleDebugPaintSizeEnabled with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugPaint', args: { @@ -603,7 +598,7 @@ void main() { testWithoutContext('S - debugDumpSemanticsTreeInTraversalOrder with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpSemanticsTreeInTraversalOrder', args: { @@ -644,7 +639,7 @@ void main() { testWithoutContext('U - debugDumpSemanticsTreeInInverseHitTestOrder with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpSemanticsTreeInInverseHitTestOrder', args: { @@ -698,7 +693,7 @@ void main() { testWithoutContext('t,T - debugDumpRenderTree with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpRenderTree', args: { @@ -709,7 +704,7 @@ void main() { }, ), // Request 2. - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpRenderTree', args: { @@ -766,7 +761,7 @@ void main() { testWithoutContext('w,W - debugDumpApp with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpApp', args: { @@ -777,7 +772,7 @@ void main() { }, ), // Request 2. - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugDumpApp', args: { @@ -837,7 +832,7 @@ void main() { testWithoutContext('z,Z - debugToggleDebugCheckElevationsEnabled with web target', () async { final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugCheckElevationsEnabled', args: { @@ -845,7 +840,7 @@ void main() { }, ), // Request 2. - getVM, + listViews, const FakeVmServiceRequest( method: 'ext.flutter.debugCheckElevationsEnabled', args: { @@ -1024,7 +1019,7 @@ void main() { final BufferLogger logger = BufferLogger.test(); final FileSystem fileSystem = MemoryFileSystem.test(); final TerminalHandler terminalHandler = setUpTerminalHandler([ - getVM, + listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', args: { @@ -1173,7 +1168,7 @@ void main() { final FileSystem fileSystem = MemoryFileSystem.test(); final TerminalHandler terminalHandler = setUpTerminalHandler( [ - getVM, + listViews, FakeVmServiceRequest( method: 'ext.flutter.debugAllowBanner', args: {