Unverified Commit 2c1d12d4 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Add a detach command to detach without terminating" (#21464)

parent 409baff3
...@@ -92,12 +92,6 @@ The `callServiceExtension()` allows clients to make arbitrary calls to service p ...@@ -92,12 +92,6 @@ The `callServiceExtension()` allows clients to make arbitrary calls to service p
- `methodName`: the name of the service protocol extension to invoke; this is required. - `methodName`: the name of the service protocol extension to invoke; this is required.
- `params`: an optional Map of parameters to pass to the service protocol extension. - `params`: an optional Map of parameters to pass to the service protocol extension.
#### app.detach
The `detach()` command takes one parameter, `appId`. It returns a `bool` to indicate success or failure in detaching from an app without stopping it.
- `appId`: the id of a previously started app; this is required.
#### app.stop #### app.stop
The `stop()` command takes one parameter, `appId`. It returns a `bool` to indicate success or failure in stopping an app. The `stop()` command takes one parameter, `appId`. It returns a `bool` to indicate success or failure in stopping an app.
...@@ -116,7 +110,7 @@ This is sent when an observatory port is available for a started app. The `param ...@@ -116,7 +110,7 @@ This is sent when an observatory port is available for a started app. The `param
#### app.started #### app.started
This is sent once the application launch process is complete and the app is either paused before main() (if `startPaused` is true) or main() has begun running. When attaching, this even will be fired once attached. The `params` field will be a map containing the field `appId`. This is sent once the application launch process is complete and the app is either paused before main() (if `startPaused` is true) or main() has begun running. The `params` field will be a map containing the field `appId`.
#### app.log #### app.log
...@@ -128,7 +122,7 @@ This is sent when an operation starts and again when it stops. When an operation ...@@ -128,7 +122,7 @@ This is sent when an operation starts and again when it stops. When an operation
#### app.stop #### app.stop
This is sent when an app is stopped or detached from. The `params` field will be a map with the field `appId`. This is sent when an app is stopped. The `params` field will be a map with the field `appId`.
### device domain ### device domain
...@@ -210,7 +204,6 @@ The following subset of the app domain is available in `flutter run --machine`. ...@@ -210,7 +204,6 @@ The following subset of the app domain is available in `flutter run --machine`.
- Commands - Commands
- [`restart`](#apprestart) - [`restart`](#apprestart)
- [`callServiceExtension`](#appcallserviceextension) - [`callServiceExtension`](#appcallserviceextension)
- [`detach`](#appdetach)
- [`stop`](#appstop) - [`stop`](#appstop)
- Events - Events
- [`start`](#appstart) - [`start`](#appstart)
...@@ -226,7 +219,6 @@ See the [source](https://github.com/flutter/flutter/blob/master/packages/flutter ...@@ -226,7 +219,6 @@ See the [source](https://github.com/flutter/flutter/blob/master/packages/flutter
## Changelog ## Changelog
- 0.4.2: Added `app.detach` command
- 0.4.1: Added `flutter attach --machine` - 0.4.1: Added `flutter attach --machine`
- 0.4.0: Added `emulator.create` command - 0.4.0: Added `emulator.create` command
- 0.3.0: Added `daemon.connected` event at startup - 0.3.0: Added `daemon.connected` event at startup
...@@ -28,7 +28,7 @@ import '../runner/flutter_command.dart'; ...@@ -28,7 +28,7 @@ import '../runner/flutter_command.dart';
import '../tester/flutter_tester.dart'; import '../tester/flutter_tester.dart';
import '../vmservice.dart'; import '../vmservice.dart';
const String protocolVersion = '0.4.2'; const String protocolVersion = '0.4.1';
/// A server process command. This command will start up a long-lived server. /// A server process command. This command will start up a long-lived server.
/// It reads JSON-RPC based commands from stdin, executes them, and returns /// It reads JSON-RPC based commands from stdin, executes them, and returns
...@@ -316,7 +316,6 @@ class AppDomain extends Domain { ...@@ -316,7 +316,6 @@ class AppDomain extends Domain {
registerHandler('restart', restart); registerHandler('restart', restart);
registerHandler('callServiceExtension', callServiceExtension); registerHandler('callServiceExtension', callServiceExtension);
registerHandler('stop', stop); registerHandler('stop', stop);
registerHandler('detach', detach);
} }
static final Uuid _uuidGenerator = new Uuid(); static final Uuid _uuidGenerator = new Uuid();
...@@ -517,23 +516,6 @@ class AppDomain extends Domain { ...@@ -517,23 +516,6 @@ class AppDomain extends Domain {
}); });
} }
Future<bool> detach(Map<String, dynamic> args) async {
final String appId = _getStringArg(args, 'appId', required: true);
final AppInstance app = _getApp(appId);
if (app == null)
throw "app '$appId' not found";
return app.detach().timeout(const Duration(seconds: 5)).then<bool>((_) {
return true;
}).catchError((dynamic error) {
_sendAppEvent(app, 'log', <String, dynamic>{ 'log': '$error', 'error': true });
app.closeLogger();
_apps.remove(app);
return false;
});
}
AppInstance _getApp(String id) { AppInstance _getApp(String id) {
return _apps.firstWhere((AppInstance app) => app.id == id, orElse: () => null); return _apps.firstWhere((AppInstance app) => app.id == id, orElse: () => null);
} }
...@@ -787,7 +769,6 @@ class AppInstance { ...@@ -787,7 +769,6 @@ class AppInstance {
} }
Future<Null> stop() => runner.stop(); Future<Null> stop() => runner.stop();
Future<Null> detach() => runner.detach();
void closeLogger() { void closeLogger() {
_logger.close(); _logger.close();
......
...@@ -66,7 +66,6 @@ class HotRunner extends ResidentRunner { ...@@ -66,7 +66,6 @@ class HotRunner extends ResidentRunner {
final bool benchmarkMode; final bool benchmarkMode;
final File applicationBinary; final File applicationBinary;
final bool hostIsIde; final bool hostIsIde;
bool _didAttach = false;
Set<String> _dartDependencies; Set<String> _dartDependencies;
final String dillOutputPath; final String dillOutputPath;
...@@ -153,7 +152,6 @@ class HotRunner extends ResidentRunner { ...@@ -153,7 +152,6 @@ class HotRunner extends ResidentRunner {
Completer<void> appStartedCompleter, Completer<void> appStartedCompleter,
String viewFilter, String viewFilter,
}) async { }) async {
_didAttach = true;
try { try {
await connectToServiceProtocol(viewFilter: viewFilter, await connectToServiceProtocol(viewFilter: viewFilter,
reloadSources: _reloadSourcesService, reloadSources: _reloadSourcesService,
...@@ -753,26 +751,19 @@ class HotRunner extends ResidentRunner { ...@@ -753,26 +751,19 @@ class HotRunner extends ResidentRunner {
for (Uri uri in device.observatoryUris) for (Uri uri in device.observatoryUris)
printStatus('An Observatory debugger and profiler on $dname is available at: $uri'); printStatus('An Observatory debugger and profiler on $dname is available at: $uri');
} }
final String quitMessage = _didAttach
? 'To detach, press "d"; to quit, press "q".'
: 'To quit, press "q".';
if (details) { if (details) {
printHelpDetails(); printHelpDetails();
printStatus('To repeat this help message, press "h". $quitMessage'); printStatus('To repeat this help message, press "h". To quit, press "q".');
} else { } else {
printStatus('For a more detailed help message, press "h". $quitMessage'); printStatus('For a more detailed help message, press "h". To quit, press "q".');
} }
} }
@override @override
Future<Null> cleanupAfterSignal() async { Future<Null> cleanupAfterSignal() async {
await stopEchoingDeviceLog(); await stopEchoingDeviceLog();
if (_didAttach) {
appFinished();
} else {
await stopApp(); await stopApp();
} }
}
@override @override
Future<Null> preStop() => _cleanupDevFS(); Future<Null> preStop() => _cleanupDevFS();
......
...@@ -6,6 +6,7 @@ import 'package:file/file.dart'; ...@@ -6,6 +6,7 @@ import 'package:file/file.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart';
import 'test_data/basic_project.dart'; import 'test_data/basic_project.dart';
import 'test_driver.dart'; import 'test_driver.dart';
...@@ -17,35 +18,23 @@ void main() { ...@@ -17,35 +18,23 @@ void main() {
setUp(() async { setUp(() async {
tempDir = fs.systemTempDirectory.createTempSync('flutter_attach_test.'); tempDir = fs.systemTempDirectory.createTempSync('flutter_attach_test.');
await _project.setUpIn(tempDir); await _project.setUpIn(tempDir);
_flutterRun = new FlutterTestDriver(tempDir, logPrefix: 'RUN'); _flutterRun = new FlutterTestDriver(tempDir);
_flutterAttach = new FlutterTestDriver(tempDir, logPrefix: 'ATTACH'); _flutterAttach = new FlutterTestDriver(tempDir);
}); });
tearDown(() async { tearDown(() async {
await _flutterAttach.detach(); // We can't call stop() on both of these because they'll both try to stop the
// same app. Just quit the attach process and then send a stop to the original
// process.
await _flutterRun.stop(); await _flutterRun.stop();
await _flutterAttach.quit();
tryToDelete(tempDir); tryToDelete(tempDir);
}); });
group('attached process', () { group('attached process', () {
test('can hot reload', () async { testUsingContext('can hot reload', () async {
await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload();
});
test('can detach, reattach, hot reload', () async {
await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.detach();
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload();
});
test('killing process behaves the same as detach ', () async {
await _flutterRun.run(withDebugger: true); await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort); await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.quit();
_flutterAttach = new FlutterTestDriver(tempDir, logPrefix: 'ATTACH-2');
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload(); await _flutterAttach.hotReload();
}); });
}, timeout: const Timeout.factor(6)); }, timeout: const Timeout.factor(6));
......
...@@ -23,11 +23,9 @@ const Duration appStartTimeout = Duration(seconds: 120); ...@@ -23,11 +23,9 @@ const Duration appStartTimeout = Duration(seconds: 120);
const Duration quitTimeout = Duration(seconds: 10); const Duration quitTimeout = Duration(seconds: 10);
class FlutterTestDriver { class FlutterTestDriver {
FlutterTestDriver(this._projectFolder, {String logPrefix}): FlutterTestDriver(this._projectFolder);
this._logPrefix = logPrefix != null ? '$logPrefix: ' : '';
final Directory _projectFolder; final Directory _projectFolder;
final String _logPrefix;
Process _proc; Process _proc;
int _procPid; int _procPid;
final StreamController<String> _stdout = new StreamController<String>.broadcast(); final StreamController<String> _stdout = new StreamController<String>.broadcast();
...@@ -51,7 +49,7 @@ class FlutterTestDriver { ...@@ -51,7 +49,7 @@ class FlutterTestDriver {
msg.length > maxLength ? msg.substring(0, maxLength) + '...' : msg; msg.length > maxLength ? msg.substring(0, maxLength) + '...' : msg;
_allMessages.add(truncatedMsg); _allMessages.add(truncatedMsg);
if (_printJsonAndStderr) { if (_printJsonAndStderr) {
print('$_logPrefix$truncatedMsg'); print(truncatedMsg);
} }
return msg; return msg;
} }
...@@ -164,31 +162,6 @@ class FlutterTestDriver { ...@@ -164,31 +162,6 @@ class FlutterTestDriver {
_throwErrorResponse('Hot ${fullRestart ? 'restart' : 'reload'} request failed'); _throwErrorResponse('Hot ${fullRestart ? 'restart' : 'reload'} request failed');
} }
Future<int> detach() async {
if (vmService != null) {
_debugPrint('Closing VM service');
await vmService.close()
.timeout(quitTimeout,
onTimeout: () { _debugPrint('VM Service did not quit within $quitTimeout'); });
}
if (_currentRunningAppId != null) {
_debugPrint('Detaching from app');
await Future.any<void>(<Future<void>>[
_proc.exitCode,
_sendRequest(
'app.detach',
<String, dynamic>{'appId': _currentRunningAppId}
),
]).timeout(
quitTimeout,
onTimeout: () { _debugPrint('app.detach did not return within $quitTimeout'); }
);
_currentRunningAppId = null;
}
_debugPrint('Waiting for process to end');
return _proc.exitCode.timeout(quitTimeout, onTimeout: _killGracefully);
}
Future<int> stop() async { Future<int> stop() async {
if (vmService != null) { if (vmService != null) {
_debugPrint('Closing VM service'); _debugPrint('Closing VM service');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment