This reverts commit 66b01c1f29.
* Add DDS ipv6 support
* Use --dds-port for DDS instead of hijacking --host-vmservice-port
This commit is contained in:
@@ -13,30 +13,24 @@ import 'logger.dart';
|
||||
class DartDevelopmentService {
|
||||
DartDevelopmentService({@required this.logger});
|
||||
|
||||
// TODO(bkonyi): enable once VM service can handle SSE forwarding for
|
||||
// Devtools (https://github.com/flutter/flutter/issues/62507)
|
||||
static const bool ddsDisabled = true;
|
||||
final Logger logger;
|
||||
dds.DartDevelopmentService _ddsInstance;
|
||||
|
||||
Uri get uri => _ddsInstance.uri;
|
||||
|
||||
Future<void> startDartDevelopmentService(
|
||||
Uri observatoryUri,
|
||||
int hostPort,
|
||||
bool ipv6,
|
||||
bool disableServiceAuthCodes,
|
||||
) async {
|
||||
if (ddsDisabled) {
|
||||
logger.printTrace(
|
||||
'DDS is currently disabled due to '
|
||||
'https://github.com/flutter/flutter/issues/62507'
|
||||
);
|
||||
return;
|
||||
}
|
||||
final Uri ddsUri = Uri(
|
||||
scheme: 'http',
|
||||
host: (ipv6 ?
|
||||
io.InternetAddress.loopbackIPv6 :
|
||||
io.InternetAddress.loopbackIPv4
|
||||
).host,
|
||||
port: 0,
|
||||
port: hostPort ?? 0,
|
||||
);
|
||||
logger.printTrace(
|
||||
'Launching a Dart Developer Service (DDS) instance at $ddsUri, '
|
||||
@@ -46,6 +40,8 @@ class DartDevelopmentService {
|
||||
_ddsInstance = await dds.DartDevelopmentService.startDartDevelopmentService(
|
||||
observatoryUri,
|
||||
serviceUri: ddsUri,
|
||||
enableAuthCodes: !disableServiceAuthCodes,
|
||||
ipv6: ipv6,
|
||||
);
|
||||
logger.printTrace('DDS is listening at ${_ddsInstance.uri}.');
|
||||
} on dds.DartDevelopmentServiceException catch (e) {
|
||||
|
||||
@@ -236,12 +236,18 @@ class DriveCommand extends RunCommandBase {
|
||||
}
|
||||
observatoryUri = result.observatoryUri.toString();
|
||||
// TODO(bkonyi): add web support (https://github.com/flutter/flutter/issues/61259)
|
||||
if (!isWebPlatform) {
|
||||
if (!isWebPlatform && !disableDds) {
|
||||
try {
|
||||
// If there's another flutter_tools instance still connected to the target
|
||||
// application, DDS will already be running remotely and this call will fail.
|
||||
// We can ignore this and continue to use the remote DDS instance.
|
||||
await device.dds.startDartDevelopmentService(Uri.parse(observatoryUri), ipv6);
|
||||
await device.dds.startDartDevelopmentService(
|
||||
Uri.parse(observatoryUri),
|
||||
ddsPort,
|
||||
ipv6,
|
||||
disableServiceAuthCodes,
|
||||
);
|
||||
observatoryUri = device.dds.uri.toString();
|
||||
} on dds.DartDevelopmentServiceException catch(_) {
|
||||
globals.printTrace('Note: DDS is already connected to $observatoryUri.');
|
||||
}
|
||||
@@ -480,7 +486,8 @@ Future<LaunchResult> _startApp(
|
||||
debuggingOptions: DebuggingOptions.enabled(
|
||||
command.getBuildInfo(),
|
||||
startPaused: true,
|
||||
hostVmServicePort: command.hostVmservicePort,
|
||||
hostVmServicePort: webUri != null ? command.hostVmservicePort : 0,
|
||||
ddsPort: command.ddsPort,
|
||||
verboseSystemLogs: command.verboseSystemLogs,
|
||||
cacheSkSL: command.cacheSkSL,
|
||||
dumpSkpOnShaderCompilation: command.dumpSkpOnShaderCompilation,
|
||||
|
||||
@@ -66,7 +66,12 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
||||
help: 'A file to write the attached vmservice uri to after an'
|
||||
' application is started.',
|
||||
valueHelp: 'project/example/out.txt'
|
||||
);
|
||||
)
|
||||
..addFlag('disable-service-auth-codes',
|
||||
negatable: false,
|
||||
hide: !verboseHelp,
|
||||
help: 'No longer require an authentication code to connect to the VM '
|
||||
'service (not recommended).');
|
||||
usesWebOptions(hide: !verboseHelp);
|
||||
usesTargetOption();
|
||||
usesPortOptions();
|
||||
@@ -76,13 +81,14 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
|
||||
addNullSafetyModeOptions(hide: !verboseHelp);
|
||||
usesDeviceUserOption();
|
||||
usesDeviceTimeoutOption();
|
||||
addDdsOptions(verboseHelp: verboseHelp);
|
||||
}
|
||||
|
||||
bool get traceStartup => boolArg('trace-startup');
|
||||
bool get cacheSkSL => boolArg('cache-sksl');
|
||||
bool get dumpSkpOnShaderCompilation => boolArg('dump-skp-on-shader-compilation');
|
||||
bool get purgePersistentCache => boolArg('purge-persistent-cache');
|
||||
|
||||
bool get disableServiceAuthCodes => boolArg('disable-service-auth-codes');
|
||||
String get route => stringArg('route');
|
||||
}
|
||||
|
||||
@@ -206,11 +212,6 @@ class RunCommand extends RunCommandBase {
|
||||
'results out to "refresh_benchmark.json", and exit. This flag is '
|
||||
'intended for use in generating automated flutter benchmarks.',
|
||||
)
|
||||
..addFlag('disable-service-auth-codes',
|
||||
negatable: false,
|
||||
hide: !verboseHelp,
|
||||
help: 'No longer require an authentication code to connect to the VM '
|
||||
'service (not recommended).')
|
||||
..addFlag('web-initialize-platform',
|
||||
negatable: true,
|
||||
defaultsTo: true,
|
||||
@@ -227,7 +228,6 @@ class RunCommand extends RunCommandBase {
|
||||
'Currently this is only supported on Android devices. This option '
|
||||
'cannot be paired with --use-application-binary.'
|
||||
);
|
||||
addDdsOptions(verboseHelp: verboseHelp);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -408,6 +408,7 @@ class RunCommand extends RunCommandBase {
|
||||
purgePersistentCache: purgePersistentCache,
|
||||
deviceVmServicePort: deviceVmservicePort,
|
||||
hostVmServicePort: hostVmservicePort,
|
||||
ddsPort: ddsPort,
|
||||
verboseSystemLogs: boolArg('verbose-system-logs'),
|
||||
initializePlatform: boolArg('web-initialize-platform'),
|
||||
hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '',
|
||||
|
||||
@@ -131,6 +131,7 @@ class TestCommand extends FlutterCommand {
|
||||
'This flag is ignored if --start-paused or coverage are requested. '
|
||||
'The vmservice will be enabled no matter what in those cases.'
|
||||
);
|
||||
addDdsOptions(verboseHelp: verboseHelp);
|
||||
}
|
||||
|
||||
/// The interface for starting and configuring the tester.
|
||||
@@ -274,6 +275,7 @@ class TestCommand extends FlutterCommand {
|
||||
enableObservatory: collector != null || startPaused || boolArg('enable-vmservice'),
|
||||
startPaused: startPaused,
|
||||
disableServiceAuthCodes: disableServiceAuthCodes,
|
||||
disableDds: disableDds,
|
||||
ipv6: boolArg('ipv6'),
|
||||
machine: machine,
|
||||
buildMode: BuildMode.debug,
|
||||
|
||||
@@ -789,6 +789,7 @@ class DebuggingOptions {
|
||||
this.verboseSystemLogs = false,
|
||||
this.hostVmServicePort,
|
||||
this.deviceVmServicePort,
|
||||
this.ddsPort,
|
||||
this.initializePlatform = true,
|
||||
this.hostname,
|
||||
this.port,
|
||||
@@ -830,6 +831,7 @@ class DebuggingOptions {
|
||||
verboseSystemLogs = false,
|
||||
hostVmServicePort = null,
|
||||
deviceVmServicePort = null,
|
||||
ddsPort = null,
|
||||
vmserviceOutFile = null,
|
||||
fastStart = false,
|
||||
webEnableExpressionEvaluation = false,
|
||||
@@ -857,6 +859,7 @@ class DebuggingOptions {
|
||||
final bool initializePlatform;
|
||||
final int hostVmServicePort;
|
||||
final int deviceVmServicePort;
|
||||
final int ddsPort;
|
||||
final String port;
|
||||
final String hostname;
|
||||
final bool webEnableExposeUrl;
|
||||
|
||||
@@ -55,8 +55,14 @@ Future<vm_service.VmService> _kDefaultFuchsiaIsolateDiscoveryConnector(Uri uri)
|
||||
Future<void> _kDefaultDartDevelopmentServiceStarter(
|
||||
Device device,
|
||||
Uri observatoryUri,
|
||||
bool disableServiceAuthCodes,
|
||||
) async {
|
||||
await device.dds.startDartDevelopmentService(observatoryUri, true);
|
||||
await device.dds.startDartDevelopmentService(
|
||||
observatoryUri,
|
||||
0,
|
||||
true,
|
||||
disableServiceAuthCodes,
|
||||
);
|
||||
}
|
||||
|
||||
/// Read the log for a particular device.
|
||||
@@ -738,7 +744,7 @@ class FuchsiaIsolateDiscoveryProtocol {
|
||||
final String _isolateName;
|
||||
final Completer<Uri> _foundUri = Completer<Uri>();
|
||||
final Future<vm_service.VmService> Function(Uri) _vmServiceConnector;
|
||||
final Future<void> Function(Device, Uri) _ddsStarter;
|
||||
final Future<void> Function(Device, Uri, bool) _ddsStarter;
|
||||
// whether to only poll once.
|
||||
final bool _pollOnce;
|
||||
Timer _pollingTimer;
|
||||
@@ -781,8 +787,8 @@ class FuchsiaIsolateDiscoveryProtocol {
|
||||
final int localPort = await _device.portForwarder.forward(port);
|
||||
try {
|
||||
final Uri uri = Uri.parse('http://[$_ipv6Loopback]:$localPort');
|
||||
await _ddsStarter(_device, uri);
|
||||
service = await _vmServiceConnector(uri);
|
||||
await _ddsStarter(_device, uri, true);
|
||||
service = await _vmServiceConnector(_device.dds.uri);
|
||||
_ports[port] = service;
|
||||
} on SocketException catch (err) {
|
||||
globals.printTrace('Failed to connect to $localPort: $err');
|
||||
|
||||
@@ -424,8 +424,8 @@ class IOSSimulator extends Device {
|
||||
if (debuggingOptions.skiaDeterministicRendering) '--skia-deterministic-rendering',
|
||||
if (debuggingOptions.useTestFonts) '--use-test-fonts',
|
||||
if (debuggingOptions.traceAllowlist != null) '--trace-allowlist="${debuggingOptions.traceAllowlist}"',
|
||||
if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags'
|
||||
'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}',
|
||||
if (dartVmFlags.isNotEmpty) '--dart-flags=$dartVmFlags',
|
||||
'--observatory-port=${debuggingOptions.hostVmServicePort ?? 0}'
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -237,7 +237,9 @@ Future<Uri> buildObservatoryUri(
|
||||
if (!path.endsWith('/')) {
|
||||
path += '/';
|
||||
}
|
||||
final int actualHostPort = hostVmservicePort ?? await device
|
||||
.portForwarder.forward(devicePort);
|
||||
hostVmservicePort ??= 0;
|
||||
final int actualHostPort = hostVmservicePort == 0 ?
|
||||
await device.portForwarder.forward(devicePort) :
|
||||
hostVmservicePort;
|
||||
return Uri(scheme: 'http', host: host, port: actualHostPort, path: path);
|
||||
}
|
||||
|
||||
@@ -205,6 +205,9 @@ class FlutterDevice {
|
||||
ReloadMethod reloadMethod,
|
||||
GetSkSLMethod getSkSLMethod,
|
||||
PrintStructuredErrorLogMethod printStructuredErrorLogMethod,
|
||||
int hostVmServicePort,
|
||||
int ddsPort,
|
||||
bool disableServiceAuthCodes = false,
|
||||
bool disableDds = false,
|
||||
bool ipv6 = false,
|
||||
}) {
|
||||
@@ -220,12 +223,14 @@ class FlutterDevice {
|
||||
if (!disableDds) {
|
||||
await device.dds.startDartDevelopmentService(
|
||||
observatoryUri,
|
||||
ddsPort,
|
||||
ipv6,
|
||||
disableServiceAuthCodes,
|
||||
);
|
||||
}
|
||||
try {
|
||||
service = await connectToVmService(
|
||||
observatoryUri,
|
||||
disableDds ? observatoryUri : device.dds.uri,
|
||||
reloadSources: reloadSources,
|
||||
restart: restart,
|
||||
compileExpression: compileExpression,
|
||||
@@ -1238,10 +1243,13 @@ abstract class ResidentRunner {
|
||||
restart: restart,
|
||||
compileExpression: compileExpression,
|
||||
disableDds: debuggingOptions.disableDds,
|
||||
ddsPort: debuggingOptions.ddsPort,
|
||||
hostVmServicePort: debuggingOptions.hostVmServicePort,
|
||||
reloadMethod: reloadMethod,
|
||||
getSkSLMethod: getSkSLMethod,
|
||||
printStructuredErrorLogMethod: printStructuredErrorLog,
|
||||
ipv6: ipv6,
|
||||
disableServiceAuthCodes: debuggingOptions.disableServiceAuthCodes
|
||||
);
|
||||
// This will wait for at least one flutter view before returning.
|
||||
final Status status = globals.logger.startProgress(
|
||||
|
||||
@@ -285,7 +285,9 @@ abstract class FlutterCommand extends Command<void> {
|
||||
argParser.addOption(observatoryPortOption,
|
||||
help: '(deprecated use host-vmservice-port instead) '
|
||||
'Listen to the given port for an observatory debugger connection.\n'
|
||||
'Specifying port 0 (the default) will find a random free port.',
|
||||
'Specifying port 0 (the default) will find a random free port.\nNote: '
|
||||
'if the Dart Development Service (DDS) is enabled, this will not be the port '
|
||||
'of the Observatory instance advertised on the command line.',
|
||||
);
|
||||
argParser.addOption('device-vmservice-port',
|
||||
help: 'Look for vmservice connections only from the specified port.\n'
|
||||
@@ -301,6 +303,10 @@ abstract class FlutterCommand extends Command<void> {
|
||||
}
|
||||
|
||||
void addDdsOptions({@required bool verboseHelp}) {
|
||||
argParser.addOption('dds-port',
|
||||
help: 'When this value is provided, the Dart Development Service (DDS) will be '
|
||||
'bound to the provided port.\nSpecifying port 0 (the default) will find '
|
||||
'a random free port.');
|
||||
argParser.addFlag(
|
||||
'disable-dds',
|
||||
hide: !verboseHelp,
|
||||
@@ -313,6 +319,15 @@ abstract class FlutterCommand extends Command<void> {
|
||||
);
|
||||
}
|
||||
|
||||
bool get disableDds => boolArg('disable-dds');
|
||||
|
||||
int get ddsPort {
|
||||
if (argResults.wasParsed('dds-port')) {
|
||||
return int.tryParse(stringArg('dds-port')) ?? 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Gets the vmservice port provided to in the 'observatory-port' or
|
||||
/// 'host-vmservice-port option.
|
||||
///
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:dds/dds.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:stream_channel/stream_channel.dart';
|
||||
@@ -52,6 +53,7 @@ FlutterPlatform installHook({
|
||||
bool machine = false,
|
||||
bool startPaused = false,
|
||||
bool disableServiceAuthCodes = false,
|
||||
bool disableDds = false,
|
||||
int port = 0,
|
||||
String precompiledDillPath,
|
||||
Map<String, String> precompiledDillFiles,
|
||||
@@ -89,6 +91,7 @@ FlutterPlatform installHook({
|
||||
enableObservatory: enableObservatory,
|
||||
startPaused: startPaused,
|
||||
disableServiceAuthCodes: disableServiceAuthCodes,
|
||||
disableDds: disableDds,
|
||||
explicitObservatoryPort: observatoryPort,
|
||||
host: _kHosts[serverType],
|
||||
port: port,
|
||||
@@ -233,6 +236,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
this.machine,
|
||||
this.startPaused,
|
||||
this.disableServiceAuthCodes,
|
||||
this.disableDds,
|
||||
this.explicitObservatoryPort,
|
||||
this.host,
|
||||
this.port,
|
||||
@@ -255,6 +259,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
final bool machine;
|
||||
final bool startPaused;
|
||||
final bool disableServiceAuthCodes;
|
||||
final bool disableDds;
|
||||
final int explicitObservatoryPort;
|
||||
final InternetAddress host;
|
||||
final int port;
|
||||
@@ -402,7 +407,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
controllerSinkClosed = true;
|
||||
}));
|
||||
|
||||
// Prepare our WebSocket server to talk to the engine subproces.
|
||||
// Prepare our WebSocket server to talk to the engine subprocess.
|
||||
final HttpServer server = await bind(host, port);
|
||||
finalizers.add(() async {
|
||||
globals.printTrace('test $ourTestCount: shutting down test harness socket server');
|
||||
@@ -496,15 +501,17 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
assert(processObservatoryUri == null);
|
||||
assert(explicitObservatoryPort == null ||
|
||||
explicitObservatoryPort == detectedUri.port);
|
||||
if (startPaused && !machine) {
|
||||
globals.printStatus('The test process has been started.');
|
||||
globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
|
||||
globals.printStatus(' $detectedUri');
|
||||
globals.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
|
||||
if (!disableDds) {
|
||||
final DartDevelopmentService dds = await DartDevelopmentService.startDartDevelopmentService(
|
||||
detectedUri,
|
||||
enableAuthCodes: !disableServiceAuthCodes,
|
||||
ipv6: host.type == InternetAddressType.IPv6,
|
||||
);
|
||||
processObservatoryUri = dds.uri;
|
||||
globals.printTrace('Dart Development Service started at ${dds.uri}, forwarding to VM service at ${dds.remoteVmServiceUri}.');
|
||||
} else {
|
||||
globals.printTrace('test $ourTestCount: using observatory uri $detectedUri from pid ${process.pid}');
|
||||
processObservatoryUri = detectedUri;
|
||||
}
|
||||
processObservatoryUri = detectedUri;
|
||||
{
|
||||
globals.printTrace('Connecting to service protocol: $processObservatoryUri');
|
||||
final Future<vm_service.VmService> localVmService = connectToVmService(processObservatoryUri,
|
||||
@@ -513,6 +520,14 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
globals.printTrace('Successfully connected to service protocol: $processObservatoryUri');
|
||||
}));
|
||||
}
|
||||
if (startPaused && !machine) {
|
||||
globals.printStatus('The test process has been started.');
|
||||
globals.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
|
||||
globals.printStatus(' $processObservatoryUri');
|
||||
globals.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
|
||||
} else {
|
||||
globals.printTrace('test $ourTestCount: using observatory uri $processObservatoryUri from pid ${process.pid}');
|
||||
}
|
||||
gotProcessObservatoryUri.complete();
|
||||
watcher?.handleStartedProcess(
|
||||
ProcessEvent(ourTestCount, process, processObservatoryUri));
|
||||
|
||||
@@ -34,6 +34,7 @@ abstract class FlutterTestRunner {
|
||||
bool enableObservatory = false,
|
||||
bool startPaused = false,
|
||||
bool disableServiceAuthCodes = false,
|
||||
bool disableDds = false,
|
||||
bool ipv6 = false,
|
||||
bool machine = false,
|
||||
String precompiledDillPath,
|
||||
@@ -69,6 +70,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
bool enableObservatory = false,
|
||||
bool startPaused = false,
|
||||
bool disableServiceAuthCodes = false,
|
||||
bool disableDds = false,
|
||||
bool ipv6 = false,
|
||||
bool machine = false,
|
||||
String precompiledDillPath,
|
||||
@@ -167,6 +169,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
machine: machine,
|
||||
startPaused: startPaused,
|
||||
disableServiceAuthCodes: disableServiceAuthCodes,
|
||||
disableDds: disableDds,
|
||||
serverType: serverType,
|
||||
precompiledDillPath: precompiledDillPath,
|
||||
precompiledDillFiles: precompiledDillFiles,
|
||||
|
||||
Reference in New Issue
Block a user