mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Shut down DevTools and DDS processes if flutter_tools is killed by a signal (#159238)
See https://github.com/flutter/flutter/issues/159154
This commit is contained in:
parent
c7dd6419d9
commit
efe8737ea0
@ -69,7 +69,6 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
|||||||
final ResidentRunner _residentRunner;
|
final ResidentRunner _residentRunner;
|
||||||
final Logger _logger;
|
final Logger _logger;
|
||||||
bool _shutdown = false;
|
bool _shutdown = false;
|
||||||
bool _served = false;
|
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
bool launchedInBrowser = false;
|
bool launchedInBrowser = false;
|
||||||
@ -105,7 +104,6 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
|||||||
_devToolsLauncher.devToolsUrl = devToolsServerAddress;
|
_devToolsLauncher.devToolsUrl = devToolsServerAddress;
|
||||||
} else {
|
} else {
|
||||||
await _devToolsLauncher.serve();
|
await _devToolsLauncher.serve();
|
||||||
_served = true;
|
|
||||||
}
|
}
|
||||||
await _devToolsLauncher.ready;
|
await _devToolsLauncher.ready;
|
||||||
// Do not attempt to print debugger list if the connection has failed or if we're shutting down.
|
// Do not attempt to print debugger list if the connection has failed or if we're shutting down.
|
||||||
@ -305,7 +303,7 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
|
|||||||
@override
|
@override
|
||||||
Future<void> shutdown() async {
|
Future<void> shutdown() async {
|
||||||
_shutdown = true;
|
_shutdown = true;
|
||||||
if (_devToolsLauncher == null || !_served) {
|
if (_devToolsLauncher == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_readyToAnnounce = false;
|
_readyToAnnounce = false;
|
||||||
|
@ -1248,8 +1248,10 @@ class HotRunner extends ResidentRunner {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> cleanupAfterSignal() async {
|
Future<void> cleanupAfterSignal() async {
|
||||||
|
await residentDevtoolsHandler!.shutdown();
|
||||||
await stopEchoingDeviceLog();
|
await stopEchoingDeviceLog();
|
||||||
await hotRunnerConfig!.runPreShutdownOperations();
|
await hotRunnerConfig!.runPreShutdownOperations();
|
||||||
|
shutdownDartDevelopmentService();
|
||||||
if (stopAppDuringCleanup) {
|
if (stopAppDuringCleanup) {
|
||||||
return exitApp();
|
return exitApp();
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class FakeDevice extends Fake implements Device {
|
|||||||
bool disposed = false;
|
bool disposed = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final DartDevelopmentService dds = _FakeDartDevelopmentService();
|
final DartDevelopmentService dds = FakeDartDevelopmentService();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool isSupported() => true;
|
bool isSupported() => true;
|
||||||
@ -94,9 +94,13 @@ class FakeDevice extends Fake implements Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
|
class FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
|
||||||
|
bool wasShutdown = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void shutdown() {}
|
void shutdown() {
|
||||||
|
wasShutdown = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeFlutterDevice extends Fake implements FlutterDevice {
|
class FakeFlutterDevice extends Fake implements FlutterDevice {
|
||||||
|
@ -9,6 +9,7 @@ import 'package:flutter_tools/src/compile.dart';
|
|||||||
import 'package:flutter_tools/src/devfs.dart';
|
import 'package:flutter_tools/src/devfs.dart';
|
||||||
import 'package:flutter_tools/src/device.dart';
|
import 'package:flutter_tools/src/device.dart';
|
||||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||||
|
import 'package:flutter_tools/src/resident_devtools_handler.dart';
|
||||||
import 'package:flutter_tools/src/resident_runner.dart';
|
import 'package:flutter_tools/src/resident_runner.dart';
|
||||||
import 'package:flutter_tools/src/run_hot.dart';
|
import 'package:flutter_tools/src/run_hot.dart';
|
||||||
import 'package:flutter_tools/src/vmservice.dart';
|
import 'package:flutter_tools/src/vmservice.dart';
|
||||||
@ -56,11 +57,14 @@ void main() {
|
|||||||
target: 'main.dart',
|
target: 'main.dart',
|
||||||
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
|
debuggingOptions: DebuggingOptions.disabled(BuildInfo.debug),
|
||||||
analytics: _FakeAnalytics(),
|
analytics: _FakeAnalytics(),
|
||||||
|
devtoolsHandler: createNoOpHandler,
|
||||||
);
|
);
|
||||||
|
|
||||||
await runner.run();
|
await runner.run();
|
||||||
await runner.cleanupAfterSignal();
|
await runner.cleanupAfterSignal();
|
||||||
expect(flutterDevice.wasExited, true);
|
expect(flutterDevice.wasExited, true);
|
||||||
|
expect((flutterDevice.device.dds as FakeDartDevelopmentService).wasShutdown, true);
|
||||||
|
expect((runner.residentDevtoolsHandler! as NoOpDevtoolsHandler).wasShutdown, true);
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
FileSystem: () => fileSystem,
|
FileSystem: () => fileSystem,
|
||||||
|
Loading…
Reference in New Issue
Block a user