Reintroduce verbose logging for hot reload flake (#152639)

Adds some logging to assist with troubleshooting https://github.com/flutter/flutter/issues/152220 (which is a reapperance of flake https://github.com/flutter/flutter/issues/146879) on CI.

TL;DR [the tool sometimes never receives the `IsolateRunnable` event from the vm service after calling `_flutter.runInView`](https://github.com/flutter/flutter/issues/146879#issuecomment-2118629953).
This commit is contained in:
Andrew Kolos 2024-07-31 16:15:17 -07:00 committed by GitHub
parent d62069ff37
commit 535e88b092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 10 deletions

View File

@ -643,14 +643,6 @@ class HotRunner extends ResidentRunner {
final Future<vm_service.Isolate?> reloadIsolate = device.vmService!
.getIsolateOrNull(view.uiIsolate!.id!);
operations.add(reloadIsolate.then((vm_service.Isolate? isolate) async {
// TODO(andrewkolos): this race is meant to assist in debugging
// https://github.com/flutter/flutter/issues/145812. When the issue
// is resolved, this trace (and probably all others added by
// the same PR) can be removed.
globals.logger.printTrace(
'Beginning of UI start paused handler. '
'uiIsolate = $isolate; isolate.pauseEvent.kind = ${isolate?.pauseEvent!.kind}',
);
if ((isolate != null) && isPauseEvent(isolate.pauseEvent!.kind!)) {
// The embedder requires that the isolate is unpaused, because the
// runInView method requires interaction with dart engine APIs that
@ -673,7 +665,6 @@ class HotRunner extends ResidentRunner {
await Future.wait(breakpointAndExceptionRemoval);
await device.vmService!.service.resume(view.uiIsolate!.id!);
}
globals.logger.printTrace('End of UI start paused handler.');
}));
}

View File

@ -578,6 +578,25 @@ class FlutterVmService {
}
}
// TODO(andrewkolos): this is to assist in troubleshooting
// https://github.com/flutter/flutter/issues/152220 and should be reverted
// once this issue is resolved.
final StreamSubscription<String> onReceiveSubscription = service.onReceive.listen(
(String message) {
globals.logger.printTrace(
'runInView VM service onReceive listener received "$message"',
);
final dynamic messageAsJson = jsonDecode(message);
// ignore: avoid_dynamic_calls -- Temporary code.
final dynamic messageKind = messageAsJson['params']?['event']?['kind'];
if (messageKind == 'IsolateRunnable') {
globals.logger.printTrace(
'Received IsolateRunnable event from onReceive.',
);
}
},
);
final Future<void> onRunnable = service.onIsolateEvent.firstWhere((vm_service.Event event) {
return event.kind == vm_service.EventKind.kIsolateRunnable;
});
@ -590,6 +609,7 @@ class FlutterVmService {
},
);
await onRunnable;
await onReceiveSubscription.cancel();
}
Future<String> flutterDebugDumpApp({

View File

@ -231,7 +231,7 @@ void main() {
});
});
testWithoutContext('runInView forwards arguments correctly', () async {
testUsingContext('runInView forwards arguments correctly', () async {
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
requests: <VmServiceExpectation>[
const FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{