Start removing Observatory support and references (#169216)

This change removes references to Observatory, including:

 - Deprecated flags
 - Deprecated embedder APIs
 - Outdated documentation
 - Documentation instances where "VM service" should have been used
 - Incorrectly named tests / directories

As a part of this change, `--serve-observatory` is no longer a valid
flag.

Observatory is still available for now via the `_serveObservatory` RPC,
but will be removed in a follow up PR once we've prepared for breakages
in G3.

Work towards https://github.com/dart-lang/sdk/issues/50233

FYI @a-siva
This commit is contained in:
Ben Konyi 2025-05-23 20:00:30 -04:00 committed by GitHub
parent 16fabc7b58
commit b2b4fb5cbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
46 changed files with 60 additions and 335 deletions

View File

@ -14,7 +14,7 @@
set -e
# To debug the tool, you can uncomment the following lines to enable debug
# mode and set an observatory port:
# mode and set a VM service port:
# FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS"
# FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432"

View File

@ -19,7 +19,7 @@ set -e
# the effects immediately, but is much slower than using the prebuilt snapshot.
# To debug the tool, you can uncomment the following lines to enable debug
# mode and set an observatory port:
# mode and set a VM service port:
# FLUTTER_TOOL_ARGS="--enable-asserts $FLUTTER_TOOL_ARGS"
# FLUTTER_TOOL_ARGS="$FLUTTER_TOOL_ARGS --observe=65432"

View File

@ -13,6 +13,6 @@ The strings in these files are used in `dev/bots/test.dart`.
The tests in this folder must be run with `flutter test --enable-vmservice`,
since they test that trace data is written to the timeline by connecting to
the observatory.
the VM service.
These tests will fail if run without this flag.

View File

@ -36,9 +36,9 @@ application (which is necessary to use `flutter run` with a test).
Unit tests run with `flutter test` run inside a headless flutter shell on your workstation,
you won't see any UI. You can use `print` to generate console output or you can interact
with the Dart VM via the Dart Observatory at [http://localhost:8181/](http://localhost:8181/).
with the Dart VM via Flutter DevTools at [http://localhost:8181/](http://localhost:8181/).
To debug tests in Observatory, use the `--start-paused` option to start the test in a
To debug tests in Flutter DevTools, use the `--start-paused` option to start the test in a
paused state and wait for connection from a debugger. This option lets you set breakpoints
before the test runs.

View File

@ -78,8 +78,8 @@ To run or debug the tests in IDE, make sure `FLUTTER_ROOT` directory is set up.
For example, in Android Studio, select the configuration for the test, click "Edit Configurations...",
under "Environment Variables" section, enter `FLUTTER_ROOT=directory_to_your_flutter_framework_repo`.
The pre-built flutter tool runs in release mode with the observatory off by default.
To enable debugging mode and the observatory on the `flutter` tool, uncomment the
The pre-built flutter tool runs in release mode with the Dart VM service off by default.
To enable debugging mode and Dart DevTools for the `flutter` tool, uncomment the
`FLUTTER_TOOL_ARGS` line in the `bin/flutter` (or `bin/flutter-dev`) shell script.
## Debugging the `flutter` command-line tool in VS Code

View File

@ -21,6 +21,7 @@ The config file contains all the configured custom devices. To see documentation
If your device is reachable via ssh, you can add it to the config with a guided setup using `flutter custom-devices add`.
The setup really is self-explanatory, but for example for my Raspberry Pi, the setup looks like this:
```
hannes@pop-os:~/devel$ flutter custom-devices add
Please enter the id you want to device to have. Must contain only alphanumeric
@ -45,7 +46,7 @@ Please enter the command executed on the remote device for starting the app.
flutter-pi /tmp/${appName}
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
address and you have a way of specifying the "--vm-service-host=<ip>" engine
option, you might prefer not using port forwarding. [Y/n] (empty for default)
Enter the command executed on the remote device for taking a screenshot.

View File

@ -80,11 +80,11 @@
},
{
"language": "dart",
"name": "test: observatory and service protocol",
"script": "flutter/shell/testing/observatory/test.dart",
"name": "test: service protocol",
"script": "flutter/shell/testing/vm_service/test.dart",
"parameters": [
"out/ci/host_debug_unopt/flutter_tester",
"flutter/shell/testing/observatory/empty_main.dart"
"flutter/shell/testing/vm_service/empty_main.dart"
]
},
{

View File

@ -161,7 +161,7 @@ Then you can open it in the debugger with:
gdb build/linux/x64/debug/bundle/your_app_name
```
Note that this won't help you debug the Dart portion of the app: this is just for debugging the engine code. If you need to simultaneously debug the Dart portion, you can connect to the observatory port given when you run the app in `gdb`.
Note that this won't help you debug the Dart portion of the app: this is just for debugging the engine code. If you need to simultaneously debug the Dart portion, you can connect to the VM service port given when you run the app in `gdb`.
## Logging in the engine

View File

@ -1,16 +1,15 @@
We aspire to reach a state where developers are able to use the following modes for running Flutter code. Our tools should not expose any other combinations of features or modes. Each mode corresponds to a separate build of the engine that we provide.
1. **Debug** mode on device (including simulators, emulators): Turns on all the assertions in the world, includes all debugging information, enables all the debugger aids (e.g. observatory) and service extensions. Optimizes for fast develop/run cycles. Does not optimize for execution speed, binary size, or deployment. Used by `flutter run`. Built with `sky/tools/gn --android` or `sky/tools/gn --ios`. Also sometimes called "**checked** mode" or "**slow** mode".
1. **Debug** mode on device (including simulators, emulators): Turns on all the assertions in the world, includes all debugging information, enables all the debugger aids (e.g. Flutter DevTools) and service extensions. Optimizes for fast develop/run cycles. Does not optimize for execution speed, binary size, or deployment. Used by `flutter run`. Built with `sky/tools/gn --android` or `sky/tools/gn --ios`. Also sometimes called "**checked** mode" or "**slow** mode".
2. **Release** mode on device (excluding simulators, emulators): Turns off all assertions, strips as much debugging information as possible, turns off all the debugger tools. Optimizes for fast startup, fast execution, small package sizes. Disables any debugging aids. Disables service extensions. Intended for deployment to end-users. Used by `flutter run --release`. Built with `sky/tools/gn --android --runtime-mode=release` or `sky/tools/gn --ios --runtime-mode=release`.
2. **Release** mode on device (excluding simulators, emulators): Turns off all assertions, strips as much debugging information as possible, turns off all the debugger tools. Optimizes for fast startup, fast execution, small package sizes. Disables any debugging aids. Disables service extensions. Intended for deployment to end-users. Used by `flutter run --release`. Built with `sky/tools/gn --android --runtime-mode=release` or `sky/tools/gn --ios --runtime-mode=release`.
3. **Profile** mode on device (excluding simulators, emulators): Same as release mode except that profile-mode service extensions (like the one that turns on the performance overlay) is enabled, and tracing is enabled, as well as the minimum required to support using the tracing information (e.g. observatory can probably connect to the process). Used by `flutter run --profile`. Built with `sky/tools/gn --android --runtime-mode=profile` or `sky/tools/gn --ios --runtime-mode=profile`. Not available on simulators or emulators because profiling on simulators is not representative of real performance.
3. **Profile** mode on device (excluding simulators, emulators): Same as release mode except that profile-mode service extensions (like the one that turns on the performance overlay) is enabled, and tracing is enabled, as well as the minimum required to support using the tracing information (e.g. Flutter DevTools can probably connect to the process). Used by `flutter run --profile`. Built with `sky/tools/gn --android --runtime-mode=profile` or `sky/tools/gn --ios --runtime-mode=profile`. Not available on simulators or emulators because profiling on simulators is not representative of real performance.
4. Headless **test** mode on desktop: Same as debug mode except headless and for desktop platforms. Used by `flutter test`. Built with `sky/tools/gn`.
In addition, for our purposes during development, each of the above should be able to be built in two modes: optimized, which is what end-developers use, and unoptimized, which is what we would use when debugging the engine. Optimized is the default, unoptimized engines are built by adding `--unoptimized` to the arguments.
### Artifact differences
Debug mode produces a script snapshot, which is basically tokenized sources. Comments and whitespace are missing, literals are canonicalized. There is no machine code, tree-shaking or obfuscation.
@ -21,22 +20,22 @@ Profile and release modes produce app-aot snapshots, either as dylibs (iOS and F
The following axes, as described above, exist:
* debug, release, profile
* opt, unopt
* iOS, Android, macOS, Linux, Windows
- debug, release, profile
- opt, unopt
- iOS, Android, macOS, Linux, Windows
In addition, some versions can select alternative graphics backends:
* iOS can choose between: OpenGL, software
* Android can choose between: Vulkan, OpenGL, software
* macOS can choose between, OpenGL, software, headless (debug only)
* Linux can choose between: OpenGL, software, headless (debug only)
* Windows can choose between: OpenGL, software, headless (debug only)
- iOS can choose between: OpenGL, software
- Android can choose between: Vulkan, OpenGL, software
- macOS can choose between, OpenGL, software, headless (debug only)
- Linux can choose between: OpenGL, software, headless (debug only)
- Windows can choose between: OpenGL, software, headless (debug only)
Separate from all the above, Fuchsia has the following modes:
* AOT, JIT, interpreted DBC
* Observatory present, observatory absent
* opt, unopt
- AOT, JIT, interpreted DBC
- VM Service present, VM Service absent
- opt, unopt
In total therefore there are 3&times;2&times;(2+3+2+2+2) + 1&times;2&times;3 + 3&times;2&times;2 modes, which is 84 modes.

View File

@ -110,6 +110,6 @@ You also need to set the `--enable_playground` flag in order to do frame capturi
This is also the spot where you will add other command line arguments that will
aid in your debugging. In that example, `–timeout=-1` will disable the Flutter
test hang watchdog which will kill your process if the test doesn’t complete in
30 seconds. I also like to set the observatory port to a known value so I can
30 seconds. I also like to set the VM service port to a known value so I can
get to it and disable service auth codes so I can just refresh the page to
launch the latest version of the observatory.
connect to a new instance of the VM service.

View File

@ -234,28 +234,16 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
// Enable the VM Service
settings.enable_vm_service =
!command_line.HasOption(FlagForSwitch(Switch::DisableVMService)) &&
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
!command_line.HasOption(FlagForSwitch(Switch::DisableObservatory));
!command_line.HasOption(FlagForSwitch(Switch::DisableVMService));
// Enable mDNS VM Service Publication
settings.enable_vm_service_publication =
!command_line.HasOption(
FlagForSwitch(Switch::DisableVMServicePublication)) &&
!command_line.HasOption(
FlagForSwitch(Switch::DisableObservatoryPublication));
settings.enable_vm_service_publication = !command_line.HasOption(
FlagForSwitch(Switch::DisableVMServicePublication));
// Set VM Service Host
if (command_line.HasOption(FlagForSwitch(Switch::DeviceVMServiceHost))) {
command_line.GetOptionValue(FlagForSwitch(Switch::DeviceVMServiceHost),
&settings.vm_service_host);
} else if (command_line.HasOption(
FlagForSwitch(Switch::DeviceObservatoryHost))) {
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
command_line.GetOptionValue(FlagForSwitch(Switch::DeviceObservatoryHost),
&settings.vm_service_host);
}
// Default the VM Service port based on --ipv6 if not set.
if (settings.vm_service_host.empty()) {
@ -272,16 +260,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
<< "VM Service port specified was malformed. Will default to "
<< settings.vm_service_port;
}
} else if (command_line.HasOption(
FlagForSwitch(Switch::DeviceObservatoryPort))) {
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,
&settings.vm_service_port)) {
FML_LOG(INFO)
<< "VM Service port specified was malformed. Will default to "
<< settings.vm_service_port;
}
}
settings.may_insecurely_connect_to_all_domains = !command_line.HasOption(

View File

@ -75,45 +75,18 @@ DEF_SWITCH(DeviceVMServiceHost,
"The hostname/IP address on which the Dart VM Service should "
"be served. If not set, defaults to 127.0.0.1 or ::1 depending on "
"whether --ipv6 is specified.")
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(
DeviceObservatoryHost,
"observatory-host",
"(deprecated) The hostname/IP address on which the Dart VM Service should "
"be served. If not set, defaults to 127.0.0.1 or ::1 depending on "
"whether --ipv6 is specified.")
DEF_SWITCH(DeviceVMServicePort,
"vm-service-port",
"A custom Dart VM Service port. The default is to pick a randomly "
"available open port.")
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DeviceObservatoryPort,
"observatory-port",
"(deprecated) A custom Dart VM Service port. The default is to pick "
"a randomly "
"available open port.")
DEF_SWITCH(
DisableVMService,
"disable-vm-service",
"Disable the Dart VM Service. The Dart VM Service is never available "
"in release mode.")
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DisableObservatory,
"disable-observatory",
"(deprecated) Disable the Dart VM Service. The Dart VM Service is "
"never available "
"in release mode.")
DEF_SWITCH(DisableVMServicePublication,
"disable-vm-service-publication",
"Disable mDNS Dart VM Service publication.")
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DisableObservatoryPublication,
"disable-observatory-publication",
"(deprecated) Disable mDNS Dart VM Service publication.")
DEF_SWITCH(IPv6,
"ipv6",
"Bind to the IPv6 localhost address for the Dart VM Service. "

View File

@ -257,20 +257,6 @@ public class FlutterJNI {
return vmServiceUri;
}
/**
* VM Service URI for the VM instance.
*
* <p>Its value is set by the native engine once {@link #init(Context, String[], String, String,
* String, long, int)} is run.
*
* @deprecated replaced by {@link #getVMServiceUri()}.
*/
@Deprecated
@Nullable
public static String getObservatoryUri() {
return vmServiceUri;
}
/**
* Notifies the engine about the refresh rate of the display when the API level is below 30.
*

View File

@ -61,9 +61,6 @@ public class FlutterShellArgs {
public static final String ARG_VERBOSE_LOGGING = "--verbose-logging";
public static final String ARG_KEY_VM_SERVICE_PORT = "vm-service-port";
public static final String ARG_VM_SERVICE_PORT = "--vm-service-port=";
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
public static final String ARG_KEY_OBSERVATORY_PORT = "observatory-port";
public static final String ARG_KEY_DART_FLAGS = "dart-flags";
public static final String ARG_DART_FLAGS = "--dart-flags";
@ -83,13 +80,6 @@ public class FlutterShellArgs {
int vmServicePort = intent.getIntExtra(ARG_KEY_VM_SERVICE_PORT, 0);
if (vmServicePort > 0) {
args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort));
} else {
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
// See https://github.com/dart-lang/sdk/issues/50233
vmServicePort = intent.getIntExtra(ARG_KEY_OBSERVATORY_PORT, 0);
if (vmServicePort > 0) {
args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort));
}
}
if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) {
args.add(ARG_DISABLE_SERVICE_AUTH_CODES);

View File

@ -411,16 +411,6 @@ FLUTTER_DARWIN_EXPORT
*/
@property(nonatomic, readonly) FlutterBasicMessageChannel* keyEventChannel;
/**
* The depcreated `NSURL` of the Dart VM Service for the service isolate.
*
* This is only set in debug and profile runtime modes, and only after the
* Dart VM Service is ready. In release mode or before the Dart VM Service has
* started, it returns `nil`.
*/
@property(nonatomic, readonly, nullable)
NSURL* observatoryUrl FLUTTER_DEPRECATED("Use vmServiceUrl instead");
/**
* The `NSURL` of the Dart VM Service for the service isolate.
*

View File

@ -505,10 +505,6 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
_platformViewsController = nil;
}
- (NSURL*)observatoryUrl {
return self.publisher.url;
}
- (NSURL*)vmServiceUrl {
return self.publisher.url;
}

View File

@ -58,23 +58,11 @@ Future<void> testWebSocketProtocolRequest(Uri uri) async {
}
}
// Test accessing an Observatory UI asset.
Future<void> testHttpAssetRequest(Uri uri) async {
uri = uri.replace(path: 'third_party/trace_viewer_full.html');
final HttpClient client = HttpClient();
final HttpClientRequest request = await client.getUrl(uri);
final HttpClientResponse response = await request.close();
Expect.equals(response.statusCode, 200);
await response.drain<void>();
client.close();
}
typedef TestFunction = Future<void> Function(Uri uri);
final List<TestFunction> basicTests = <TestFunction>[
testHttpProtocolRequest,
testWebSocketProtocolRequest,
testHttpAssetRequest,
];
Future<bool> runTests(ShellLauncher launcher, List<TestFunction> tests) async {

View File

@ -67,7 +67,7 @@ def launch_package(package_name, activity_name, adb_path='adb'):
stderr=subprocess.STDOUT)
for line in logcat.stdout:
print('>>>>>>>> ' + line.strip())
if ('Observatory listening' in line) or ('Dart VM service is listening' in line):
if 'Dart VM service is listening' in line:
logcat.kill()
break

View File

@ -1,5 +1,5 @@
Tests in this folder need to be run with the observatory enabled, e.g. to make
Tests in this folder need to be run with the Dart VM service enabled, e.g. to make
VM service method calls.
The `run_tests.py` script disables the observatory for other tests in the
parent directory.
The `run_tests.py` script disables the Dart VM service for other tests in the
parent directory.

View File

@ -612,17 +612,17 @@ class FlutterTesterOptions():
self,
multithreaded=False,
enable_impeller=False,
enable_observatory=False,
enable_vm_service=False,
expect_failure=False
):
self.multithreaded = multithreaded
self.enable_impeller = enable_impeller
self.enable_observatory = enable_observatory
self.enable_vm_service = enable_vm_service
self.expect_failure = expect_failure
def apply_args(self, command_args):
if not self.enable_observatory:
command_args.append('--disable-observatory')
if not self.enable_vm_service:
command_args.append('--disable-vm-service')
if self.enable_impeller:
command_args += ['--enable-impeller', '--enable-flutter-gpu']
@ -867,15 +867,15 @@ def gather_dart_tests(build_dir, test_filter):
cwd=dart_tests_dir,
)
dart_observatory_tests = glob.glob('%s/observatory/*_test.dart' % dart_tests_dir)
dart_vm_service_tests = glob.glob('%s/vm_service/*_test.dart' % dart_tests_dir)
dart_tests = glob.glob('%s/*_test.dart' % dart_tests_dir)
if 'release' not in build_dir:
for dart_test_file in dart_observatory_tests:
for dart_test_file in dart_vm_service_tests:
if test_filter is not None and os.path.basename(dart_test_file) not in test_filter:
logger.info("Skipping '%s' due to filter.", dart_test_file)
else:
logger.info("Gathering dart test '%s' with observatory enabled", dart_test_file)
logger.info("Gathering dart test '%s' with VM service enabled", dart_test_file)
for multithreaded in [False, True]:
for enable_impeller in [False, True]:
yield gather_dart_test(
@ -883,7 +883,7 @@ def gather_dart_tests(build_dir, test_filter):
FlutterTesterOptions(
multithreaded=multithreaded,
enable_impeller=enable_impeller,
enable_observatory=True
enable_vm_service=True
)
)

View File

@ -6990,7 +6990,7 @@ class MouseRegion extends SingleChildRenderObjectWidget {
/// * [debugRepaintRainbowEnabled], a debugging flag to help visually monitor
/// render tree repaints in a running app.
/// * [debugProfilePaintsEnabled], a debugging flag to show render tree
/// repaints in the observatory's timeline view.
/// repaints in Flutter DevTools' timeline view.
class RepaintBoundary extends SingleChildRenderObjectWidget {
/// Creates a widget that isolates repaints.
const RepaintBoundary({super.key, super.child});

View File

@ -1820,7 +1820,7 @@ mixin WidgetInspectorService {
/// Wrapper around `json.encode` that uses a ring of cached values to prevent
/// the Dart garbage collector from collecting objects between when
/// the value is returned over the VM service protocol and when the
/// separate observatory protocol command has to be used to retrieve its full
/// separate VM service protocol command has to be used to retrieve its full
/// contents.
//
// TODO(jacobr): Replace this with a better solution once
@ -2804,8 +2804,7 @@ class _WidgetForTypeTests extends Widget {
/// Select a location on your device or emulator and view what widgets and
/// render object that best matches the location. An outline of the selected
/// widget and terse summary information is shown on device with detailed
/// information is shown in the observatory or in IntelliJ when using the
/// Flutter Plugin.
/// information is shown in Flutter DevTools.
///
/// The inspector has a select mode and a view mode.
///

View File

@ -123,10 +123,9 @@ abstract class FlutterDriver {
///
/// Resumes the application if it is currently paused (e.g. at a breakpoint).
///
/// The `dartVmServiceUrl` parameter is the URL to Dart observatory
/// (a.k.a. VM service). If not specified, the URL specified by the
/// `VM_SERVICE_URL` environment variable is used. One or the other must be
/// specified.
/// The `dartVmServiceUrl` parameter is the URL to the Dart VM service. If
/// not specified, the URL specified by the `VM_SERVICE_URL` environment
/// variable is used. One or the other must be specified.
///
/// The `printCommunication` parameter determines whether the command
/// communication between the test and the app should be printed to stdout.

View File

@ -142,7 +142,6 @@ class AttachCommand extends FlutterCommand {
usesTrackWidgetCreation(verboseHelp: verboseHelp);
addDdsOptions(verboseHelp: verboseHelp);
addDevToolsOptions(verboseHelp: verboseHelp);
addServeObservatoryOptions(verboseHelp: verboseHelp);
usesDeviceTimeoutOption();
usesDeviceConnectionOption();
}
@ -208,8 +207,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
return uri;
}
bool get serveObservatory => boolArg('serve-observatory');
String? get appId {
return stringArg('app-id');
}
@ -487,7 +484,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
enableDds: enableDds,
ddsPort: ddsPort,
devToolsServerAddress: devToolsServerAddress,
serveObservatory: serveObservatory,
usingCISystem: usingCISystem,
debugLogsDirectoryPath: debugLogsDirectoryPath,
enableDevTools: boolArg(FlutterCommand.kEnableDevTools),

View File

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

View File

@ -214,7 +214,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
usesDeviceConnectionOption();
addDdsOptions(verboseHelp: verboseHelp);
addDevToolsOptions(verboseHelp: verboseHelp);
addServeObservatoryOptions(verboseHelp: verboseHelp);
addAndroidSpecificBuildOptions(hide: !verboseHelp);
usesFatalWarningsOption(verboseHelp: verboseHelp);
addEnableImpellerFlag(verboseHelp: verboseHelp);
@ -360,7 +359,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
enableImpeller: enableImpeller,
enableVulkanValidation: enableVulkanValidation,
uninstallFirst: uninstallFirst,
serveObservatory: boolArg('serve-observatory'),
enableDartProfiling: enableDartProfiling,
enableEmbedderApi: enableEmbedderApi,
usingCISystem: usingCISystem,

View File

@ -29,7 +29,6 @@ class ScreenshotCommand extends FlutterCommand {
);
argParser.addOption(
_kVmServiceUrl,
aliases: <String>['observatory-url'], // for historical reasons
valueHelp: 'URI',
help:
'The VM Service URL to which to connect.\n'

View File

@ -294,7 +294,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
);
addDdsOptions(verboseHelp: verboseHelp);
addServeObservatoryOptions(verboseHelp: verboseHelp);
usesFatalWarningsOption(verboseHelp: verboseHelp);
}
@ -461,7 +460,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
buildInfo,
startPaused: startPaused,
disableServiceAuthCodes: boolArg('disable-service-auth-codes'),
serveObservatory: boolArg('serve-observatory'),
// On iOS >=14, keeping this enabled will leave a prompt on the screen.
disablePortPublication: true,
enableDds: enableDds,

View File

@ -968,7 +968,6 @@ class DebuggingOptions {
this.enableImpeller = ImpellerStatus.platformDefault,
this.enableVulkanValidation = false,
this.uninstallFirst = false,
this.serveObservatory = false,
this.enableDartProfiling = true,
this.enableEmbedderApi = false,
this.usingCISystem = false,
@ -1031,7 +1030,6 @@ class DebuggingOptions {
fastStart = false,
webEnableExpressionEvaluation = false,
nativeNullAssertions = false,
serveObservatory = false,
enableDevTools = false,
ipv6 = false,
google3WorkspaceRoot = null,
@ -1085,7 +1083,6 @@ class DebuggingOptions {
required this.enableImpeller,
required this.enableVulkanValidation,
required this.uninstallFirst,
required this.serveObservatory,
required this.enableDartProfiling,
required this.enableEmbedderApi,
required this.usingCISystem,
@ -1131,7 +1128,6 @@ class DebuggingOptions {
final bool webUseSseForInjectedClient;
final ImpellerStatus enableImpeller;
final bool enableVulkanValidation;
final bool serveObservatory;
final bool enableDartProfiling;
final bool enableEmbedderApi;
final bool usingCISystem;
@ -1281,7 +1277,6 @@ class DebuggingOptions {
'nativeNullAssertions': nativeNullAssertions,
'enableImpeller': enableImpeller.asBool,
'enableVulkanValidation': enableVulkanValidation,
'serveObservatory': serveObservatory,
'enableDartProfiling': enableDartProfiling,
'enableEmbedderApi': enableEmbedderApi,
'usingCISystem': usingCISystem,
@ -1351,7 +1346,6 @@ class DebuggingOptions {
enableImpeller: ImpellerStatus.fromBool(json['enableImpeller'] as bool?),
enableVulkanValidation: (json['enableVulkanValidation'] as bool?) ?? false,
uninstallFirst: (json['uninstallFirst'] as bool?) ?? false,
serveObservatory: (json['serveObservatory'] as bool?) ?? false,
enableDartProfiling: (json['enableDartProfiling'] as bool?) ?? true,
enableEmbedderApi: (json['enableEmbedderApi'] as bool?) ?? false,
usingCISystem: (json['usingCISystem'] as bool?) ?? false,
@ -1364,9 +1358,7 @@ class DebuggingOptions {
}
class LaunchResult {
LaunchResult.succeeded({Uri? vmServiceUri, Uri? observatoryUri})
: started = true,
vmServiceUri = vmServiceUri ?? observatoryUri;
LaunchResult.succeeded({this.vmServiceUri}) : started = true;
LaunchResult.failed() : started = false, vmServiceUri = null;

View File

@ -365,9 +365,7 @@ class ProxiedDevice extends Device {
}),
);
final bool started = _cast<bool>(result['started']);
// TODO(bkonyi): remove once clients have migrated to relying on vmServiceUri.
final String? vmServiceUriStr =
_cast<String?>(result['vmServiceUri']) ?? _cast<String?>(result['observatoryUri']);
final String? vmServiceUriStr = _cast<String?>(result['vmServiceUri']);
final Uri? vmServiceUri = vmServiceUriStr == null ? null : Uri.parse(vmServiceUriStr);
if (started) {
if (vmServiceUri != null) {

View File

@ -1347,23 +1347,6 @@ abstract class ResidentRunner extends ResidentHandlers {
_finished.complete(0);
}
Future<void> enableObservatory() async {
assert(debuggingOptions.serveObservatory);
final List<Future<vm_service.Response?>> serveObservatoryRequests =
<Future<vm_service.Response?>>[
for (final FlutterDevice? device in flutterDevices)
if (device != null)
// Notify the VM service if the user wants Observatory to be served.
device.vmService?.callMethodWrapper('_serveObservatory') ??
Future<vm_service.Response?>.value(),
];
try {
await Future.wait(serveObservatoryRequests);
} on vm_service.RPCError catch (e) {
globals.printWarning('Unable to enable Observatory: $e');
}
}
@protected
void appFinished() {
if (_finished.isCompleted) {

View File

@ -75,10 +75,6 @@ class ColdRunner extends ResidentRunner {
}
}
if (debuggingEnabled && debuggingOptions.serveObservatory) {
await enableObservatory();
}
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
if (debuggingEnabled && debuggingOptions.enableDevTools) {
// The method below is guaranteed never to return a failing future.
@ -160,10 +156,6 @@ class ColdRunner extends ResidentRunner {
}
}
if (debuggingEnabled && debuggingOptions.serveObservatory) {
await enableObservatory();
}
appStartedCompleter?.complete();
if (stayResident) {
return waitForAppToFinish();

View File

@ -266,11 +266,6 @@ class HotRunner extends ResidentRunner {
globals.printError('Error connecting to the service protocol: $error');
return 2;
}
if (debuggingOptions.serveObservatory) {
await enableObservatory();
}
// TODO(bkonyi): remove when ready to serve DevTools from DDS.
if (debuggingOptions.enableDevTools) {
// The method below is guaranteed never to return a failing future.

View File

@ -169,9 +169,6 @@ abstract class FlutterCommand extends Command<void> {
/// 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.
static const String kDevToolsServerAddress = 'devtools-server-address';
@ -518,16 +515,6 @@ abstract class FlutterCommand extends Command<void> {
'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',
help:
@ -608,14 +595,6 @@ abstract class FlutterCommand extends Command<void> {
);
}
void addServeObservatoryOptions({required bool verboseHelp}) {
argParser.addFlag(
'serve-observatory',
hide: !verboseHelp,
help: 'Serve the legacy Observatory developer tooling through the VM service.',
);
}
late final bool enableDds = () {
bool ddsEnabled = false;
if (argResults?.wasParsed('disable-dds') ?? false) {
@ -646,12 +625,10 @@ abstract class FlutterCommand extends Command<void> {
bool get _hostVmServicePortProvided =>
(argResults?.wasParsed(vmServicePortOption) ?? false) ||
(argResults?.wasParsed(observatoryPortOption) ?? false) ||
(argResults?.wasParsed('host-vmservice-port') ?? false);
int _tryParseHostVmservicePort() {
final String? vmServicePort =
stringArg(vmServicePortOption) ?? stringArg(observatoryPortOption);
final String? vmServicePort = stringArg(vmServicePortOption);
final String? hostPort = stringArg('host-vmservice-port');
if (vmServicePort == null && hostPort == null) {
throwToolExit('Invalid port for `--vm-service-port/--host-vmservice-port`');
@ -697,7 +674,6 @@ abstract class FlutterCommand extends Command<void> {
return null;
}
if ((argResults?.wasParsed(vmServicePortOption) ?? false) &&
(argResults?.wasParsed(observatoryPortOption) ?? false) &&
(argResults?.wasParsed('host-vmservice-port') ?? false)) {
throwToolExit(
'Only one of "--vm-service-port" and '

View File

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

View File

@ -8,7 +8,6 @@ import 'dart:io' as io; // flutter_ignore: dart_io_import;
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:vm_service/vm_service.dart' as vm_service;
import '../base/dds.dart';
import '../base/file_system.dart';
@ -189,20 +188,12 @@ class FlutterTesterTestDevice extends TestDevice {
}
logger.printTrace('Connecting to service protocol: $forwardingUri');
final FlutterVmService vmService = await connectToVmServiceImpl(
await connectToVmServiceImpl(
forwardingUri!,
compileExpression: compileExpression,
logger: logger,
);
logger.printTrace('test $id: Successfully connected to service protocol: $forwardingUri');
if (debuggingOptions.serveObservatory) {
try {
await vmService.callMethodWrapper('_serveObservatory');
} on vm_service.RPCError {
logger.printWarning('Unable to enable Observatory');
}
}
if (debuggingOptions.startPaused && !machine!) {
logger.printStatus('The Dart VM service is listening on $forwardingUri');
await _startDevTools(forwardingUri, _ddsLauncher);

View File

@ -999,6 +999,7 @@ class _BrowserEnvironment implements Environment {
@override
final bool supportsDebugging = true;
// TODO(bkonyi): update package:test_core to no longer reference Observatory.
@override
final Uri? observatoryUrl;

View File

@ -361,9 +361,7 @@ class TestFlutterTesterDevice extends FlutterTesterTestDevice {
CompileExpression? compileExpression,
required Logger logger,
}) async {
return FakeVmServiceHost(
requests: <VmServiceExpectation>[const FakeVmServiceRequest(method: '_serveObservatory')],
).vmService;
return FakeVmServiceHost(requests: <VmServiceExpectation>[]).vmService;
}
@override

View File

@ -35,8 +35,7 @@ void main() {
expect(
output.toString(),
'\n'
'[{"event":"test.startedProcess","params":{"vmServiceUri":"http://localhost:1234",'
'"observatoryUri":"http://localhost:1234"}}]'
'[{"event":"test.startedProcess","params":{"vmServiceUri":"http://localhost:1234"}}]'
'\n',
);
});
@ -47,8 +46,7 @@ void main() {
expect(
output.toString(),
'\n'
'[{"event":"test.startedProcess","params":{"vmServiceUri":null,'
'"observatoryUri":null}}]'
'[{"event":"test.startedProcess","params":{"vmServiceUri":null}}]'
'\n',
);
});

View File

@ -5,8 +5,6 @@
@Tags(<String>['flutter-test-driver'])
library;
import 'dart:convert';
import 'package:file/file.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:vm_service/vm_service.dart';
@ -153,51 +151,4 @@ void main() {
expect(vmServiceUri.port, equals(ddsPort));
});
});
group('--serve-observatory', () {
late FlutterRunTestDriver flutterRun, flutterAttach;
setUp(() async {
flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN ');
flutterAttach = FlutterRunTestDriver(
tempDir,
logPrefix: 'ATTACH ',
// Only one DDS instance can be connected to the VM service at a time.
// DDS can also only initialize if the VM service doesn't have any existing
// clients, so we'll just let _flutterRun be responsible for spawning DDS.
spawnDdsInstance: false,
);
});
tearDown(() async {
await flutterAttach.detach();
await flutterRun.stop();
});
Future<bool> isObservatoryAvailable() async {
final HttpClient client = HttpClient();
final Uri vmServiceUri = Uri(
scheme: 'http',
host: flutterRun.vmServiceWsUri!.host,
port: flutterRun.vmServicePort,
);
final HttpClientRequest request = await client.getUrl(vmServiceUri);
final HttpClientResponse response = await request.close();
final String content = await response.transform(utf8.decoder).join();
return content.contains('Dart VM Observatory');
}
testWithoutContext('enables Observatory on run', () async {
await flutterRun.run(withDebugger: true, serveObservatory: true);
expect(await isObservatoryAvailable(), true);
});
testWithoutContext('enables Observatory on attach', () async {
await flutterRun.run(withDebugger: true);
expect(await isObservatoryAvailable(), false);
await flutterAttach.attach(flutterRun.vmServicePort!, serveObservatory: true);
expect(await isObservatoryAvailable(), true);
});
});
}

View File

@ -534,7 +534,6 @@ final class FlutterRunTestDriver extends FlutterTestDriver {
String device = FlutterTesterDevices.kTesterDeviceId,
bool expressionEvaluation = true,
bool structuredErrors = false,
bool serveObservatory = false,
bool noDevtools = false,
bool verbose = false,
String? script,
@ -559,7 +558,6 @@ final class FlutterRunTestDriver extends FlutterTestDriver {
'--machine',
if (!spawnDdsInstance) '--no-dds',
if (noDevtools) '--no-devtools',
'--${serveObservatory ? '' : 'no-'}serve-observatory',
...getLocalEngineArguments(),
'-d',
...deviceArgs,
@ -579,7 +577,6 @@ final class FlutterRunTestDriver extends FlutterTestDriver {
bool withDebugger = false,
bool startPaused = false,
bool pauseOnExceptions = false,
bool serveObservatory = false,
List<String>? additionalCommandArgs,
}) async {
_attachPort = port;
@ -589,7 +586,6 @@ final class FlutterRunTestDriver extends FlutterTestDriver {
...getLocalEngineArguments(),
'--machine',
if (!spawnDdsInstance) '--no-dds',
'--${serveObservatory ? '' : 'no-'}serve-observatory',
'-d',
'flutter-tester',
'--debug-port',

View File

@ -471,35 +471,6 @@ void main() {
);
});
testWithoutContext('flutter test should respect --serve-observatory', () async {
Process? process;
StreamSubscription<String>? sub;
try {
process = await _runFlutterTestConcurrent(
'trivial',
automatedTestsDirectory,
flutterTestDirectory,
extraArguments: const <String>['--start-paused', '--serve-observatory'],
);
final Completer<Uri> completer = Completer<Uri>();
final RegExp vmServiceUriRegExp = RegExp(r'((http)?:\/\/)[^\s]+');
sub = process.stdout.transform(utf8.decoder).listen((String e) {
if (!completer.isCompleted && vmServiceUriRegExp.hasMatch(e)) {
completer.complete(Uri.parse(vmServiceUriRegExp.firstMatch(e)!.group(0)!));
}
});
final Uri vmServiceUri = await completer.future;
final HttpClient client = HttpClient();
final HttpClientRequest request = await client.getUrl(vmServiceUri);
final HttpClientResponse response = await request.close();
final String content = await response.transform(utf8.decoder).join();
expect(content, contains('Dart VM Observatory'));
} finally {
await sub?.cancel();
process?.kill();
}
});
testWithoutContext('flutter test should serve DevTools', () async {
Process? process;
StreamSubscription<String>? sub;

View File

@ -557,7 +557,7 @@ class FuchsiaRemoteConnection {
final List<int> ports = getVmServicePortFromInspectSnapshot(inspectOutputJson);
if (ports.length > 1) {
throw StateError('More than one Flutter observatory port found');
throw StateError('More than one Dart VM service port found');
}
return ports;
}