Skip to content

Commit

Permalink
add more print traces in hot runner workflow (#148258)
Browse files Browse the repository at this point in the history
In service of flutter/flutter#146879. See flutter/flutter#146879 (comment) in particular for the purpose of this PR. This adds a few more `printTrace` calls to try to see where we are getting stuck.
  • Loading branch information
andrewkolos authored May 13, 2024
1 parent a36ff80 commit 7d26350
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions packages/flutter_tools/lib/src/vmservice.dart
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Future<FlutterVmService> _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<String, Object?> params, String paramName) {
Expand Down Expand Up @@ -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<vm_service.Response?> callMethodWrapper(
String method, {
Expand Down Expand Up @@ -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 {
Expand All @@ -577,6 +580,7 @@ class FlutterVmService {
final Future<void> onRunnable = service.onIsolateEvent.firstWhere((vm_service.Event event) {
return event.kind == vm_service.EventKind.kIsolateRunnable;
});
_logger.printTrace('Calling $kRunInViewMethod...');
await callMethodWrapper(
kRunInViewMethod,
args: <String, Object>{
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter_tools/test/general.shard/vmservice_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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'),
Expand All @@ -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');

Expand All @@ -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');

Expand Down
3 changes: 2 additions & 1 deletion packages/flutter_tools/test/src/fake_vm_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String, Object?> request = json.decode(data) as Map<String, Object?>;
Expand Down

0 comments on commit 7d26350

Please sign in to comment.