diff --git a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart index 54307a49dbbc..3df469e32f7d 100644 --- a/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/isolated/resident_web_runner.dart @@ -172,7 +172,7 @@ class ResidentWebRunner extends ResidentRunner { final vmservice.VmService? service = _connectionResult?.vmService; final Uri websocketUri = Uri.parse(_connectionResult!.debugConnection!.uri); final Uri httpUri = _httpUriFromWebsocketUri(websocketUri); - return _instance ??= FlutterVmService(service!, wsAddress: websocketUri, httpAddress: httpUri); + return _instance ??= FlutterVmService(service!, wsAddress: websocketUri, httpAddress: httpUri, logger: _logger); } FlutterVmService? _instance; diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 4076a2c1255b..edcada46a536 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -417,7 +417,7 @@ Future _connect( // This call is to ensure we are able to establish a connection instead of // keeping on trucking and failing farther down the process. await delegateService.getVersion(); - return FlutterVmService(service, httpAddress: httpUri, wsAddress: wsUri); + return FlutterVmService(service, httpAddress: httpUri, wsAddress: wsUri, logger: logger); } String _validateRpcStringParam(String methodName, Map params, String paramName) { @@ -486,11 +486,13 @@ class FlutterVmService { this.service, { this.wsAddress, this.httpAddress, - }); + required Logger logger, + }) : _logger = logger; final vm_service.VmService service; final Uri? wsAddress; final Uri? httpAddress; + final Logger _logger; Future callMethodWrapper( String method, { @@ -569,6 +571,7 @@ class FlutterVmService { required Uri main, required Uri assetsDirectory, }) async { + _logger.printTrace('Running $main in view $viewId...'); try { await service.streamListen(vm_service.EventStreams.kIsolate); } on vm_service.RPCError { @@ -577,6 +580,7 @@ class FlutterVmService { final Future onRunnable = service.onIsolateEvent.firstWhere((vm_service.Event event) { return event.kind == vm_service.EventKind.kIsolateRunnable; }); + _logger.printTrace('Calling $kRunInViewMethod...'); await callMethodWrapper( kRunInViewMethod, args: { @@ -585,7 +589,9 @@ class FlutterVmService { 'assetDirectory': assetsDirectory.toString(), }, ); + _logger.printTrace('Finished $kRunInViewMethod'); await onRunnable; + _logger.printTrace('Finished running $main in view $viewId'); } /// Renders the last frame with additional raster tracing enabled. @@ -905,9 +911,11 @@ class FlutterVmService { Duration delay = const Duration(milliseconds: 50), }) async { while (true) { + _logger.printTrace('Calling _flutter.listViews...'); final vm_service.Response? response = await callMethodWrapper( kListViewsMethod, ); + _logger.printTrace('Response from _flutter.listViews: ${json.encode(response?.json)}'); if (response == null) { // The service may have disappeared mid-request. // Return an empty list now, and let the shutdown logic elsewhere deal diff --git a/packages/flutter_tools/test/general.shard/vmservice_test.dart b/packages/flutter_tools/test/general.shard/vmservice_test.dart index ffb88c6955d7..a141d347ec4b 100644 --- a/packages/flutter_tools/test/general.shard/vmservice_test.dart +++ b/packages/flutter_tools/test/general.shard/vmservice_test.dart @@ -167,7 +167,7 @@ void main() { testWithoutContext('setAssetDirectory forwards arguments correctly', () async { final MockVMService mockVMService = MockVMService(); - final FlutterVmService flutterVmService = FlutterVmService(mockVMService); + final FlutterVmService flutterVmService = FlutterVmService(mockVMService, logger: BufferLogger.test()); await flutterVmService.setAssetDirectory( assetsDirectory: Uri(path: 'abc', scheme: 'file'), @@ -186,7 +186,7 @@ void main() { testWithoutContext('setAssetDirectory forwards arguments correctly - windows', () async { final MockVMService mockVMService = MockVMService(); - final FlutterVmService flutterVmService = FlutterVmService(mockVMService); + final FlutterVmService flutterVmService = FlutterVmService(mockVMService, logger: BufferLogger.test()); await flutterVmService.setAssetDirectory( assetsDirectory: Uri(path: 'C:/Users/Tester/AppData/Local/Temp/hello_worldb42a6da5/hello_world/build/flutter_assets', scheme: 'file'), @@ -207,7 +207,7 @@ void main() { testWithoutContext('getSkSLs forwards arguments correctly', () async { final MockVMService mockVMService = MockVMService(); - final FlutterVmService flutterVmService = FlutterVmService(mockVMService); + final FlutterVmService flutterVmService = FlutterVmService(mockVMService, logger: BufferLogger.test()); await flutterVmService.getSkSLs(viewId: 'abc'); @@ -220,7 +220,7 @@ void main() { testWithoutContext('flushUIThreadTasks forwards arguments correctly', () async { final MockVMService mockVMService = MockVMService(); - final FlutterVmService flutterVmService = FlutterVmService(mockVMService); + final FlutterVmService flutterVmService = FlutterVmService(mockVMService, logger: BufferLogger.test()); await flutterVmService.flushUIThreadTasks(uiIsolateId: 'def'); diff --git a/packages/flutter_tools/test/src/fake_vm_services.dart b/packages/flutter_tools/test/src/fake_vm_services.dart index 75be62f87e33..55c35fb73f24 100644 --- a/packages/flutter_tools/test/src/fake_vm_services.dart +++ b/packages/flutter_tools/test/src/fake_vm_services.dart @@ -4,6 +4,7 @@ import 'dart:async'; +import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/vmservice.dart'; import 'package:test/test.dart' hide test; @@ -22,7 +23,7 @@ class FakeVmServiceHost { _vmService = FlutterVmService(vm_service.VmService( _input.stream, _output.add, - ), httpAddress: httpAddress, wsAddress: wsAddress); + ), httpAddress: httpAddress, wsAddress: wsAddress, logger: BufferLogger.test()); _applyStreamListen(); _output.stream.listen((String data) { final Map request = json.decode(data) as Map;