Skip to content

Commit 5a36bdd

Browse files
authored
Stop serving Observatory by default (flutter#122419)
Observatory can still be enabled by providing `--serve-observatory` or invoking the `_serveObservatory` private service RPC via web socket or HTTP. Related to dart-lang/sdk#50233
1 parent 897e3db commit 5a36bdd

File tree

5 files changed

+8
-44
lines changed

5 files changed

+8
-44
lines changed

packages/flutter_tools/lib/src/device.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class DebuggingOptions {
937937
this.nativeNullAssertions = false,
938938
this.enableImpeller = ImpellerStatus.platformDefault,
939939
this.uninstallFirst = false,
940-
this.serveObservatory = true,
940+
this.serveObservatory = false,
941941
this.enableDartProfiling = true,
942942
this.enableEmbedderApi = false,
943943
}) : debuggingEnabled = true;

packages/flutter_tools/lib/src/runner/flutter_command.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ abstract class FlutterCommand extends Command<void> {
474474
void addServeObservatoryOptions({required bool verboseHelp}) {
475475
argParser.addFlag('serve-observatory',
476476
hide: !verboseHelp,
477-
defaultsTo: true,
478477
help: 'Serve the legacy Observatory developer tooling through the VM service.',
479478
);
480479
}

packages/flutter_tools/test/general.shard/resident_runner_test.dart

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,6 @@ const FakeVmServiceRequest evictShader = FakeVmServiceRequest(
153153
}
154154
);
155155

156-
const FakeVmServiceRequest serveObservatory = FakeVmServiceRequest(
157-
method: '_serveObservatory',
158-
);
159-
160156
final Uri testUri = Uri.parse('foo://bar');
161157

162158
void main() {
@@ -196,7 +192,6 @@ void main() {
196192
testUsingContext('ResidentRunner can attach to device successfully', () => testbed.run(() async {
197193
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
198194
listViews,
199-
serveObservatory,
200195
listViews,
201196
]);
202197
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
@@ -220,7 +215,6 @@ void main() {
220215
.createSync(recursive: true);
221216
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
222217
listViews,
223-
serveObservatory,
224218
listViews,
225219
]);
226220
final FakeResidentCompiler residentCompiler = FakeResidentCompiler()
@@ -312,7 +306,6 @@ void main() {
312306
.createSync(recursive: true);
313307
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
314308
listViews,
315-
serveObservatory,
316309
listViews,
317310
]);
318311
final FakeResidentCompiler residentCompiler = FakeResidentCompiler()
@@ -337,7 +330,6 @@ void main() {
337330
testUsingContext('ResidentRunner can attach to device successfully with --fast-start', () => testbed.run(() async {
338331
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
339332
listViews,
340-
serveObservatory,
341333
listViews,
342334
listViews,
343335
FakeVmServiceRequest(
@@ -406,7 +398,6 @@ void main() {
406398
testUsingContext('ResidentRunner can handle an RPC exception from hot reload', () => testbed.run(() async {
407399
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
408400
listViews,
409-
serveObservatory,
410401
listViews,
411402
listViews,
412403
]);
@@ -440,7 +431,6 @@ void main() {
440431
testUsingContext('ResidentRunner fails its operation if the device initialization is not complete', () => testbed.run(() async {
441432
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
442433
listViews,
443-
serveObservatory,
444434
listViews,
445435
]);
446436
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
@@ -462,7 +452,6 @@ void main() {
462452
testUsingContext('ResidentRunner can handle an reload-barred exception from hot reload', () => testbed.run(() async {
463453
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
464454
listViews,
465-
serveObservatory,
466455
listViews,
467456
listViews,
468457
]);
@@ -498,7 +487,6 @@ void main() {
498487
testUsingContext('ResidentRunner reports hot reload event with null safety analytics', () => testbed.run(() async {
499488
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
500489
listViews,
501-
serveObservatory,
502490
listViews,
503491
listViews,
504492
]);
@@ -546,7 +534,6 @@ void main() {
546534
testUsingContext('ResidentRunner does not reload sources if no sources changed', () => testbed.run(() async {
547535
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
548536
listViews,
549-
serveObservatory,
550537
listViews,
551538
listViews,
552539
FakeVmServiceRequest(
@@ -591,7 +578,6 @@ void main() {
591578
testUsingContext('ResidentRunner reports error with missing entrypoint file', () => testbed.run(() async {
592579
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
593580
listViews,
594-
serveObservatory,
595581
listViews,
596582
listViews,
597583
FakeVmServiceRequest(
@@ -652,7 +638,6 @@ void main() {
652638
testUsingContext('ResidentRunner resets compilation time on reload reject', () => testbed.run(() async {
653639
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
654640
listViews,
655-
serveObservatory,
656641
listViews,
657642
listViews,
658643
FakeVmServiceRequest(
@@ -717,7 +702,6 @@ void main() {
717702
testUsingContext('ResidentRunner can send target platform to analytics from hot reload', () => testbed.run(() async {
718703
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
719704
listViews,
720-
serveObservatory,
721705
listViews,
722706
listViews,
723707
FakeVmServiceRequest(
@@ -781,7 +765,6 @@ void main() {
781765
testUsingContext('ResidentRunner can perform fast reassemble', () => testbed.run(() async {
782766
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
783767
listViews,
784-
serveObservatory,
785768
FakeVmServiceRequest(
786769
method: 'getVM',
787770
jsonResponse: fakeVM.toJson(),
@@ -872,7 +855,6 @@ void main() {
872855
testUsingContext('ResidentRunner reports hot reload time details', () => testbed.run(() async {
873856
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
874857
listViews,
875-
serveObservatory,
876858
FakeVmServiceRequest(
877859
method: 'getVM',
878860
jsonResponse: fakeVM.toJson(),
@@ -962,7 +944,6 @@ void main() {
962944
testUsingContext('ResidentRunner can send target platform to analytics from full restart', () => testbed.run(() async {
963945
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
964946
listViews,
965-
serveObservatory,
966947
listViews,
967948
listViews,
968949
FakeVmServiceRequest(
@@ -1023,7 +1004,6 @@ void main() {
10231004
testUsingContext('ResidentRunner can remove breakpoints and exception-pause-mode from paused isolate during hot restart', () => testbed.run(() async {
10241005
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
10251006
listViews,
1026-
serveObservatory,
10271007
listViews,
10281008
listViews,
10291009
FakeVmServiceRequest(
@@ -1097,7 +1077,6 @@ void main() {
10971077
testUsingContext('ResidentRunner will alternative the name of the dill file uploaded for a hot restart', () => testbed.run(() async {
10981078
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
10991079
listViews,
1100-
serveObservatory,
11011080
listViews,
11021081
listViews,
11031082
FakeVmServiceRequest(
@@ -1220,7 +1199,6 @@ void main() {
12201199
testUsingContext('ResidentRunner Can handle an RPC exception from hot restart', () => testbed.run(() async {
12211200
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
12221201
listViews,
1223-
serveObservatory,
12241202
listViews,
12251203
]);
12261204
final Completer<DebugConnectionInfo> futureConnectionInfo = Completer<DebugConnectionInfo>.sync();
@@ -1653,7 +1631,6 @@ flutter:
16531631
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
16541632
listViews,
16551633
listViews,
1656-
serveObservatory,
16571634
]);
16581635
residentRunner = ColdRunner(
16591636
<FlutterDevice>[
@@ -1696,7 +1673,6 @@ flutter:
16961673
testUsingContext('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async {
16971674
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
16981675
listViews,
1699-
serveObservatory,
17001676
listViews,
17011677
], wsAddress: testUri);
17021678
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1719,7 +1695,6 @@ flutter:
17191695
testUsingContext('HotRunner copies compiled app.dill to cache during startup', () => testbed.run(() async {
17201696
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
17211697
listViews,
1722-
serveObservatory,
17231698
listViews,
17241699
], wsAddress: testUri);
17251700
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1748,7 +1723,6 @@ flutter:
17481723
testUsingContext('HotRunner copies compiled app.dill to cache during startup with dart defines', () => testbed.run(() async {
17491724
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
17501725
listViews,
1751-
serveObservatory,
17521726
listViews,
17531727
], wsAddress: testUri);
17541728
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1779,7 +1753,6 @@ flutter:
17791753
testUsingContext('HotRunner copies compiled app.dill to cache during startup with null safety', () => testbed.run(() async {
17801754
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
17811755
listViews,
1782-
serveObservatory,
17831756
listViews,
17841757
], wsAddress: testUri);
17851758
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1810,7 +1783,6 @@ flutter:
18101783
testUsingContext('HotRunner copies compiled app.dill to cache during startup with track-widget-creation', () => testbed.run(() async {
18111784
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
18121785
listViews,
1813-
serveObservatory,
18141786
listViews,
18151787
], wsAddress: testUri);
18161788
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1834,7 +1806,6 @@ flutter:
18341806
testUsingContext('HotRunner does not copy app.dill if a dillOutputPath is given', () => testbed.run(() async {
18351807
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
18361808
listViews,
1837-
serveObservatory,
18381809
listViews,
18391810
], wsAddress: testUri);
18401811
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1858,7 +1829,6 @@ flutter:
18581829
testUsingContext('HotRunner copies compiled app.dill to cache during startup with --track-widget-creation', () => testbed.run(() async {
18591830
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
18601831
listViews,
1861-
serveObservatory,
18621832
listViews,
18631833
], wsAddress: testUri);
18641834
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1886,7 +1856,6 @@ flutter:
18861856
testUsingContext('HotRunner calls device dispose', () => testbed.run(() async {
18871857
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
18881858
listViews,
1889-
serveObservatory,
18901859
listViews,
18911860
], wsAddress: testUri);
18921861
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1907,7 +1876,6 @@ flutter:
19071876
testUsingContext('HotRunner handles failure to write vmservice file', () => testbed.run(() async {
19081877
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
19091878
listViews,
1910-
serveObservatory,
19111879
listViews,
19121880
]);
19131881
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
@@ -1932,7 +1900,6 @@ flutter:
19321900
testUsingContext('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async {
19331901
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
19341902
listViews,
1935-
serveObservatory,
19361903
], wsAddress: testUri);
19371904
globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true);
19381905
residentRunner = ColdRunner(

packages/flutter_tools/test/integration.shard/flutter_attach_test.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,24 +197,22 @@ void main() {
197197
testWithoutContext('enables Observatory on run', () async {
198198
await flutterRun.run(
199199
withDebugger: true,
200-
// TODO(bkonyi): uncomment once Observatory is disabled by default
201-
// See https://github.com/dart-lang/sdk/issues/50233
202-
// serveObservatory: true,
200+
serveObservatory: true,
203201
);
204202
expect(await isObservatoryAvailable(), true);
205203
});
206204

207205
testWithoutContext('enables Observatory on attach', () async {
208-
await flutterRun.run(withDebugger: true, serveObservatory: false);
206+
await flutterRun.run(withDebugger: true);
209207
// Bail out if Observatory is still served by default in the VM.
208+
// TODO(bkonyi): replace this with the following once Observatory is disabled in the VM:
209+
// expect(await isObservatoryAvailable(), isFalse);
210210
if (await isObservatoryAvailable()) {
211211
return;
212212
}
213213
await flutterAttach.attach(
214214
flutterRun.vmServicePort!,
215-
// TODO(bkonyi): uncomment once Observatory is disabled by default
216-
// See https://github.com/dart-lang/sdk/issues/50233
217-
// serveObservatory: true,
215+
serveObservatory: true,
218216
);
219217
expect(await isObservatoryAvailable(), true);
220218
});

packages/flutter_tools/test/integration.shard/test_driver.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
505505
bool expressionEvaluation = true,
506506
bool structuredErrors = false,
507507
bool singleWidgetReloads = false,
508-
bool serveObservatory = true,
508+
bool serveObservatory = false,
509509
String? script,
510510
List<String>? additionalCommandArgs,
511511
}) async {
@@ -545,7 +545,7 @@ class FlutterRunTestDriver extends FlutterTestDriver {
545545
bool startPaused = false,
546546
bool pauseOnExceptions = false,
547547
bool singleWidgetReloads = false,
548-
bool serveObservatory = true,
548+
bool serveObservatory = false,
549549
List<String>? additionalCommandArgs,
550550
}) async {
551551
_attachPort = port;

0 commit comments

Comments
 (0)