Skip to content

Commit 254a796

Browse files
authored
Revert "Reland "Add --serve-observatory flag to run, attach, and test (#118402)" (#119529)" (#119729)
This reverts commit 7477d7a.
1 parent d278808 commit 254a796

16 files changed

+20
-312
lines changed

packages/flutter_tools/lib/src/base/dds.dart

-4
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,4 @@ class DartDevelopmentService {
108108
}
109109

110110
Future<void> shutdown() async => _ddsInstance?.shutdown();
111-
112-
void setExternalDevToolsUri(Uri uri) {
113-
_ddsInstance?.setExternalDevToolsUri(uri);
114-
}
115111
}

packages/flutter_tools/lib/src/commands/attach.dart

-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class AttachCommand extends FlutterCommand {
139139
usesTrackWidgetCreation(verboseHelp: verboseHelp);
140140
addDdsOptions(verboseHelp: verboseHelp);
141141
addDevToolsOptions(verboseHelp: verboseHelp);
142-
addServeObservatoryOptions(verboseHelp: verboseHelp);
143142
usesDeviceTimeoutOption();
144143
}
145144

@@ -201,8 +200,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
201200
return uri;
202201
}
203202

204-
bool get serveObservatory => boolArg('serve-observatory') ?? false;
205-
206203
String? get appId {
207204
return stringArgDeprecated('app-id');
208205
}
@@ -517,7 +514,6 @@ known, it can be explicitly provided to attach via the command-line, e.g.
517514
enableDds: enableDds,
518515
ddsPort: ddsPort,
519516
devToolsServerAddress: devToolsServerAddress,
520-
serveObservatory: serveObservatory,
521517
);
522518

523519
return buildInfo.isDebug

packages/flutter_tools/lib/src/commands/run.dart

-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
179179
usesDeviceTimeoutOption();
180180
addDdsOptions(verboseHelp: verboseHelp);
181181
addDevToolsOptions(verboseHelp: verboseHelp);
182-
addServeObservatoryOptions(verboseHelp: verboseHelp);
183182
addAndroidSpecificBuildOptions(hide: !verboseHelp);
184183
usesFatalWarningsOption(verboseHelp: verboseHelp);
185184
addEnableImpellerFlag(verboseHelp: verboseHelp);
@@ -280,7 +279,6 @@ abstract class RunCommandBase extends FlutterCommand with DeviceBasedDevelopment
280279
nativeNullAssertions: boolArgDeprecated('native-null-assertions'),
281280
enableImpeller: enableImpeller,
282281
uninstallFirst: uninstallFirst,
283-
serveObservatory: boolArgDeprecated('serve-observatory'),
284282
enableDartProfiling: enableDartProfiling,
285283
);
286284
}

packages/flutter_tools/lib/src/commands/test.dart

-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
215215
'or as the string "none" to disable the timeout entirely.',
216216
);
217217
addDdsOptions(verboseHelp: verboseHelp);
218-
addServeObservatoryOptions(verboseHelp: verboseHelp);
219218
usesFatalWarningsOption(verboseHelp: verboseHelp);
220219
}
221220

@@ -405,7 +404,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
405404
buildInfo,
406405
startPaused: startPaused,
407406
disableServiceAuthCodes: boolArgDeprecated('disable-service-auth-codes'),
408-
serveObservatory: boolArgDeprecated('serve-observatory'),
409407
// On iOS >=14, keeping this enabled will leave a prompt on the screen.
410408
disablePortPublication: true,
411409
enableDds: enableDds,

packages/flutter_tools/lib/src/device.dart

+1-7
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ class DebuggingOptions {
754754
this.nativeNullAssertions = false,
755755
this.enableImpeller = false,
756756
this.uninstallFirst = false,
757-
this.serveObservatory = true,
758757
this.enableDartProfiling = true,
759758
}) : debuggingEnabled = true;
760759

@@ -800,8 +799,7 @@ class DebuggingOptions {
800799
fastStart = false,
801800
webEnableExpressionEvaluation = false,
802801
nullAssertions = false,
803-
nativeNullAssertions = false,
804-
serveObservatory = false;
802+
nativeNullAssertions = false;
805803

806804
DebuggingOptions._({
807805
required this.buildInfo,
@@ -846,7 +844,6 @@ class DebuggingOptions {
846844
required this.nativeNullAssertions,
847845
required this.enableImpeller,
848846
required this.uninstallFirst,
849-
required this.serveObservatory,
850847
required this.enableDartProfiling,
851848
});
852849

@@ -883,7 +880,6 @@ class DebuggingOptions {
883880
final bool webUseSseForDebugBackend;
884881
final bool webUseSseForInjectedClient;
885882
final bool enableImpeller;
886-
final bool serveObservatory;
887883
final bool enableDartProfiling;
888884

889885
/// Whether the tool should try to uninstall a previously installed version of the app.
@@ -1012,7 +1008,6 @@ class DebuggingOptions {
10121008
'nullAssertions': nullAssertions,
10131009
'nativeNullAssertions': nativeNullAssertions,
10141010
'enableImpeller': enableImpeller,
1015-
'serveObservatory': serveObservatory,
10161011
'enableDartProfiling': enableDartProfiling,
10171012
};
10181013

@@ -1060,7 +1055,6 @@ class DebuggingOptions {
10601055
nativeNullAssertions: json['nativeNullAssertions']! as bool,
10611056
enableImpeller: (json['enableImpeller'] as bool?) ?? false,
10621057
uninstallFirst: (json['uninstallFirst'] as bool?) ?? false,
1063-
serveObservatory: (json['serveObservatory'] as bool?) ?? false,
10641058
enableDartProfiling: (json['enableDartProfiling'] as bool?) ?? true,
10651059
);
10661060
}

packages/flutter_tools/lib/src/resident_devtools_handler.dart

-14
Original file line numberDiff line numberDiff line change
@@ -91,26 +91,12 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
9191
final List<FlutterDevice?> devicesWithExtension = await _devicesWithExtensions(flutterDevices);
9292
await _maybeCallDevToolsUriServiceExtension(devicesWithExtension);
9393
await _callConnectedVmServiceUriExtension(devicesWithExtension);
94-
9594
if (_shutdown) {
9695
// If we're shutting down, no point reporting the debugger list.
9796
return;
9897
}
9998
_readyToAnnounce = true;
10099
assert(_devToolsLauncher!.activeDevToolsServer != null);
101-
102-
final Uri? devToolsUrl = _devToolsLauncher!.devToolsUrl;
103-
if (devToolsUrl != null) {
104-
for (final FlutterDevice? device in devicesWithExtension) {
105-
if (device == null) {
106-
continue;
107-
}
108-
// Notify the DDS instances that there's a DevTools instance available so they can correctly
109-
// redirect DevTools related requests.
110-
device.device?.dds.setExternalDevToolsUri(devToolsUrl);
111-
}
112-
}
113-
114100
if (_residentRunner.reportedDebuggers) {
115101
// Since the DevTools only just became available, we haven't had a chance to
116102
// report their URLs yet. Do so now.

packages/flutter_tools/lib/src/resident_runner.dart

-20
Original file line numberDiff line numberDiff line change
@@ -1402,26 +1402,6 @@ abstract class ResidentRunner extends ResidentHandlers {
14021402
_finished.complete(0);
14031403
}
14041404

1405-
Future<void> enableObservatory() async {
1406-
assert(debuggingOptions.serveObservatory);
1407-
final List<Future<vm_service.Response?>> serveObservatoryRequests = <Future<vm_service.Response?>>[];
1408-
for (final FlutterDevice? device in flutterDevices) {
1409-
if (device == null) {
1410-
continue;
1411-
}
1412-
// Notify the VM service if the user wants Observatory to be served.
1413-
serveObservatoryRequests.add(
1414-
device.vmService?.callMethodWrapper('_serveObservatory') ??
1415-
Future<vm_service.Response?>.value(),
1416-
);
1417-
}
1418-
try {
1419-
await Future.wait(serveObservatoryRequests);
1420-
} on vm_service.RPCError catch(e) {
1421-
globals.printWarning('Unable to enable Observatory: $e');
1422-
}
1423-
}
1424-
14251405
void appFinished() {
14261406
if (_finished.isCompleted) {
14271407
return;

packages/flutter_tools/lib/src/run_cold.dart

+12-22
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,12 @@ class ColdRunner extends ResidentRunner {
8080
}
8181
}
8282

83-
if (debuggingEnabled) {
84-
if (enableDevTools) {
85-
// The method below is guaranteed never to return a failing future.
86-
unawaited(residentDevtoolsHandler!.serveAndAnnounceDevTools(
87-
devToolsServerAddress: debuggingOptions.devToolsServerAddress,
88-
flutterDevices: flutterDevices,
89-
));
90-
}
91-
if (debuggingOptions.serveObservatory) {
92-
await enableObservatory();
93-
}
83+
if (enableDevTools && debuggingEnabled) {
84+
// The method below is guaranteed never to return a failing future.
85+
unawaited(residentDevtoolsHandler!.serveAndAnnounceDevTools(
86+
devToolsServerAddress: debuggingOptions.devToolsServerAddress,
87+
flutterDevices: flutterDevices,
88+
));
9489
}
9590

9691
if (flutterDevices.first.observatoryUris != null) {
@@ -167,17 +162,12 @@ class ColdRunner extends ResidentRunner {
167162
}
168163
}
169164

170-
if (debuggingEnabled) {
171-
if (enableDevTools) {
172-
// The method below is guaranteed never to return a failing future.
173-
unawaited(residentDevtoolsHandler!.serveAndAnnounceDevTools(
174-
devToolsServerAddress: debuggingOptions.devToolsServerAddress,
175-
flutterDevices: flutterDevices,
176-
));
177-
}
178-
if (debuggingOptions.serveObservatory) {
179-
await enableObservatory();
180-
}
165+
if (enableDevTools && debuggingEnabled) {
166+
// The method below is guaranteed never to return a failing future.
167+
unawaited(residentDevtoolsHandler!.serveAndAnnounceDevTools(
168+
devToolsServerAddress: debuggingOptions.devToolsServerAddress,
169+
flutterDevices: flutterDevices,
170+
));
181171
}
182172

183173
appStartedCompleter?.complete();

packages/flutter_tools/lib/src/run_hot.dart

-4
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ class HotRunner extends ResidentRunner {
237237
return 2;
238238
}
239239

240-
if (debuggingOptions.serveObservatory) {
241-
await enableObservatory();
242-
}
243-
244240
if (enableDevTools) {
245241
// The method below is guaranteed never to return a failing future.
246242
unawaited(residentDevtoolsHandler!.serveAndAnnounceDevTools(

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

-8
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,6 @@ abstract class FlutterCommand extends Command<void> {
458458
);
459459
}
460460

461-
void addServeObservatoryOptions({required bool verboseHelp}) {
462-
argParser.addFlag('serve-observatory',
463-
hide: !verboseHelp,
464-
defaultsTo: true,
465-
help: 'Serve the legacy Observatory developer tooling through the VM service.',
466-
);
467-
}
468-
469461
late final bool enableDds = () {
470462
bool ddsEnabled = false;
471463
if (argResults?.wasParsed('disable-dds') ?? false) {

packages/flutter_tools/lib/src/test/flutter_tester_device.dart

+1-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:dds/dds.dart';
1111
import 'package:meta/meta.dart';
1212
import 'package:process/process.dart';
1313
import 'package:stream_channel/stream_channel.dart';
14-
import 'package:vm_service/vm_service.dart' as vm_service;
1514

1615
import '../base/file_system.dart';
1716
import '../base/io.dart';
@@ -181,15 +180,8 @@ class FlutterTesterTestDevice extends TestDevice {
181180
compileExpression: compileExpression,
182181
logger: logger,
183182
);
184-
unawaited(localVmService.then((FlutterVmService vmservice) async {
183+
unawaited(localVmService.then((FlutterVmService vmservice) {
185184
logger.printTrace('test $id: Successfully connected to service protocol: $forwardingUri');
186-
if (debuggingOptions.serveObservatory) {
187-
try {
188-
await vmservice.callMethodWrapper('_serveObservatory');
189-
} on vm_service.RPCError {
190-
logger.printWarning('Unable to enable Observatory');
191-
}
192-
}
193185
}));
194186

195187
if (debuggingOptions.startPaused && !machine!) {
@@ -198,7 +190,6 @@ class FlutterTesterTestDevice extends TestDevice {
198190
logger.printStatus(' $forwardingUri');
199191
logger.printStatus('You should first set appropriate breakpoints, then resume the test in the debugger.');
200192
}
201-
202193
_gotProcessObservatoryUri.complete(forwardingUri);
203194
},
204195
);

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

+5-48
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:async';
66

7-
import 'package:flutter_tools/src/base/dds.dart';
87
import 'package:flutter_tools/src/base/logger.dart';
98
import 'package:flutter_tools/src/build_info.dart';
109
import 'package:flutter_tools/src/cache.dart';
@@ -111,9 +110,7 @@ void main() {
111110

112111
testWithoutContext('serveAndAnnounceDevTools with attached device does not fail on null vm service', () async {
113112
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
114-
FakeDevtoolsLauncher()
115-
..activeDevToolsServer = DevToolsServerAddress('localhost', 8080)
116-
..devToolsUrl = Uri.parse('http://localhost:8080'),
113+
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),
117114
FakeResidentRunner(),
118115
BufferLogger.test(),
119116
);
@@ -128,9 +125,7 @@ void main() {
128125

129126
testWithoutContext('serveAndAnnounceDevTools with invokes devtools and vm_service setter', () async {
130127
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
131-
FakeDevtoolsLauncher()
132-
..activeDevToolsServer = DevToolsServerAddress('localhost', 8080)
133-
..devToolsUrl = Uri.parse('http://localhost:8080'),
128+
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),
134129
FakeResidentRunner(),
135130
BufferLogger.test(),
136131
);
@@ -199,9 +194,7 @@ void main() {
199194

200195
testWithoutContext('serveAndAnnounceDevTools with web device', () async {
201196
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
202-
FakeDevtoolsLauncher()
203-
..activeDevToolsServer = DevToolsServerAddress('localhost', 8080)
204-
..devToolsUrl = Uri.parse('http://localhost:8080'),
197+
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),
205198
FakeResidentRunner(),
206199
BufferLogger.test(),
207200
);
@@ -285,9 +278,7 @@ void main() {
285278

286279
testWithoutContext('serveAndAnnounceDevTools with multiple devices and VM service disappears on one', () async {
287280
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
288-
FakeDevtoolsLauncher()
289-
..activeDevToolsServer = DevToolsServerAddress('localhost', 8080)
290-
..devToolsUrl = Uri.parse('http://localhost:8080'),
281+
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),
291282
FakeResidentRunner(),
292283
BufferLogger.test(),
293284
);
@@ -451,9 +442,6 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
451442

452443
@override
453444
bool reportedDebuggers = false;
454-
455-
@override
456-
DebuggingOptions debuggingOptions = DebuggingOptions.disabled(BuildInfo.debug);
457445
}
458446

459447
class FakeFlutterDevice extends Fake implements FlutterDevice {
@@ -470,35 +458,4 @@ class FakeFlutterDevice extends Fake implements FlutterDevice {
470458
// Unfortunately Device, despite not being immutable, has an `operator ==`.
471459
// Until we fix that, we have to also ignore related lints here.
472460
// ignore: avoid_implementing_value_types
473-
class FakeDevice extends Fake implements Device {
474-
@override
475-
DartDevelopmentService get dds => FakeDartDevelopmentService();
476-
}
477-
478-
class FakeDartDevelopmentService extends Fake implements DartDevelopmentService {
479-
bool started = false;
480-
bool disposed = false;
481-
482-
@override
483-
final Uri uri = Uri.parse('http://127.0.0.1:1234/');
484-
485-
@override
486-
Future<void> startDartDevelopmentService(
487-
Uri observatoryUri, {
488-
required Logger logger,
489-
int? hostPort,
490-
bool? ipv6,
491-
bool? disableServiceAuthCodes,
492-
bool cacheStartupProfile = false,
493-
}) async {
494-
started = true;
495-
}
496-
497-
@override
498-
Future<void> shutdown() async {
499-
disposed = true;
500-
}
501-
502-
@override
503-
void setExternalDevToolsUri(Uri uri) {}
504-
}
461+
class FakeDevice extends Fake implements Device { }

0 commit comments

Comments
 (0)