Reland "Remove references to Observatory (#118577)" (#121606)

This reverts commit 275ab9c69b.
This commit is contained in:
Ben Konyi
2023-02-28 11:57:04 -05:00
committed by GitHub
parent 8fc499aaf0
commit ecd7518df5
90 changed files with 519 additions and 491 deletions

View File

@@ -599,12 +599,12 @@ class AndroidDevice extends Device {
}
final bool traceStartup = platformArgs['trace-startup'] as bool? ?? false;
ProtocolDiscovery? observatoryDiscovery;
ProtocolDiscovery? vmServiceDiscovery;
if (debuggingOptions.debuggingEnabled) {
observatoryDiscovery = ProtocolDiscovery.observatory(
vmServiceDiscovery = ProtocolDiscovery.vmService(
// Avoid using getLogReader, which returns a singleton instance, because the
// observatory discovery will dispose at the end. creating a new logger here allows
// VM Service discovery will dipose at the end. creating a new logger here allows
// logs to be surfaced normally during `flutter drive`.
await AdbLogReader.createLogReader(
this,
@@ -687,13 +687,13 @@ class AndroidDevice extends Device {
}
// Wait for the service protocol port here. This will complete once the
// device has printed "Observatory is listening on...".
_logger.printTrace('Waiting for observatory port to be available...');
// device has printed "VM Service is listening on...".
_logger.printTrace('Waiting for VM Service port to be available...');
try {
Uri? observatoryUri;
Uri? vmServiceUri;
if (debuggingOptions.buildInfo.isDebug || debuggingOptions.buildInfo.isProfile) {
observatoryUri = await observatoryDiscovery?.uri;
if (observatoryUri == null) {
vmServiceUri = await vmServiceDiscovery?.uri;
if (vmServiceUri == null) {
_logger.printError(
'Error waiting for a debug connection: '
'The log reader stopped unexpectedly',
@@ -701,12 +701,12 @@ class AndroidDevice extends Device {
return LaunchResult.failed();
}
}
return LaunchResult.succeeded(observatoryUri: observatoryUri);
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
} on Exception catch (error) {
_logger.printError('Error waiting for a debug connection: $error');
return LaunchResult.failed();
} finally {
await observatoryDiscovery?.cancel();
await vmServiceDiscovery?.cancel();
}
}

View File

@@ -35,7 +35,7 @@ class DartDevelopmentService {
final Completer<void> _completer = Completer<void>();
Future<void> startDartDevelopmentService(
Uri observatoryUri, {
Uri vmServiceUri, {
required Logger logger,
int? hostPort,
bool? ipv6,
@@ -49,11 +49,11 @@ class DartDevelopmentService {
);
logger.printTrace(
'Launching a Dart Developer Service (DDS) instance at $ddsUri, '
'connecting to VM service at $observatoryUri.',
'connecting to VM service at $vmServiceUri.',
);
try {
_ddsInstance = await ddsLauncherCallback(
observatoryUri,
vmServiceUri,
serviceUri: ddsUri,
enableAuthCodes: disableServiceAuthCodes != true,
ipv6: ipv6 ?? false,

View File

@@ -394,16 +394,16 @@ class BuildMode {
throw ArgumentError('$value is not a supported build mode');
}
/// Built in JIT mode with no optimizations, enabled asserts, and an observatory.
/// Built in JIT mode with no optimizations, enabled asserts, and a VM service.
static const BuildMode debug = BuildMode._('debug');
/// Built in AOT mode with some optimizations and an observatory.
/// Built in AOT mode with some optimizations and a VM service.
static const BuildMode profile = BuildMode._('profile');
/// Built in AOT mode with all optimizations and no observatory.
/// Built in AOT mode with all optimizations and no VM service.
static const BuildMode release = BuildMode._('release');
/// Built in JIT mode with all optimizations and no observatory.
/// Built in JIT mode with all optimizations and no VM service.
static const BuildMode jitRelease = BuildMode._('jit_release');
static const List<BuildMode> values = <BuildMode>[

View File

@@ -56,7 +56,7 @@ import '../vmservice.dart';
/// ```
/// $ flutter attach
/// ```
/// As soon as a new observatory is detected the command attaches to it and
/// As soon as a new VM Service is detected the command attaches to it and
/// enables hot reloading.
///
/// To attach to a flutter mod running on a fuchsia device, `--module` must
@@ -97,18 +97,18 @@ class AttachCommand extends FlutterCommand {
..addOption(
'debug-port',
hide: !verboseHelp,
help: '(deprecated) Device port where the observatory is listening. Requires '
help: '(deprecated) Device port where the Dart VM Service is listening. Requires '
'"--disable-service-auth-codes" to also be provided to the Flutter '
'application at launch, otherwise this command will fail to connect to '
'the application. In general, "--debug-url" should be used instead.',
)..addOption(
'debug-url',
aliases: <String>[ 'debug-uri' ], // supported for historical reasons
help: 'The URL at which the observatory is listening.',
help: 'The URL at which the Dart VM Service is listening.',
)..addOption(
'app-id',
help: 'The package name (Android) or bundle identifier (iOS) for the app. '
'This can be specified to avoid being prompted if multiple observatory ports '
'This can be specified to avoid being prompted if multiple Dart VM Service ports '
'are advertised.\n'
'If you have multiple devices or emulators running, you should include the '
'device hostname as well, e.g. "com.example.myApp@my-iphone".\n'
@@ -169,7 +169,7 @@ For Fuchsia, the module name must be provided, e.g. `$flutter attach
--module=mod_name`. This can be called either before or after the application
is started.
If the app or module is already running and the specific observatory port is
If the app or module is already running and the specific vmService port is
known, it can be explicitly provided to attach via the command-line, e.g.
`$ flutter attach --debug-port 12345`''';
@@ -225,10 +225,10 @@ known, it can be explicitly provided to attach via the command-line, e.g.
'the value of --ipv6 on its own.',
);
}
if (debugPort == null && debugUri == null && argResults!.wasParsed(FlutterCommand.observatoryPortOption)) {
if (debugPort == null && debugUri == null && argResults!.wasParsed(FlutterCommand.vmServicePortOption)) {
throwToolExit(
'When the --debug-port or --debug-url is unknown, this command does not use '
'the value of --observatory-port.',
'the value of --vm-service-port.',
);
}
if (debugPort != null && debugUri != null) {
@@ -281,7 +281,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
)
: null;
Stream<Uri>? observatoryUri;
Stream<Uri>? vmServiceUri;
bool usesIpv6 = ipv6!;
final String ipv6Loopback = InternetAddress.loopbackIPv6.address;
final String ipv4Loopback = InternetAddress.loopbackIPv4.address;
@@ -298,7 +298,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
FuchsiaIsolateDiscoveryProtocol? isolateDiscoveryProtocol;
try {
isolateDiscoveryProtocol = device.getIsolateDiscoveryProtocol(module);
observatoryUri = Stream<Uri>.value(await isolateDiscoveryProtocol.uri).asBroadcastStream();
vmServiceUri = Stream<Uri>.value(await isolateDiscoveryProtocol.uri).asBroadcastStream();
} on Exception {
isolateDiscoveryProtocol?.dispose();
final List<ForwardedPort> ports = device.portForwarder.forwardedPorts.toList();
@@ -351,7 +351,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
Future<Uri?>? protocolDiscoveryFuture;
if (compatibleWithProtocolDiscovery) {
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.observatory(
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(
device.getLogReader(),
portForwarder: device.portForwarder,
ipv6: ipv6!,
@@ -372,14 +372,14 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
discoveryStatus.stop();
observatoryUri = foundUrl == null
vmServiceUri = foundUrl == null
? null
: Stream<Uri>.value(foundUrl).asBroadcastStream();
}
// If MDNS discovery fails or we're not on iOS, fallback to ProtocolDiscovery.
if (observatoryUri == null) {
final ProtocolDiscovery observatoryDiscovery =
ProtocolDiscovery.observatory(
if (vmServiceUri == null) {
final ProtocolDiscovery vmServiceDiscovery =
ProtocolDiscovery.vmService(
// If it's an Android device, attaching relies on past log searching
// to find the service protocol.
await device.getLogReader(includePastLogs: device is AndroidDevice),
@@ -390,12 +390,12 @@ known, it can be explicitly provided to attach via the command-line, e.g.
logger: _logger,
);
_logger.printStatus('Waiting for a connection from Flutter on ${device.name}...');
observatoryUri = observatoryDiscovery.uris;
vmServiceUri = vmServiceDiscovery.uris;
// Determine ipv6 status from the scanned logs.
usesIpv6 = observatoryDiscovery.ipv6;
usesIpv6 = vmServiceDiscovery.ipv6;
}
} else {
observatoryUri = Stream<Uri>
vmServiceUri = Stream<Uri>
.fromFuture(
buildVMServiceUri(
device,
@@ -413,7 +413,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
int? result;
if (daemon != null) {
final ResidentRunner runner = await createResidentRunner(
observatoryUris: observatoryUri,
vmServiceUris: vmServiceUri,
device: device,
flutterProject: flutterProject,
usesIpv6: usesIpv6,
@@ -446,7 +446,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
while (true) {
final ResidentRunner runner = await createResidentRunner(
observatoryUris: observatoryUri,
vmServiceUris: vmServiceUri,
device: device,
flutterProject: flutterProject,
usesIpv6: usesIpv6,
@@ -476,7 +476,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
terminalHandler?.stop();
assert(result != null);
if (runner.exited || !runner.isWaitingForObservatory) {
if (runner.exited || !runner.isWaitingForVmService) {
break;
}
_logger.printStatus('Waiting for a new connection from Flutter on ${device.name}...');
@@ -495,7 +495,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
}
Future<ResidentRunner> createResidentRunner({
required Stream<Uri> observatoryUris,
required Stream<Uri> vmServiceUris,
required Device device,
required FlutterProject flutterProject,
required bool usesIpv6,
@@ -510,7 +510,7 @@ known, it can be explicitly provided to attach via the command-line, e.g.
userIdentifier: userIdentifier,
platform: _platform,
);
flutterDevice.observatoryUris = observatoryUris;
flutterDevice.vmServiceUris = vmServiceUris;
final List<FlutterDevice> flutterDevices = <FlutterDevice>[flutterDevice];
final DebuggingOptions debuggingOptions = DebuggingOptions.enabled(
buildInfo,

View File

@@ -650,7 +650,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
description: 'Should the device use port forwarding? '
'Using port forwarding is the default because it works in all cases, however if your '
'remote device has a static IP address and you have a way of '
'specifying the "--observatory-host=<ip>" engine option, you might prefer '
'specifying the "--vm-service-host=<ip>" engine option, you might prefer '
'not using port forwarding.',
);

View File

@@ -1016,7 +1016,9 @@ class DeviceDomain extends Domain {
);
return <String, Object?>{
'started': result.started,
'observatoryUri': result.observatoryUri?.toString(),
'vmServiceUri': result.vmServiceUri?.toString(),
// TODO(bkonyi): remove once clients have migrated to relying on vmServiceUri.
'observatoryUri': result.vmServiceUri?.toString(),
};
}

View File

@@ -81,7 +81,7 @@ class DriveCommand extends RunCommandBase {
'running, and "--no-keep-app-running" overrides it.',
)
..addOption('use-existing-app',
help: 'Connect to an already running instance via the given observatory URL. '
help: 'Connect to an already running instance via the given Dart VM Service URL. '
'If this option is given, the application will not be automatically started, '
'and it will only be stopped if "--no-keep-app-running" is explicitly set.',
valueHelp: 'url',

View File

@@ -15,7 +15,7 @@ import '../vmservice.dart';
const String _kOut = 'out';
const String _kType = 'type';
const String _kObservatoryUrl = 'observatory-url';
const String _kVmServiceUrl = 'vm-service-url';
const String _kDeviceType = 'device';
const String _kSkiaType = 'skia';
const String _kRasterizerType = 'rasterizer';
@@ -29,13 +29,13 @@ class ScreenshotCommand extends FlutterCommand {
help: 'Location to write the screenshot.',
);
argParser.addOption(
_kObservatoryUrl,
_kVmServiceUrl,
aliases: <String>[ 'observatory-url' ], // for historical reasons
valueHelp: 'URI',
help: 'The Observatory URL to which to connect.\n'
help: 'The VM Service URL to which to connect.\n'
'This is required when "--$_kType" is "$_kSkiaType" or "$_kRasterizerType".\n'
'To find the Observatory URL, use "flutter run" and look for '
'"An Observatory ... is available at" in the output.',
'To find the VM service URL, use "flutter run" and look for '
'"A Dart VM Service ... is available at" in the output.',
);
argParser.addOption(
_kType,
@@ -46,8 +46,8 @@ class ScreenshotCommand extends FlutterCommand {
_kDeviceType: "Delegate to the device's native screenshot capabilities. This "
'screenshots the entire screen currently being displayed (including content '
'not rendered by Flutter, like the device status bar).',
_kSkiaType: 'Render the Flutter app as a Skia picture. Requires "--$_kObservatoryUrl".',
_kRasterizerType: 'Render the Flutter app using the rasterizer. Requires "--$_kObservatoryUrl."',
_kSkiaType: 'Render the Flutter app as a Skia picture. Requires "--$_kVmServiceUrl".',
_kRasterizerType: 'Render the Flutter app using the rasterizer. Requires "--$_kVmServiceUrl."',
},
defaultsTo: _kDeviceType,
);
@@ -70,11 +70,11 @@ class ScreenshotCommand extends FlutterCommand {
Device? device;
Future<void> _validateOptions(String? screenshotType, String? observatoryUrl) async {
Future<void> _validateOptions(String? screenshotType, String? vmServiceUrl) async {
switch (screenshotType) {
case _kDeviceType:
if (observatoryUrl != null) {
throwToolExit('Observatory URI cannot be provided for screenshot type $screenshotType');
if (vmServiceUrl != null) {
throwToolExit('VM Service URI cannot be provided for screenshot type $screenshotType');
}
device = await findTargetDevice();
if (device == null) {
@@ -85,18 +85,18 @@ class ScreenshotCommand extends FlutterCommand {
}
break;
default:
if (observatoryUrl == null) {
throwToolExit('Observatory URI must be specified for screenshot type $screenshotType');
if (vmServiceUrl == null) {
throwToolExit('VM Service URI must be specified for screenshot type $screenshotType');
}
if (observatoryUrl.isEmpty || Uri.tryParse(observatoryUrl) == null) {
throwToolExit('Observatory URI "$observatoryUrl" is invalid');
if (vmServiceUrl.isEmpty || Uri.tryParse(vmServiceUrl) == null) {
throwToolExit('VM Service URI "$vmServiceUrl" is invalid');
}
}
}
@override
Future<FlutterCommandResult> verifyThenRunCommand(String? commandPath) async {
await _validateOptions(stringArgDeprecated(_kType), stringArgDeprecated(_kObservatoryUrl));
await _validateOptions(stringArgDeprecated(_kType), stringArgDeprecated(_kVmServiceUrl));
return super.verifyThenRunCommand(commandPath);
}
@@ -150,8 +150,8 @@ class ScreenshotCommand extends FlutterCommand {
}
Future<bool> runSkia(File? outputFile) async {
final Uri observatoryUrl = Uri.parse(stringArgDeprecated(_kObservatoryUrl)!);
final FlutterVmService vmService = await connectToVmService(observatoryUrl, logger: globals.logger);
final Uri vmServiceUrl = Uri.parse(stringArgDeprecated(_kVmServiceUrl)!);
final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger);
final vm_service.Response? skp = await vmService.screenshotSkp();
if (skp == null) {
globals.printError(
@@ -174,8 +174,8 @@ class ScreenshotCommand extends FlutterCommand {
}
Future<bool> runRasterizer(File? outputFile) async {
final Uri observatoryUrl = Uri.parse(stringArgDeprecated(_kObservatoryUrl)!);
final FlutterVmService vmService = await connectToVmService(observatoryUrl, logger: globals.logger);
final Uri vmServiceUrl = Uri.parse(stringArgDeprecated(_kVmServiceUrl)!);
final FlutterVmService vmService = await connectToVmService(vmServiceUrl, logger: globals.logger);
final vm_service.Response? response = await vmService.screenshot();
if (response == null) {
globals.printError(

View File

@@ -464,7 +464,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
tags: tags,
excludeTags: excludeTags,
watcher: watcher,
enableObservatory: collector != null || startPaused || boolArgDeprecated('enable-vmservice'),
enableVmService: collector != null || startPaused || boolArgDeprecated('enable-vmservice'),
ipv6: boolArgDeprecated('ipv6'),
machine: machine,
updateGoldens: boolArgDeprecated('update-goldens'),

View File

@@ -309,7 +309,7 @@ class CustomDeviceAppSession {
'purge-persistent-cache=true',
if (debuggingOptions.debuggingEnabled) ...<String>[
if (debuggingOptions.deviceVmServicePort != null)
'observatory-port=${debuggingOptions.deviceVmServicePort}',
'vm-service-port=${debuggingOptions.deviceVmServicePort}',
if (debuggingOptions.buildInfo.isDebug) ...<String>[
'enable-checked-mode=true',
'verify-entry-points=true',
@@ -374,7 +374,7 @@ class CustomDeviceAppSession {
assert(_process == null);
_process = process;
final ProtocolDiscovery discovery = ProtocolDiscovery.observatory(
final ProtocolDiscovery discovery = ProtocolDiscovery.vmService(
logReader,
portForwarder: _device._config.usesPortForwarding ? _device.portForwarder : null,
logger: _logger,
@@ -388,14 +388,14 @@ class CustomDeviceAppSession {
// in the same microtask AFAICT but this way we're on the safe side.
logReader.listenToProcessOutput(process);
final Uri? observatoryUri = await discovery.uri;
final Uri? vmServiceUri = await discovery.uri;
await discovery.cancel();
if (_device._config.usesPortForwarding) {
_forwardedHostPort = observatoryUri?.port;
_forwardedHostPort = vmServiceUri?.port;
}
return LaunchResult.succeeded(observatoryUri: observatoryUri);
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
}
void _maybeUnforwardPort() {

View File

@@ -153,7 +153,7 @@ class FlutterTestDebugAdapter extends FlutterBaseDebugAdapter with TestAdapter {
/// Handles the test.processStarted event from Flutter that provides the VM Service URL.
void _handleTestStartedProcess(Map<String, Object?> params) {
final String? vmServiceUriString = params['observatoryUri'] as String?;
final String? vmServiceUriString = params['vmServiceUri'] as String?;
// For no-debug mode, this event may be still sent so ignore it if we know
// we're not debugging, or its URI is null.
if (!enableDebugger || vmServiceUriString == null) {

View File

@@ -152,17 +152,17 @@ abstract class DesktopDevice extends Device {
if (debuggingOptions.buildInfo.isRelease == true) {
return LaunchResult.succeeded();
}
final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_deviceLogReader,
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_deviceLogReader,
devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions.hostVmServicePort,
ipv6: ipv6,
logger: _logger,
);
try {
final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) {
final Uri? vmServiceUri = await vmServiceDiscovery.uri;
if (vmServiceUri != null) {
onAttached(package, buildInfo, process);
return LaunchResult.succeeded(observatoryUri: observatoryUri);
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
}
_logger.printError(
'Error waiting for a debug connection: '
@@ -171,7 +171,7 @@ abstract class DesktopDevice extends Device {
} on Exception catch (error) {
_logger.printError('Error waiting for a debug connection: $error');
} finally {
await observatoryDiscovery.cancel();
await vmServiceDiscovery.cancel();
}
return LaunchResult.failed();
}
@@ -270,7 +270,7 @@ abstract class DesktopDevice extends Device {
// tool and the device, usually in debug or profile mode.
if (debuggingOptions.debuggingEnabled) {
if (debuggingOptions.deviceVmServicePort != null) {
addFlag('observatory-port=${debuggingOptions.deviceVmServicePort}');
addFlag('vm-service-port=${debuggingOptions.deviceVmServicePort}');
}
if (debuggingOptions.buildInfo.isDebug) {
addFlag('enable-checked-mode=true');

View File

@@ -933,7 +933,7 @@ class DebuggingOptions {
return <String>[
if (enableDartProfiling) '--enable-dart-profiling',
if (disableServiceAuthCodes) '--disable-service-auth-codes',
if (disablePortPublication) '--disable-observatory-publication',
if (disablePortPublication) '--disable-vm-service-publication',
if (startPaused) '--start-paused',
// Wrap dart flags in quotes for physical devices
if (environmentType == EnvironmentType.physical && dartVmFlags.isNotEmpty)
@@ -960,14 +960,14 @@ class DebuggingOptions {
if (platformArgs['trace-startup'] as bool? ?? false) '--trace-startup',
if (enableImpeller) '--enable-impeller',
if (environmentType == EnvironmentType.physical && deviceVmServicePort != null)
'--observatory-port=$deviceVmServicePort',
'--vm-service-port=$deviceVmServicePort',
// The simulator "device" is actually on the host machine so no ports will be forwarded.
// Use the suggested host port.
if (environmentType == EnvironmentType.simulator && hostVmServicePort != null)
'--observatory-port=$hostVmServicePort',
// Tell the observatory to listen on all interfaces, don't restrict to the loopback.
'--vm-service-port=$hostVmServicePort',
// Tell the VM service to listen on all interfaces, don't restrict to the loopback.
if (interfaceType == IOSDeviceConnectionInterface.network)
'--observatory-host=${ipv6 ? '::0' : '0.0.0.0'}',
'--vm-service-host=${ipv6 ? '::0' : '0.0.0.0'}',
];
}
@@ -1066,21 +1066,24 @@ class DebuggingOptions {
}
class LaunchResult {
LaunchResult.succeeded({ this.observatoryUri }) : started = true;
LaunchResult.succeeded({ Uri? vmServiceUri, Uri? observatoryUri }) :
started = true,
vmServiceUri = vmServiceUri ?? observatoryUri;
LaunchResult.failed()
: started = false,
observatoryUri = null;
vmServiceUri = null;
bool get hasObservatory => observatoryUri != null;
bool get hasVmService => vmServiceUri != null;
final bool started;
final Uri? observatoryUri;
final Uri? vmServiceUri;
@override
String toString() {
final StringBuffer buf = StringBuffer('started=$started');
if (observatoryUri != null) {
buf.write(', observatory=$observatoryUri');
if (vmServiceUri != null) {
buf.write(', vmService=$vmServiceUri');
}
return buf.toString();
}
@@ -1109,9 +1112,9 @@ abstract class DeviceLogReader {
/// Describes an app running on the device.
class DiscoveredApp {
DiscoveredApp(this.id, this.observatoryPort);
DiscoveredApp(this.id, this.vmServicePort);
final String id;
final int observatoryPort;
final int vmServicePort;
}
// An empty device log reader

View File

@@ -196,7 +196,7 @@ class FlutterDriverService extends DriverService {
throwToolExit('Application failed to start. Will not run test. Quitting.', exitCode: 1);
}
return reuseApplication(
result.observatoryUri!,
result.vmServiceUri!,
device,
debuggingOptions,
ipv6,

View File

@@ -52,11 +52,11 @@ Future<FlutterVmService> _kDefaultFuchsiaIsolateDiscoveryConnector(Uri uri) {
Future<void> _kDefaultDartDevelopmentServiceStarter(
Device device,
Uri observatoryUri,
Uri vmServiceUri,
bool disableServiceAuthCodes,
) async {
await device.dds.startDartDevelopmentService(
observatoryUri,
vmServiceUri,
hostPort: 0,
ipv6: true,
disableServiceAuthCodes: disableServiceAuthCodes,
@@ -458,12 +458,12 @@ class FuchsiaDevice extends Device {
globals.printTrace(
'App started in a non-release mode. Setting up vmservice connection.');
// In a debug or profile build, try to find the observatory uri.
// In a debug or profile build, try to find the vmService uri.
final FuchsiaIsolateDiscoveryProtocol discovery =
getIsolateDiscoveryProtocol(appName);
try {
final Uri observatoryUri = await discovery.uri;
return LaunchResult.succeeded(observatoryUri: observatoryUri);
final Uri vmServiceUri = await discovery.uri;
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
} finally {
discovery.dispose();
}
@@ -620,7 +620,7 @@ class FuchsiaDevice extends Device {
return addr;
}();
/// List the ports currently running a dart observatory.
/// List the ports currently running a dart vmService.
Future<List<int>> servicePorts() async {
const String findCommand = 'find /hub -name vmservice-port';
final RunResult findResult = await shell(findCommand);

View File

@@ -284,5 +284,4 @@ PreRunValidator get preRunValidator => context.get<PreRunValidator>() ?? const N
const String kDefaultFrameworkChannel = 'master';
// Used to build RegExp instances which can detect the VM service message.
const String kServicePrefixRegExp = '(?:Observatory|The Dart VM service is)';
final RegExp kVMServiceMessageRegExp = RegExp(kServicePrefixRegExp + r' listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');
final RegExp kVMServiceMessageRegExp = RegExp(r'The Dart VM service is listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)');

View File

@@ -357,10 +357,10 @@ class IOSDevice extends Device {
'Installing and launching...',
);
try {
ProtocolDiscovery? observatoryDiscovery;
ProtocolDiscovery? vmServiceDiscovery;
int installationResult = 1;
if (debuggingOptions.debuggingEnabled) {
_logger.printTrace('Debugging is enabled, connecting to observatory');
_logger.printTrace('Debugging is enabled, connecting to vmService');
final DeviceLogReader deviceLogReader = getLogReader(app: package);
// If the device supports syslog reading, prefer launching the app without
@@ -378,8 +378,8 @@ class IOSDevice extends Device {
deviceLogReader.debuggerStream = iosDeployDebugger;
}
}
// Don't port forward if debugging with a network device.
observatoryDiscovery = ProtocolDiscovery.observatory(
// Don't port foward if debugging with a network device.
vmServiceDiscovery = ProtocolDiscovery.vmService(
deviceLogReader,
portForwarder: interfaceType == IOSDeviceConnectionInterface.network ? null : portForwarder,
hostPort: debuggingOptions.hostVmServicePort,
@@ -435,7 +435,7 @@ class IOSDevice extends Device {
Uri? localUri;
if (interfaceType == IOSDeviceConnectionInterface.network) {
// Wait for Dart VM Service to start up.
final Uri? serviceURL = await observatoryDiscovery?.uri;
final Uri? serviceURL = await vmServiceDiscovery?.uri;
if (serviceURL == null) {
await iosDeployDebugger?.stopAndDumpBacktrace();
return LaunchResult.failed();
@@ -463,14 +463,14 @@ class IOSDevice extends Device {
mDNSLookupTimer.cancel();
} else {
localUri = await observatoryDiscovery?.uri;
localUri = await vmServiceDiscovery?.uri;
}
timer.cancel();
if (localUri == null) {
await iosDeployDebugger?.stopAndDumpBacktrace();
return LaunchResult.failed();
}
return LaunchResult.succeeded(observatoryUri: localUri);
return LaunchResult.succeeded(vmServiceUri: localUri);
} on ProcessException catch (e) {
await iosDeployDebugger?.stopAndDumpBacktrace();
_logger.printError(e.message);

View File

@@ -450,9 +450,9 @@ class IOSSimulator extends Device {
platformArgs,
);
ProtocolDiscovery? observatoryDiscovery;
ProtocolDiscovery? vmServiceDiscovery;
if (debuggingOptions.debuggingEnabled) {
observatoryDiscovery = ProtocolDiscovery.observatory(
vmServiceDiscovery = ProtocolDiscovery.vmService(
getLogReader(app: package),
ipv6: ipv6,
hostPort: debuggingOptions.hostVmServicePort,
@@ -485,13 +485,13 @@ class IOSSimulator extends Device {
}
// Wait for the service protocol port here. This will complete once the
// device has printed "Observatory is listening on..."
globals.printTrace('Waiting for observatory port to be available...');
// device has printed "Dart VM Service is listening on..."
globals.printTrace('Waiting for VM Service port to be available...');
try {
final Uri? deviceUri = await observatoryDiscovery?.uri;
final Uri? deviceUri = await vmServiceDiscovery?.uri;
if (deviceUri != null) {
return LaunchResult.succeeded(observatoryUri: deviceUri);
return LaunchResult.succeeded(vmServiceUri: deviceUri);
}
globals.printError(
'Error waiting for a debug connection: '
@@ -500,7 +500,7 @@ class IOSSimulator extends Device {
} on Exception catch (error) {
globals.printError('Error waiting for a debug connection: $error');
} finally {
await observatoryDiscovery?.cancel();
await vmServiceDiscovery?.cancel();
}
return LaunchResult.failed();
}

View File

@@ -29,7 +29,7 @@ abstract class MacOSApp extends ApplicationPackage {
/// `applicationBinary` is the path to the framework directory created by an
/// Xcode build. By default, this is located under
/// "~/Library/Developer/Xcode/DerivedData/" and contains an executable
/// which is expected to start the application and send the observatory
/// which is expected to start the application and send the vmService
/// port over stdout.
static MacOSApp? fromPrebuiltApp(FileSystemEntity applicationBinary) {
final _BundleInfo? bundleInfo = _executableFromBundle(applicationBinary);

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:multicast_dns/multicast_dns.dart';
@@ -39,7 +41,7 @@ class MDnsVmServiceDiscovery {
final Usage _flutterUsage;
@visibleForTesting
static const String dartVmServiceName = '_dartobservatory._tcp.local';
static const String dartVmServiceName = '_dartVmService._tcp.local';
static MDnsVmServiceDiscovery? get instance => context.get<MDnsVmServiceDiscovery>();

View File

@@ -139,16 +139,16 @@ class PreviewDevice extends Device {
_process = process;
_logReader.initializeProcess(process);
final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory(_logReader,
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_logReader,
devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions.hostVmServicePort,
ipv6: ipv6,
logger: _logger,
);
try {
final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) {
return LaunchResult.succeeded(observatoryUri: observatoryUri);
final Uri? vmServiceUri = await vmServiceDiscovery.uri;
if (vmServiceUri != null) {
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
}
_logger.printError(
'Error waiting for a debug connection: '
@@ -157,7 +157,7 @@ class PreviewDevice extends Device {
} on Exception catch (error) {
_logger.printError('Error waiting for a debug connection: $error');
} finally {
await observatoryDiscovery.cancel();
await vmServiceDiscovery.cancel();
}
return LaunchResult.failed();
}

View File

@@ -29,7 +29,7 @@ class ProtocolDiscovery {
);
}
factory ProtocolDiscovery.observatory(
factory ProtocolDiscovery.vmService(
DeviceLogReader logReader, {
DevicePortForwarder? portForwarder,
Duration? throttleDuration,
@@ -38,10 +38,10 @@ class ProtocolDiscovery {
required bool ipv6,
required Logger logger,
}) {
const String kObservatoryService = 'Observatory';
const String kVmServiceService = 'VM Service';
return ProtocolDiscovery._(
logReader,
kObservatoryService,
kVmServiceService,
portForwarder: portForwarder,
throttleDuration: throttleDuration ?? const Duration(milliseconds: 200),
hostPort: hostPort,
@@ -59,7 +59,7 @@ class ProtocolDiscovery {
final bool ipv6;
final Logger _logger;
/// The time to wait before forwarding a new observatory URIs from [logReader].
/// The time to wait before forwarding a new VM Service URIs from [logReader].
final Duration throttleDuration;
StreamSubscription<String>? _deviceLogSubscription;
@@ -81,12 +81,12 @@ class ProtocolDiscovery {
/// The discovered service URLs.
///
/// When a new observatory URL: is available in [logReader],
/// When a new VM Service URL: is available in [logReader],
/// the URLs are forwarded at most once every [throttleDuration].
/// Returns when no event has been observed for [throttleTimeout].
///
/// Port forwarding is only attempted when this is invoked,
/// for each observatory URL in the stream.
/// for each VM Service URL in the stream.
Stream<Uri> get uris {
final Stream<Uri> uriStream = _uriStreamController.stream
.transform(_throttle<Uri>(
@@ -107,7 +107,7 @@ class ProtocolDiscovery {
return globals.kVMServiceMessageRegExp.firstMatch(line);
}
Uri? _getObservatoryUri(String line) {
Uri? _getVmServiceUri(String line) {
final Match? match = _getPatternMatch(line);
if (match != null) {
return Uri.parse(match[1]!);
@@ -118,7 +118,7 @@ class ProtocolDiscovery {
void _handleLine(String line) {
Uri? uri;
try {
uri = _getObservatoryUri(line);
uri = _getVmServiceUri(line);
} on FormatException catch (error, stackTrace) {
_uriStreamController.addError(error, stackTrace);
}
@@ -126,7 +126,7 @@ class ProtocolDiscovery {
return;
}
if (devicePort != null && uri.port != devicePort) {
_logger.printTrace('skipping potential observatory $uri due to device port mismatch');
_logger.printTrace('skipping potential VM Service $uri due to device port mismatch');
return;
}
_uriStreamController.add(uri);

View File

@@ -245,12 +245,12 @@ class ProxiedDevice extends Device {
'userIdentifier': userIdentifier,
}));
final bool started = _cast<bool>(result['started']);
final String? observatoryUriStr = _cast<String?>(result['observatoryUri']);
final Uri? observatoryUri = observatoryUriStr == null ? null : Uri.parse(observatoryUriStr);
final String? vmServiceUriStr = _cast<String?>(result['vmServiceUri']);
final Uri? vmServiceUri = vmServiceUriStr == null ? null : Uri.parse(vmServiceUriStr);
if (started) {
if (observatoryUri != null) {
final int hostPort = await proxiedPortForwarder.forward(observatoryUri.port);
return LaunchResult.succeeded(observatoryUri: observatoryUri.replace(port: hostPort));
if (vmServiceUri != null) {
final int hostPort = await proxiedPortForwarder.forward(vmServiceUri.port);
return LaunchResult.succeeded(vmServiceUri: vmServiceUri.replace(port: hostPort));
} else {
return LaunchResult.succeeded();
}

View File

@@ -114,7 +114,7 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
if (_residentRunner.reportedDebuggers) {
// Since the DevTools only just became available, we haven't had a chance to
// report their URLs yet. Do so now.
_residentRunner.printDebuggerList(includeObservatory: false);
_residentRunner.printDebuggerList(includeVmService: false);
}
}

View File

@@ -224,21 +224,21 @@ class FlutterDevice {
final DevelopmentSceneImporter? developmentSceneImporter;
DevFSWriter? devFSWriter;
Stream<Uri?>? observatoryUris;
Stream<Uri?>? vmServiceUris;
FlutterVmService? vmService;
DevFS? devFS;
ApplicationPackage? package;
// ignore: cancel_subscriptions
StreamSubscription<String>? _loggingSubscription;
bool? _isListeningForObservatoryUri;
bool? _isListeningForVmServiceUri;
/// Whether the stream [observatoryUris] is still open.
bool get isWaitingForObservatory => _isListeningForObservatoryUri ?? false;
/// Whether the stream [vmServiceUris] is still open.
bool get isWaitingForVmService => _isListeningForVmServiceUri ?? false;
/// If the [reloadSources] parameter is not null the 'reloadSources' service
/// will be registered.
/// The 'reloadSources' service can be used by other Service Protocol clients
/// connected to the VM (e.g. Observatory) to request a reload of the source
/// connected to the VM (e.g. VmService) to request a reload of the source
/// code of the running application (a.k.a. HotReload).
/// The 'compileExpression' service can be used to compile user-provided
/// expressions requested during debugging of the application.
@@ -262,29 +262,29 @@ class FlutterDevice {
late StreamSubscription<void> subscription;
bool isWaitingForVm = false;
subscription = observatoryUris!.listen((Uri? observatoryUri) async {
subscription = vmServiceUris!.listen((Uri? vmServiceUri) async {
// FYI, this message is used as a sentinel in tests.
globals.printTrace('Connecting to service protocol: $observatoryUri');
globals.printTrace('Connecting to service protocol: $vmServiceUri');
isWaitingForVm = true;
bool existingDds = false;
FlutterVmService? service;
if (enableDds) {
void handleError(Exception e, StackTrace st) {
globals.printTrace('Fail to connect to service protocol: $observatoryUri: $e');
globals.printTrace('Fail to connect to service protocol: $vmServiceUri: $e');
if (!completer.isCompleted) {
completer.completeError('failed to connect to $observatoryUri', st);
completer.completeError('failed to connect to $vmServiceUri', st);
}
}
// First check if the VM service is actually listening on observatoryUri as
// First check if the VM service is actually listening on vmServiceUri as
// this may not be the case when scraping logcat for URIs. If this URI is
// from an old application instance, we shouldn't try and start DDS.
try {
service = await connectToVmService(observatoryUri!, logger: globals.logger);
service = await connectToVmService(vmServiceUri!, logger: globals.logger);
await service.dispose();
} on Exception catch (exception) {
globals.printTrace('Fail to connect to service protocol: $observatoryUri: $exception');
if (!completer.isCompleted && !_isListeningForObservatoryUri!) {
completer.completeError('failed to connect to $observatoryUri');
globals.printTrace('Fail to connect to service protocol: $vmServiceUri: $exception');
if (!completer.isCompleted && !_isListeningForVmServiceUri!) {
completer.completeError('failed to connect to $vmServiceUri');
}
return;
}
@@ -294,7 +294,7 @@ class FlutterDevice {
// attaching to a VM service with existing clients, etc.).
try {
await device!.dds.startDartDevelopmentService(
observatoryUri,
vmServiceUri,
hostPort: ddsPort,
ipv6: ipv6,
disableServiceAuthCodes: disableServiceAuthCodes,
@@ -324,7 +324,7 @@ class FlutterDevice {
service = await Future.any<dynamic>(
<Future<dynamic>>[
connectToVmService(
enableDds ? (device!.dds.uri ?? observatoryUri!): observatoryUri!,
enableDds ? (device!.dds.uri ?? vmServiceUri!): vmServiceUri!,
reloadSources: reloadSources,
restart: restart,
compileExpression: compileExpression,
@@ -338,30 +338,30 @@ class FlutterDevice {
]
) as FlutterVmService?;
} on Exception catch (exception) {
globals.printTrace('Fail to connect to service protocol: $observatoryUri: $exception');
if (!completer.isCompleted && !_isListeningForObservatoryUri!) {
completer.completeError('failed to connect to $observatoryUri');
globals.printTrace('Fail to connect to service protocol: $vmServiceUri: $exception');
if (!completer.isCompleted && !_isListeningForVmServiceUri!) {
completer.completeError('failed to connect to $vmServiceUri');
}
return;
}
if (completer.isCompleted) {
return;
}
globals.printTrace('Successfully connected to service protocol: $observatoryUri');
globals.printTrace('Successfully connected to service protocol: $vmServiceUri');
vmService = service;
(await device!.getLogReader(app: package)).connectedVMService = vmService;
completer.complete();
await subscription.cancel();
}, onError: (dynamic error) {
globals.printTrace('Fail to handle observatory URI: $error');
globals.printTrace('Fail to handle VM Service URI: $error');
}, onDone: () {
_isListeningForObservatoryUri = false;
_isListeningForVmServiceUri = false;
if (!completer.isCompleted && !isWaitingForVm) {
completer.completeError(Exception('connection to device ended too early'));
}
});
_isListeningForObservatoryUri = true;
_isListeningForVmServiceUri = true;
return completer.future;
}
@@ -471,12 +471,12 @@ class FlutterDevice {
await stopEchoingDeviceLog();
return 2;
}
if (result.hasObservatory) {
observatoryUris = Stream<Uri?>
.value(result.observatoryUri)
if (result.hasVmService) {
vmServiceUris = Stream<Uri?>
.value(result.vmServiceUri)
.asBroadcastStream();
} else {
observatoryUris = const Stream<Uri>
vmServiceUris = const Stream<Uri>
.empty()
.asBroadcastStream();
}
@@ -536,12 +536,12 @@ class FlutterDevice {
await stopEchoingDeviceLog();
return 2;
}
if (result.hasObservatory) {
observatoryUris = Stream<Uri?>
.value(result.observatoryUri)
if (result.hasVmService) {
vmServiceUris = Stream<Uri?>
.value(result.vmServiceUri)
.asBroadcastStream();
} else {
observatoryUris = const Stream<Uri>
vmServiceUris = const Stream<Uri>
.empty()
.asBroadcastStream();
}
@@ -1131,10 +1131,10 @@ abstract class ResidentRunner extends ResidentHandlers {
@override
bool hotMode;
/// Returns true if every device is streaming observatory URIs.
bool get isWaitingForObservatory {
/// Returns true if every device is streaming vmService URIs.
bool get isWaitingForVmService {
return flutterDevices.every((FlutterDevice? device) {
return device!.isWaitingForObservatory;
return device!.isWaitingForVmService;
});
}
@@ -1478,7 +1478,7 @@ abstract class ResidentRunner extends ResidentHandlers {
bool get reportedDebuggers => _reportedDebuggers;
bool _reportedDebuggers = false;
void printDebuggerList({ bool includeObservatory = true, bool includeDevtools = true }) {
void printDebuggerList({ bool includeVmService = true, bool includeDevtools = true }) {
final DevToolsServerAddress? devToolsServerAddress = residentDevtoolsHandler!.activeDevToolsServer;
if (!residentDevtoolsHandler!.readyToAnnounce) {
includeDevtools = false;
@@ -1488,10 +1488,10 @@ abstract class ResidentRunner extends ResidentHandlers {
if (device!.vmService == null) {
continue;
}
if (includeObservatory) {
if (includeVmService) {
// Caution: This log line is parsed by device lab tests.
globals.printStatus(
'An Observatory debugger and profiler on ${device.device!.name} is available at: '
'A Dart VM Service on ${device.device!.name} is available at: '
'${device.vmService!.httpAddress}',
);
}

View File

@@ -69,7 +69,7 @@ class ColdRunner extends ResidentRunner {
return 1;
}
// Connect to observatory.
// Connect to the VM Service.
if (debuggingEnabled) {
try {
await connectToServiceProtocol(allowExistingDdsInstance: false);
@@ -93,7 +93,7 @@ class ColdRunner extends ResidentRunner {
}
}
if (flutterDevices.first.observatoryUris != null) {
if (flutterDevices.first.vmServiceUris != null) {
// For now, only support one debugger connection.
connectionInfoCompleter?.complete(DebugConnectionInfo(
httpUri: flutterDevices.first.vmService!.httpAddress,

View File

@@ -139,7 +139,10 @@ abstract class FlutterCommand extends Command<void> {
/// Will be `null` until the top-most command has begun execution.
static FlutterCommand? get current => context.get<FlutterCommand>();
/// The option name for a custom observatory port.
/// The option name for a custom VM Service port.
static const String vmServicePortOption = 'vm-service-port';
/// The option name for a custom VM Service port.
static const String observatoryPortOption = 'observatory-port';
/// The option name for a custom DevTools server address.
@@ -379,14 +382,22 @@ abstract class FlutterCommand extends Command<void> {
);
}
/// Adds options for connecting to the Dart VM observatory port.
/// Adds options for connecting to the Dart VM Service port.
void usesPortOptions({ required bool verboseHelp }) {
argParser.addOption(observatoryPortOption,
argParser.addOption(vmServicePortOption,
help: '(deprecated; use host-vmservice-port instead) '
'Listen to the given port for an observatory debugger connection.\n'
'Listen to the given port for a Dart VM Service connection.\n'
'Specifying port 0 (the default) will find a random free port.\n '
'if the Dart Development Service (DDS) is enabled, this will not be the port '
'of the Observatory instance advertised on the command line.',
'of the VmService instance advertised on the command line.',
hide: !verboseHelp,
);
argParser.addOption(observatoryPortOption,
help: '(deprecated; use host-vmservice-port instead) '
'Listen to the given port for a Dart VM Service connection.\n'
'Specifying port 0 (the default) will find a random free port.\n '
'if the Dart Development Service (DDS) is enabled, this will not be the port '
'of the VmService instance advertised on the command line.',
hide: !verboseHelp,
);
argParser.addOption('device-vmservice-port',
@@ -490,19 +501,21 @@ abstract class FlutterCommand extends Command<void> {
return ddsEnabled;
}();
bool get _hostVmServicePortProvided => (argResults?.wasParsed('observatory-port') ?? false)
bool get _hostVmServicePortProvided => (argResults?.wasParsed(vmServicePortOption) ?? false)
|| (argResults?.wasParsed(observatoryPortOption) ?? false)
|| (argResults?.wasParsed('host-vmservice-port') ?? false);
int _tryParseHostVmservicePort() {
final String? observatoryPort = stringArgDeprecated('observatory-port');
final String? vmServicePort = stringArgDeprecated(vmServicePortOption) ??
stringArgDeprecated(observatoryPortOption);
final String? hostPort = stringArgDeprecated('host-vmservice-port');
if (observatoryPort == null && hostPort == null) {
throwToolExit('Invalid port for `--observatory-port/--host-vmservice-port`');
if (vmServicePort == null && hostPort == null) {
throwToolExit('Invalid port for `--vm-service-port/--host-vmservice-port`');
}
try {
return int.parse((observatoryPort ?? hostPort)!);
return int.parse((vmServicePort ?? hostPort)!);
} on FormatException catch (error) {
throwToolExit('Invalid port for `--observatory-port/--host-vmservice-port`: $error');
throwToolExit('Invalid port for `--vm-service-port/--host-vmservice-port`: $error');
}
}
@@ -528,10 +541,10 @@ abstract class FlutterCommand extends Command<void> {
return null;
}
/// Gets the vmservice port provided to in the 'observatory-port' or
/// Gets the vmservice port provided to in the 'vm-service-port' or
/// 'host-vmservice-port option.
///
/// Only one of "host-vmservice-port" and "observatory-port" may be
/// Only one of "host-vmservice-port" and "vm-service-port" may be
/// specified.
///
/// If no port is set, returns null.
@@ -539,9 +552,10 @@ abstract class FlutterCommand extends Command<void> {
if (!_usesPortOption || !_hostVmServicePortProvided) {
return null;
}
if ((argResults?.wasParsed('observatory-port') ?? false)
if ((argResults?.wasParsed(vmServicePortOption) ?? false)
&& (argResults?.wasParsed(observatoryPortOption) ?? false)
&& (argResults?.wasParsed('host-vmservice-port') ?? false)) {
throwToolExit('Only one of "--observatory-port" and '
throwToolExit('Only one of "--vm-service-port" and '
'"--host-vmservice-port" may be specified.');
}
// If DDS is enabled and no explicit DDS port is provided, use the

View File

@@ -100,18 +100,18 @@ class CoverageCollector extends TestWatcher {
/// has been run to completion so that all coverage data has been recorded.
///
/// The returned [Future] completes when the coverage is collected.
Future<void> collectCoverageIsolate(Uri observatoryUri) async {
_logMessage('collecting coverage data from $observatoryUri...');
Future<void> collectCoverageIsolate(Uri vmServiceUri) async {
_logMessage('collecting coverage data from $vmServiceUri...');
final Map<String, dynamic> data = await collect(
observatoryUri, libraryNames, branchCoverage: branchCoverage);
vmServiceUri, libraryNames, branchCoverage: branchCoverage);
_logMessage('($observatoryUri): collected coverage data; merging...');
_logMessage('($vmServiceUri): collected coverage data; merging...');
_addHitmap(await coverage.HitMap.parseJson(
data['coverage'] as List<Map<String, dynamic>>,
packagePath: packageDirectory,
checkIgnoredLines: true,
));
_logMessage('($observatoryUri): done merging coverage data into global coverage map.');
_logMessage('($vmServiceUri): done merging coverage data into global coverage map.');
}
/// Collects coverage for the given [Process] using the given `port`.
@@ -141,11 +141,11 @@ class CoverageCollector extends TestWatcher {
}
);
final Future<void> collectionComplete = testDevice.observatoryUri
.then((Uri? observatoryUri) {
_logMessage('collecting coverage data from $testDevice at $observatoryUri...');
final Future<void> collectionComplete = testDevice.vmServiceUri
.then((Uri? vmServiceUri) {
_logMessage('collecting coverage data from $testDevice at $vmServiceUri...');
return collect(
observatoryUri!, libraryNames, serviceOverride: serviceOverride,
vmServiceUri!, libraryNames, serviceOverride: serviceOverride,
branchCoverage: branchCoverage)
.then<void>((Map<String, dynamic> result) {
_logMessage('Collected coverage data.');

View File

@@ -17,10 +17,15 @@ class EventPrinter extends TestWatcher {
final TestWatcher? _parent;
@override
void handleStartedDevice(Uri? observatoryUri) {
void handleStartedDevice(Uri? vmServiceUri) {
_sendEvent('test.startedProcess',
<String, dynamic>{'observatoryUri': observatoryUri?.toString()});
_parent?.handleStartedDevice(observatoryUri);
<String, dynamic>{
'vmServiceUri': vmServiceUri?.toString(),
// TODO(bkonyi): remove references to Observatory
// See https://github.com/flutter/flutter/issues/121271
'observatoryUri': vmServiceUri?.toString()
});
_parent?.handleStartedDevice(vmServiceUri);
}
@override

View File

@@ -34,7 +34,7 @@ import 'test_time_recorder.dart';
import 'watcher.dart';
/// The address at which our WebSocket server resides and at which the sky_shell
/// processes will host the Observatory server.
/// processes will host the VmService server.
final Map<InternetAddressType, InternetAddress> _kHosts = <InternetAddressType, InternetAddress>{
InternetAddressType.IPv4: InternetAddress.loopbackIPv4,
InternetAddressType.IPv6: InternetAddress.loopbackIPv6,
@@ -46,13 +46,15 @@ typedef PlatformPluginRegistration = void Function(FlutterPlatform platform);
///
/// On systems where each [FlutterPlatform] is only used to run one test suite
/// (that is, one Dart file with a `*_test.dart` file name and a single `void
/// main()`), you can set an observatory port explicitly.
/// main()`), you can set a VM Service port explicitly.
FlutterPlatform installHook({
TestWrapper testWrapper = const TestWrapper(),
required String shellPath,
required DebuggingOptions debuggingOptions,
TestWatcher? watcher,
// TODO(bkonyi): remove after roll into google3.
bool enableObservatory = false,
bool enableVmService = false,
bool machine = false,
String? precompiledDillPath,
Map<String, String>? precompiledDillFiles,
@@ -68,7 +70,7 @@ FlutterPlatform installHook({
TestTimeRecorder? testTimeRecorder,
UriConverter? uriConverter,
}) {
assert(enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
assert(enableVmService || enableObservatory || (!debuggingOptions.startPaused && debuggingOptions.hostVmServicePort == null));
// registerPlatformPlugin can be injected for testing since it's not very mock-friendly.
platformPluginRegistration ??= (FlutterPlatform platform) {
@@ -84,7 +86,7 @@ FlutterPlatform installHook({
debuggingOptions: debuggingOptions,
watcher: watcher,
machine: machine,
enableObservatory: enableObservatory,
enableVmService: enableVmService || enableObservatory,
host: _kHosts[serverType],
precompiledDillPath: precompiledDillPath,
precompiledDillFiles: precompiledDillFiles,
@@ -276,7 +278,7 @@ class FlutterPlatform extends PlatformPlugin {
required this.shellPath,
required this.debuggingOptions,
this.watcher,
this.enableObservatory,
this.enableVmService,
this.machine,
this.host,
this.precompiledDillPath,
@@ -295,7 +297,7 @@ class FlutterPlatform extends PlatformPlugin {
final String shellPath;
final DebuggingOptions debuggingOptions;
final TestWatcher? watcher;
final bool? enableObservatory;
final bool? enableVmService;
final bool? machine;
final InternetAddress? host;
final String? precompiledDillPath;
@@ -357,7 +359,7 @@ class FlutterPlatform extends PlatformPlugin {
if (_testCount > 0) {
// Fail if there will be a port conflict.
if (debuggingOptions.hostVmServicePort != null) {
throwToolExit('installHook() was called with an observatory port or debugger mode enabled, but then more than one test suite was run.');
throwToolExit('installHook() was called with a VM Service port or debugger mode enabled, but then more than one test suite was run.');
}
// Fail if we're passing in a precompiled entry-point.
if (precompiledDillPath != null) {
@@ -424,7 +426,7 @@ class FlutterPlatform extends PlatformPlugin {
processManager: globals.processManager,
logger: globals.logger,
shellPath: shellPath,
enableObservatory: enableObservatory!,
enableVmService: enableVmService!,
machine: machine,
debuggingOptions: debuggingOptions,
host: host,
@@ -512,13 +514,13 @@ class FlutterPlatform extends PlatformPlugin {
await Future.any<void>(<Future<void>>[
testDevice.finished,
() async {
final Uri? processObservatoryUri = await testDevice.observatoryUri;
if (processObservatoryUri != null) {
globals.printTrace('test $ourTestCount: Observatory uri is available at $processObservatoryUri');
final Uri? processVmServiceUri = await testDevice.vmServiceUri;
if (processVmServiceUri != null) {
globals.printTrace('test $ourTestCount: VM Service uri is available at $processVmServiceUri');
} else {
globals.printTrace('test $ourTestCount: Observatory uri is not available');
globals.printTrace('test $ourTestCount: VM Service uri is not available');
}
watcher?.handleStartedDevice(processObservatoryUri);
watcher?.handleStartedDevice(processVmServiceUri);
final StreamChannel<String> remoteChannel = await remoteChannelFuture;
globals.printTrace('test $ourTestCount: connected to test device, now awaiting test result');

View File

@@ -36,7 +36,7 @@ class FlutterTesterTestDevice extends TestDevice {
required this.logger,
required this.shellPath,
required this.debuggingOptions,
required this.enableObservatory,
required this.enableVmService,
required this.machine,
required this.host,
required this.testAssetDirectory,
@@ -45,8 +45,8 @@ class FlutterTesterTestDevice extends TestDevice {
required this.compileExpression,
required this.fontConfigManager,
required this.uriConverter,
}) : assert(!debuggingOptions.startPaused || enableObservatory),
_gotProcessObservatoryUri = enableObservatory
}) : assert(!debuggingOptions.startPaused || enableVmService),
_gotProcessVmServiceUri = enableVmService
? Completer<Uri?>() : (Completer<Uri?>()..complete());
/// Used for logging to identify the test that is currently being executed.
@@ -57,7 +57,7 @@ class FlutterTesterTestDevice extends TestDevice {
final Logger logger;
final String shellPath;
final DebuggingOptions debuggingOptions;
final bool enableObservatory;
final bool enableVmService;
final bool? machine;
final InternetAddress? host;
final String? testAssetDirectory;
@@ -67,7 +67,7 @@ class FlutterTesterTestDevice extends TestDevice {
final FontConfigManager fontConfigManager;
final UriConverter? uriConverter;
final Completer<Uri?> _gotProcessObservatoryUri;
final Completer<Uri?> _gotProcessVmServiceUri;
final Completer<int> _exitCode = Completer<int>();
Process? _process;
@@ -89,7 +89,7 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printTrace('test $id: test harness socket server is running at port:${_server!.port}');
final List<String> command = <String>[
shellPath,
if (enableObservatory) ...<String>[
if (enableVmService) ...<String>[
// Some systems drive the _FlutterPlatform class in an unusual way, where
// only one test file is processed at a time, and the operating
// environment hands out specific ports ahead of time in a cooperative
@@ -99,12 +99,12 @@ class FlutterTesterTestDevice extends TestDevice {
//
// I mention this only so that you won't be tempted, as I was, to apply
// the obvious simplification to this code and remove this entire feature.
'--observatory-port=${debuggingOptions.enableDds ? 0 : debuggingOptions.hostVmServicePort }',
'--vm-service-port=${debuggingOptions.enableDds ? 0 : debuggingOptions.hostVmServicePort }',
if (debuggingOptions.startPaused) '--start-paused',
if (debuggingOptions.disableServiceAuthCodes) '--disable-service-auth-codes',
]
else
'--disable-observatory',
'--disable-vm-service',
if (host!.type == InternetAddressType.IPv6) '--ipv6',
if (icudtlPath != null) '--icu-data-file-path=$icudtlPath',
'--enable-checked-mode',
@@ -154,11 +154,11 @@ class FlutterTesterTestDevice extends TestDevice {
logger.printTrace('test $id: Started flutter_tester process at pid ${_process!.pid}');
// Pipe stdout and stderr from the subprocess to our printStatus console.
// We also keep track of what observatory port the engine used, if any.
// We also keep track of what VM Service port the engine used, if any.
_pipeStandardStreamsToConsole(
process: _process!,
reportObservatoryUri: (Uri detectedUri) async {
assert(!_gotProcessObservatoryUri.isCompleted);
reportVmServiceUri: (Uri detectedUri) async {
assert(!_gotProcessVmServiceUri.isCompleted);
assert(debuggingOptions.hostVmServicePort == null ||
debuggingOptions.hostVmServicePort == detectedUri.port);
@@ -194,12 +194,11 @@ class FlutterTesterTestDevice extends TestDevice {
if (debuggingOptions.startPaused && !machine!) {
logger.printStatus('The test process has been started.');
logger.printStatus('You can now connect to it using observatory. To connect, load the following Web site in your browser:');
logger.printStatus('You can now connect to it using vmService. To connect, load the following Web site in your browser:');
logger.printStatus(' $forwardingUri');
logger.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
}
_gotProcessObservatoryUri.complete(forwardingUri);
_gotProcessVmServiceUri.complete(forwardingUri);
},
);
@@ -207,8 +206,8 @@ class FlutterTesterTestDevice extends TestDevice {
}
@override
Future<Uri?> get observatoryUri {
return _gotProcessObservatoryUri.future;
Future<Uri?> get vmServiceUri {
return _gotProcessVmServiceUri.future;
}
@override
@@ -293,7 +292,7 @@ class FlutterTesterTestDevice extends TestDevice {
void _pipeStandardStreamsToConsole({
required Process process,
required Future<void> Function(Uri uri) reportObservatoryUri,
required Future<void> Function(Uri uri) reportVmServiceUri,
}) {
for (final Stream<List<int>> stream in <Stream<List<int>>>[
process.stderr,
@@ -310,9 +309,9 @@ class FlutterTesterTestDevice extends TestDevice {
if (match != null) {
try {
final Uri uri = Uri.parse(match[1]!);
await reportObservatoryUri(uri);
await reportVmServiceUri(uri);
} on Exception catch (error) {
logger.printError('Could not parse shell observatory port message: $error');
logger.printError('Could not parse shell VM Service port message: $error');
}
} else {
logger.printStatus('Shell: $line');

View File

@@ -84,7 +84,7 @@ class TestGoldenComparator {
}
final List<String> command = <String>[
shellPath!,
'--disable-observatory',
'--disable-vm-service',
'--non-interactive',
'--packages=${_fileSystem.path.join('.dart_tool', 'package_config.json')}',
output,

View File

@@ -35,7 +35,7 @@ class IntegrationTestTestDevice implements TestDevice {
ApplicationPackage? _applicationPackage;
final Completer<void> _finished = Completer<void>();
final Completer<Uri> _gotProcessObservatoryUri = Completer<Uri>();
final Completer<Uri> _gotProcessVmServiceUri = Completer<Uri>();
/// Starts the device.
///
@@ -62,19 +62,19 @@ class IntegrationTestTestDevice implements TestDevice {
if (!launchResult.started) {
throw TestDeviceException('Unable to start the app on the device.', StackTrace.current);
}
final Uri? observatoryUri = launchResult.observatoryUri;
if (observatoryUri == null) {
throw TestDeviceException('Observatory is not available on the test device.', StackTrace.current);
final Uri? vmServiceUri = launchResult.vmServiceUri;
if (vmServiceUri == null) {
throw TestDeviceException('The VM Service is not available on the test device.', StackTrace.current);
}
// No need to set up the log reader because the logs are captured and
// streamed to the package:test_core runner.
_gotProcessObservatoryUri.complete(observatoryUri);
_gotProcessVmServiceUri.complete(vmServiceUri);
globals.printTrace('test $id: Connecting to vm service');
final FlutterVmService vmService = await connectToVmService(
observatoryUri,
vmServiceUri,
logger: globals.logger,
compileExpression: compileExpression,
).timeout(
@@ -116,7 +116,7 @@ class IntegrationTestTestDevice implements TestDevice {
}
@override
Future<Uri> get observatoryUri => _gotProcessObservatoryUri.future;
Future<Uri> get vmServiceUri => _gotProcessVmServiceUri.future;
@override
Future<void> kill() async {

View File

@@ -30,7 +30,7 @@ abstract class FlutterTestRunner {
List<String> plainNames = const <String>[],
String? tags,
String? excludeTags,
bool enableObservatory = false,
bool enableVmService = false,
bool ipv6 = false,
bool machine = false,
String? precompiledDillPath,
@@ -68,7 +68,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
List<String> plainNames = const <String>[],
String? tags,
String? excludeTags,
bool enableObservatory = false,
bool enableVmService = false,
bool ipv6 = false,
bool machine = false,
String? precompiledDillPath,
@@ -197,7 +197,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
shellPath: shellPath,
debuggingOptions: debuggingOptions,
watcher: watcher,
enableObservatory: enableObservatory,
enableVmService: enableVmService,
machine: machine,
serverType: serverType,
precompiledDillPath: precompiledDillPath,

View File

@@ -21,8 +21,8 @@ abstract class TestDevice {
/// or raw source file.
Future<StreamChannel<String>> start(String entrypointPath);
/// Should complete with null if the observatory is not enabled.
Future<Uri?> get observatoryUri;
/// Should complete with null if the VM Service is not enabled.
Future<Uri?> get vmServiceUri;
/// Terminates the test device.
Future<void> kill();

View File

@@ -8,9 +8,9 @@ import 'test_device.dart';
abstract class TestWatcher {
/// Called after the test device starts.
///
/// If startPaused was true, the caller needs to resume in Observatory to
/// If startPaused was true, the caller needs to resume in DevTools to
/// start running the tests.
void handleStartedDevice(Uri? observatoryUri) { }
void handleStartedDevice(Uri? vmServiceUri) { }
/// Called after the tests finish but before the test device exits.
///

View File

@@ -174,11 +174,11 @@ class FlutterTesterDevice extends Device {
if (debuggingOptions.disableServiceAuthCodes)
'--disable-service-auth-codes',
if (debuggingOptions.hostVmServicePort != null)
'--observatory-port=${debuggingOptions.hostVmServicePort}',
'--vm-service-port=${debuggingOptions.hostVmServicePort}',
applicationKernelFilePath,
];
ProtocolDiscovery? observatoryDiscovery;
ProtocolDiscovery? vmServiceDiscovery;
try {
_logger.printTrace(command.join(' '));
_process = await _processManager.start(command,
@@ -190,7 +190,7 @@ class FlutterTesterDevice extends Device {
return LaunchResult.succeeded();
}
observatoryDiscovery = ProtocolDiscovery.observatory(
vmServiceDiscovery = ProtocolDiscovery.vmService(
getLogReader(),
hostPort: debuggingOptions.hostVmServicePort,
devicePort: debuggingOptions.deviceVmServicePort,
@@ -199,9 +199,9 @@ class FlutterTesterDevice extends Device {
);
_logReader.initializeProcess(_process!);
final Uri? observatoryUri = await observatoryDiscovery.uri;
if (observatoryUri != null) {
return LaunchResult.succeeded(observatoryUri: observatoryUri);
final Uri? vmServiceUri = await vmServiceDiscovery.uri;
if (vmServiceUri != null) {
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
}
_logger.printError(
'Failed to launch $package: '
@@ -210,7 +210,7 @@ class FlutterTesterDevice extends Device {
} on Exception catch (error) {
_logger.printError('Failed to launch $package: $error');
} finally {
await observatoryDiscovery?.cancel();
await vmServiceDiscovery?.cancel();
}
return LaunchResult.failed();
}

View File

@@ -120,7 +120,7 @@ class Tracing {
}
}
/// Download the startup trace information from the given observatory client and
/// Download the startup trace information from the given VM Service client and
/// store it to `$output/start_up_info.json`.
Future<void> downloadStartupTrace(FlutterVmService vmService, {
bool awaitFirstFrame = true,

View File

@@ -73,7 +73,7 @@ abstract class RPCErrorCodes {
/// The VM Service Protocol allows clients to register custom services that
/// can be invoked by other clients through the service protocol itself.
///
/// Clients like Observatory use external 'reloadSources' services,
/// Clients like VmService use external 'reloadSources' services,
/// when available, instead of the VM internal one. This allows these clients to
/// invoke Flutter HotReload when connected to a Flutter Application started in
/// hot mode.

View File

@@ -153,7 +153,7 @@ abstract class ChromiumDevice extends Device {
);
}
_logger.sendEvent('app.webLaunchUrl', <String, Object>{'url': url, 'launched': launchChrome});
return LaunchResult.succeeded(observatoryUri: Uri.parse(url));
return LaunchResult.succeeded(vmServiceUri: Uri.parse(url));
}
@override
@@ -474,7 +474,7 @@ class WebServerDevice extends Device {
'Consider using the Chrome or Edge devices for an improved development workflow.'
);
_logger.sendEvent('app.webLaunchUrl', <String, Object?>{'url': url, 'launched': false});
return LaunchResult.succeeded(observatoryUri: url != null ? Uri.parse(url): null);
return LaunchResult.succeeded(vmServiceUri: url != null ? Uri.parse(url): null);
}
@override