From 5a36bddd2b34077c2a7aef6c36271f8d30b16dda Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Thu, 23 Mar 2023 12:52:30 -0400 Subject: [PATCH] Stop serving Observatory by default (#122419) Observatory can still be enabled by providing `--serve-observatory` or invoking the `_serveObservatory` private service RPC via web socket or HTTP. Related to https://github.com/dart-lang/sdk/issues/50233 --- packages/flutter_tools/lib/src/device.dart | 2 +- .../lib/src/runner/flutter_command.dart | 1 - .../general.shard/resident_runner_test.dart | 33 ------------------- .../flutter_attach_test.dart | 12 +++---- .../test/integration.shard/test_driver.dart | 4 +-- 5 files changed, 8 insertions(+), 44 deletions(-) diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 3637f3c97f..071f056aec 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -937,7 +937,7 @@ class DebuggingOptions { this.nativeNullAssertions = false, this.enableImpeller = ImpellerStatus.platformDefault, this.uninstallFirst = false, - this.serveObservatory = true, + this.serveObservatory = false, this.enableDartProfiling = true, this.enableEmbedderApi = false, }) : debuggingEnabled = true; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 3be8a08b9d..46e3682394 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -474,7 +474,6 @@ abstract class FlutterCommand extends Command { void addServeObservatoryOptions({required bool verboseHelp}) { argParser.addFlag('serve-observatory', hide: !verboseHelp, - defaultsTo: true, help: 'Serve the legacy Observatory developer tooling through the VM service.', ); } diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index 09a783621e..464ce3a336 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart @@ -153,10 +153,6 @@ const FakeVmServiceRequest evictShader = FakeVmServiceRequest( } ); -const FakeVmServiceRequest serveObservatory = FakeVmServiceRequest( - method: '_serveObservatory', -); - final Uri testUri = Uri.parse('foo://bar'); void main() { @@ -196,7 +192,6 @@ void main() { testUsingContext('ResidentRunner can attach to device successfully', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); final Completer futureConnectionInfo = Completer.sync(); @@ -220,7 +215,6 @@ void main() { .createSync(recursive: true); fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); final FakeResidentCompiler residentCompiler = FakeResidentCompiler() @@ -312,7 +306,6 @@ void main() { .createSync(recursive: true); fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); final FakeResidentCompiler residentCompiler = FakeResidentCompiler() @@ -337,7 +330,6 @@ void main() { testUsingContext('ResidentRunner can attach to device successfully with --fast-start', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -406,7 +398,6 @@ void main() { testUsingContext('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, ]); @@ -440,7 +431,6 @@ void main() { testUsingContext('ResidentRunner fails its operation if the device initialization is not complete', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); final Completer futureConnectionInfo = Completer.sync(); @@ -462,7 +452,6 @@ void main() { testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, ]); @@ -498,7 +487,6 @@ void main() { testUsingContext('ResidentRunner reports hot reload event with null safety analytics', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, ]); @@ -546,7 +534,6 @@ void main() { testUsingContext('ResidentRunner does not reload sources if no sources changed', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -591,7 +578,6 @@ void main() { testUsingContext('ResidentRunner reports error with missing entrypoint file', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -652,7 +638,6 @@ void main() { testUsingContext('ResidentRunner resets compilation time on reload reject', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -717,7 +702,6 @@ void main() { testUsingContext('ResidentRunner can send target platform to analytics from hot reload', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -781,7 +765,6 @@ void main() { testUsingContext('ResidentRunner can perform fast reassemble', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, FakeVmServiceRequest( method: 'getVM', jsonResponse: fakeVM.toJson(), @@ -872,7 +855,6 @@ void main() { testUsingContext('ResidentRunner reports hot reload time details', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, FakeVmServiceRequest( method: 'getVM', jsonResponse: fakeVM.toJson(), @@ -962,7 +944,6 @@ void main() { testUsingContext('ResidentRunner can send target platform to analytics from full restart', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -1023,7 +1004,6 @@ void main() { testUsingContext('ResidentRunner can remove breakpoints and exception-pause-mode from paused isolate during hot restart', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -1097,7 +1077,6 @@ void main() { testUsingContext('ResidentRunner will alternative the name of the dill file uploaded for a hot restart', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, listViews, FakeVmServiceRequest( @@ -1220,7 +1199,6 @@ void main() { testUsingContext('ResidentRunner Can handle an RPC exception from hot restart', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); final Completer futureConnectionInfo = Completer.sync(); @@ -1653,7 +1631,6 @@ flutter: fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, listViews, - serveObservatory, ]); residentRunner = ColdRunner( [ @@ -1696,7 +1673,6 @@ flutter: testUsingContext('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1719,7 +1695,6 @@ flutter: testUsingContext('HotRunner copies compiled app.dill to cache during startup', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1748,7 +1723,6 @@ flutter: testUsingContext('HotRunner copies compiled app.dill to cache during startup with dart defines', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1779,7 +1753,6 @@ flutter: testUsingContext('HotRunner copies compiled app.dill to cache during startup with null safety', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1810,7 +1783,6 @@ flutter: testUsingContext('HotRunner copies compiled app.dill to cache during startup with track-widget-creation', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1834,7 +1806,6 @@ flutter: testUsingContext('HotRunner does not copy app.dill if a dillOutputPath is given', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1858,7 +1829,6 @@ flutter: testUsingContext('HotRunner copies compiled app.dill to cache during startup with --track-widget-creation', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1886,7 +1856,6 @@ flutter: testUsingContext('HotRunner calls device dispose', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1907,7 +1876,6 @@ flutter: testUsingContext('HotRunner handles failure to write vmservice file', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, listViews, ]); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); @@ -1932,7 +1900,6 @@ flutter: testUsingContext('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async { fakeVmServiceHost = FakeVmServiceHost(requests: [ listViews, - serveObservatory, ], wsAddress: testUri); globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); residentRunner = ColdRunner( diff --git a/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart b/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart index 48bf091dd3..f267d53798 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_attach_test.dart @@ -197,24 +197,22 @@ void main() { testWithoutContext('enables Observatory on run', () async { await flutterRun.run( withDebugger: true, - // TODO(bkonyi): uncomment once Observatory is disabled by default - // See https://github.com/dart-lang/sdk/issues/50233 - // serveObservatory: true, + serveObservatory: true, ); expect(await isObservatoryAvailable(), true); }); testWithoutContext('enables Observatory on attach', () async { - await flutterRun.run(withDebugger: true, serveObservatory: false); + await flutterRun.run(withDebugger: true); // Bail out if Observatory is still served by default in the VM. + // TODO(bkonyi): replace this with the following once Observatory is disabled in the VM: + // expect(await isObservatoryAvailable(), isFalse); if (await isObservatoryAvailable()) { return; } await flutterAttach.attach( flutterRun.vmServicePort!, - // TODO(bkonyi): uncomment once Observatory is disabled by default - // See https://github.com/dart-lang/sdk/issues/50233 - // serveObservatory: true, + serveObservatory: true, ); expect(await isObservatoryAvailable(), true); }); diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index c7894d8512..db034d4a29 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart @@ -505,7 +505,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { bool expressionEvaluation = true, bool structuredErrors = false, bool singleWidgetReloads = false, - bool serveObservatory = true, + bool serveObservatory = false, String? script, List? additionalCommandArgs, }) async { @@ -545,7 +545,7 @@ class FlutterRunTestDriver extends FlutterTestDriver { bool startPaused = false, bool pauseOnExceptions = false, bool singleWidgetReloads = false, - bool serveObservatory = true, + bool serveObservatory = false, List? additionalCommandArgs, }) async { _attachPort = port;