[fuchsia] Fixes for Fuchsia hot reload (#16317)
diff --git a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
index 9de810b..ef94ed6 100644
--- a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
+++ b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart
@@ -4,6 +4,7 @@
import 'dart:async';
import 'dart:collection';
+import 'dart:convert';
import '../base/common.dart';
import '../base/file_system.dart';
@@ -41,6 +42,10 @@
argParser.addOption('gn-target',
abbr: 'g',
help: 'GN target of the application, e.g //path/to/app:app.');
+ argParser.addOption('isolate-number',
+ abbr: 'i',
+ help: 'To reload only one instance, specify the isolate number, e.g. '
+ 'the number in foo\$main-###### given by --list.');
argParser.addFlag('list',
abbr: 'l',
defaultsTo: false,
@@ -48,10 +53,10 @@
argParser.addOption('name-override',
abbr: 'n',
help: 'On-device name of the application binary.');
- argParser.addOption('isolate-number',
- abbr: 'i',
- help: 'To reload only one instance, specify the isolate number, e.g. '
- 'the number in foo\$main-###### given by --list.');
+ argParser.addFlag('preview-dart-2',
+ abbr: '2',
+ defaultsTo: false,
+ help: 'Preview Dart 2.0 functionality.');
argParser.addOption('target',
abbr: 't',
defaultsTo: flx.defaultMainPath,
@@ -178,6 +183,8 @@
printTrace('Looing for view $viewFilter');
final List<int> result = <int>[];
for (FlutterView v in await _getViews(ports)) {
+ if (v.uiIsolate == null)
+ continue;
final Uri addr = v.owner.vmService.httpAddress;
printTrace('At $addr, found view: ${v.uiIsolate.name}');
if (v.uiIsolate.name.contains(viewFilter))
@@ -355,11 +362,15 @@
return <String>[path, name];
}
- Future<List<_PortForwarder>> _forwardPorts(List<int> remotePorts) {
+ Future<List<_PortForwarder>> _forwardPorts(List<int> remotePorts) async {
final String config = '$_buildDir/ssh-keys/ssh_config';
- return Future.wait(remotePorts.map((int remotePort) {
- return _PortForwarder.start(config, _address, remotePort);
- }));
+ final List<_PortForwarder> forwarders = <_PortForwarder>[];
+ for (int port in remotePorts) {
+ final _PortForwarder f =
+ await _PortForwarder.start(config, _address, port);
+ forwarders.add(f);
+ }
+ return forwarders;
}
Future<List<int>> _getServicePorts() async {
@@ -421,10 +432,14 @@
return new _PortForwarder._(null, 0, 0, null, null);
}
final List<String> command = <String>[
- 'ssh', '-F', sshConfig, '-nNT',
+ 'ssh', '-F', sshConfig, '-nNT', '-vvv',
'-L', '$localPort:$ipv4Loopback:$remotePort', address];
printTrace("_PortForwarder running '${command.join(' ')}'");
final Process process = await processManager.start(command);
+ process.stderr
+ .transform(utf8.decoder)
+ .transform(const LineSplitter())
+ .listen((String data) { printTrace(data); });
process.exitCode.then((int c) {
printTrace("'${command.join(' ')}' exited with exit code $c");
});
@@ -440,7 +455,7 @@
}
// Cancel the forwarding request.
final List<String> command = <String>[
- 'ssh', '-F', _sshConfig, '-O', 'cancel',
+ 'ssh', '-F', _sshConfig, '-O', 'cancel', '-vvv',
'-L', '$_localPort:$ipv4Loopback:$_remotePort', _remoteAddress];
final ProcessResult result = await processManager.run(command);
printTrace(command.join(' '));