Don't eagerly call runMain when --start-paused is provided to web application (#42144)
This commit is contained in:
@@ -259,7 +259,17 @@ class ResidentWebRunner extends ResidentRunner {
|
||||
unawaited(_vmService.registerService('reloadSources', 'FlutterTools'));
|
||||
websocketUri = Uri.parse(_connectionResult.debugConnection.uri);
|
||||
// Always run main after connecting because start paused doesn't work yet.
|
||||
_connectionResult.appConnection.runMain();
|
||||
if (!debuggingOptions.startPaused || !supportsServiceProtocol) {
|
||||
_connectionResult.appConnection.runMain();
|
||||
} else {
|
||||
StreamSubscription<void> resumeSub;
|
||||
resumeSub = _connectionResult.debugConnection.vmService.onDebugEvent.listen((vmservice.Event event) {
|
||||
if (event.type == vmservice.EventKind.kResume) {
|
||||
_connectionResult.appConnection.runMain();
|
||||
resumeSub.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (websocketUri != null) {
|
||||
printStatus('Debug service listening on $websocketUri');
|
||||
|
||||
@@ -83,6 +83,9 @@ void main() {
|
||||
when(mockVmService.onStdoutEvent).thenAnswer((Invocation _) {
|
||||
return const Stream<Event>.empty();
|
||||
});
|
||||
when(mockVmService.onDebugEvent).thenAnswer((Invocation _) {
|
||||
return const Stream<Event>.empty();
|
||||
});
|
||||
when(mockDebugConnection.uri).thenReturn('ws://127.0.0.1/abcd/');
|
||||
}
|
||||
|
||||
@@ -174,6 +177,27 @@ void main() {
|
||||
expect(bufferLogger.statusText, contains('THIS MESSAGE IS IMPORTANT'));
|
||||
}));
|
||||
|
||||
test('Does not run main with --start-paused', () => testbed.run(() async {
|
||||
residentWebRunner = ResidentWebRunner(
|
||||
mockWebDevice,
|
||||
flutterProject: FlutterProject.current(),
|
||||
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true),
|
||||
ipv6: true,
|
||||
);
|
||||
_setupMocks();
|
||||
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
|
||||
final StreamController<Event> controller = StreamController<Event>.broadcast();
|
||||
when(mockVmService.onStdoutEvent).thenAnswer((Invocation _) {
|
||||
return controller.stream;
|
||||
});
|
||||
unawaited(residentWebRunner.run(
|
||||
connectionInfoCompleter: connectionInfoCompleter,
|
||||
));
|
||||
await connectionInfoCompleter.future;
|
||||
|
||||
verifyNever(mockAppConnection.runMain());
|
||||
}));
|
||||
|
||||
test('Can hot reload after attaching', () => testbed.run(() async {
|
||||
_setupMocks();
|
||||
final BufferLogger bufferLogger = logger;
|
||||
|
||||
Reference in New Issue
Block a user