Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 396c7fd

Browse files
authored
Reland "Remove references to Observatory (#38919)" (#39139)
This reverts commit 5dd9454.
1 parent a7bb0e4 commit 396c7fd

36 files changed

+302
-184
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChann
25062506
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm + ../../../flutter/LICENSE
25072507
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm + ../../../flutter/LICENSE
25082508
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h + ../../../flutter/LICENSE
2509+
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h + ../../../flutter/LICENSE
2510+
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm + ../../../flutter/LICENSE
25092511
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h + ../../../flutter/LICENSE
25102512
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm + ../../../flutter/LICENSE
25112513
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm + ../../../flutter/LICENSE
@@ -2526,8 +2528,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySe
25262528
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h + ../../../flutter/LICENSE
25272529
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm + ../../../flutter/LICENSE
25282530
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm + ../../../flutter/LICENSE
2529-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h + ../../../flutter/LICENSE
2530-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm + ../../../flutter/LICENSE
25312531
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h + ../../../flutter/LICENSE
25322532
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm + ../../../flutter/LICENSE
25332533
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h + ../../../flutter/LICENSE
@@ -4992,6 +4992,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChannel
49924992
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
49934993
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm
49944994
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h
4995+
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h
4996+
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm
49954997
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h
49964998
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm
49974999
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm
@@ -5012,8 +5014,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySeco
50125014
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h
50135015
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm
50145016
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm
5015-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h
5016-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm
50175017
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h
50185018
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm
50195019
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h

common/settings.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,23 +161,23 @@ struct Settings {
161161
// Platform.executable from dart:io. If unknown, defaults to "Flutter".
162162
std::string executable_name = "Flutter";
163163

164-
// Observatory settings
164+
// VM Service settings
165165

166166
// Whether the Dart VM service should be enabled.
167-
bool enable_observatory = false;
167+
bool enable_vm_service = false;
168168

169-
// Whether to publish the observatory URL over mDNS.
169+
// Whether to publish the VM Service URL over mDNS.
170170
// On iOS 14 this prompts a local network permission dialog,
171171
// which cannot be accepted or dismissed in a CI environment.
172-
bool enable_observatory_publication = true;
172+
bool enable_vm_service_publication = true;
173173

174174
// The IP address to which the Dart VM service is bound.
175-
std::string observatory_host;
175+
std::string vm_service_host;
176176

177177
// The port to which the Dart VM service is bound. When set to `0`, a free
178178
// port will be automatically selected by the OS. A message is logged on the
179179
// target indicating the URL at which the VM service can be accessed.
180-
uint32_t observatory_port = 0;
180+
uint32_t vm_service_port = 0;
181181

182182
// Determines whether an authentication code is required to communicate with
183183
// the VM service.

lib/web_ui/dev/browser.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ abstract class BrowserEnvironment {
5454
/// Any errors starting or running the browser process are reported through
5555
/// [onExit].
5656
abstract class Browser {
57-
/// The Observatory URL for this browser.
57+
/// The Dart VM Service URL for this browser.
5858
///
5959
/// Returns `null` for browsers that aren't running the Dart VM, or
60-
/// if the Observatory URL can't be found.
61-
Future<Uri>? get observatoryUrl => null;
60+
/// if the Dart VM Service URL can't be found.
61+
Future<Uri>? get vmServiceUrl => null;
6262

6363
/// The remote debugger URL for this browser.
6464
///

lib/web_ui/dev/test_platform.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ class BrowserManager {
820820

821821
/// Loads [_BrowserEnvironment].
822822
Future<_BrowserEnvironment> _loadBrowserEnvironment() async {
823-
return _BrowserEnvironment(this, await _browser.observatoryUrl,
823+
return _BrowserEnvironment(this, await _browser.vmServiceUrl,
824824
await _browser.remoteDebuggerUrl, _onRestartController.stream);
825825
}
826826

runtime/dart_isolate.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ void DartIsolate::SetMessageHandlingTaskRunner(
412412
}
413413

414414
// Updating thread names here does not change the underlying OS thread names.
415-
// Instead, this is just additional metadata for the Observatory to show the
415+
// Instead, this is just additional metadata for the Dart VM Service to show the
416416
// thread name of the isolate.
417417
bool DartIsolate::UpdateThreadPoolNames() const {
418418
// TODO(chinmaygarde): This implementation does not account for multiple
@@ -766,7 +766,7 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
766766

767767
const auto& settings = vm_data->GetSettings();
768768

769-
if (!settings.enable_observatory) {
769+
if (!settings.enable_vm_service) {
770770
return nullptr;
771771
}
772772

@@ -802,8 +802,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(
802802

803803
tonic::DartState::Scope scope(service_isolate);
804804
if (!DartServiceIsolate::Startup(
805-
settings.observatory_host, // server IP address
806-
settings.observatory_port, // server observatory port
805+
settings.vm_service_host, // server IP address
806+
settings.vm_service_port, // server VM service port
807807
tonic::DartState::HandleLibraryTag, // embedder library tag handler
808808
false, // disable websocket origin check
809809
settings.disable_service_auth_codes, // disable VM service auth codes

runtime/dart_isolate_unittests.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ TEST_F(DartIsolateTest, CanCreateServiceIsolate) {
404404
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
405405
fml::AutoResetWaitableEvent service_isolate_latch;
406406
auto settings = CreateSettingsForFixture();
407-
settings.enable_observatory = true;
408-
settings.observatory_port = 0;
409-
settings.observatory_host = "127.0.0.1";
407+
settings.enable_vm_service = true;
408+
settings.vm_service_port = 0;
409+
settings.vm_service_host = "127.0.0.1";
410410
settings.enable_service_port_fallback = true;
411411
settings.service_isolate_create_callback = [&service_isolate_latch]() {
412412
service_isolate_latch.Signal();

runtime/dart_lifecycle_unittests.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using DartLifecycleTest = FixtureTest;
1919
TEST_F(DartLifecycleTest, CanStartAndShutdownVM) {
2020
auto settings = CreateSettingsForFixture();
2121
settings.leak_vm = false;
22-
settings.enable_observatory = false;
22+
settings.enable_vm_service = false;
2323
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
2424
{
2525
auto vm_ref = DartVMRef::Create(settings);
@@ -31,7 +31,7 @@ TEST_F(DartLifecycleTest, CanStartAndShutdownVM) {
3131
TEST_F(DartLifecycleTest, CanStartAndShutdownVMOverAndOver) {
3232
auto settings = CreateSettingsForFixture();
3333
settings.leak_vm = false;
34-
settings.enable_observatory = false;
34+
settings.enable_vm_service = false;
3535
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
3636
auto count = DartVM::GetVMLaunchCount();
3737
for (size_t i = 0; i < 10; i++) {
@@ -89,7 +89,7 @@ TEST_F(DartLifecycleTest, DISABLED_ShuttingDownTheVMShutsDownAllIsolates) {
8989
auto settings = CreateSettingsForFixture();
9090
settings.leak_vm = false;
9191
// Make sure the service protocol launches
92-
settings.enable_observatory = true;
92+
settings.enable_vm_service = true;
9393

9494
auto thread_task_runner = CreateNewThread();
9595

runtime/dart_service_isolate.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace {
3333

3434
static Dart_LibraryTagHandler g_embedder_tag_handler;
3535
static tonic::DartLibraryNatives* g_natives;
36-
static std::string g_observatory_uri;
36+
static std::string g_vm_service_uri;
3737

3838
Dart_NativeFunction GetNativeFunction(Dart_Handle name,
3939
int argument_count,
@@ -51,7 +51,7 @@ const uint8_t* GetSymbol(Dart_NativeFunction native_function) {
5151

5252
std::mutex DartServiceIsolate::callbacks_mutex_;
5353

54-
std::set<std::unique_ptr<DartServiceIsolate::ObservatoryServerStateCallback>>
54+
std::set<std::unique_ptr<DartServiceIsolate::DartVMServiceServerStateCallback>>
5555
DartServiceIsolate::callbacks_;
5656

5757
void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) {
@@ -63,11 +63,11 @@ void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) {
6363
return;
6464
}
6565

66-
g_observatory_uri = uri;
66+
g_vm_service_uri = uri;
6767

6868
// Collect callbacks to fire in a separate collection and invoke them outside
6969
// the lock.
70-
std::vector<DartServiceIsolate::ObservatoryServerStateCallback>
70+
std::vector<DartServiceIsolate::DartVMServiceServerStateCallback>
7171
callbacks_to_fire;
7272
{
7373
std::scoped_lock lock(callbacks_mutex_);
@@ -82,13 +82,13 @@ void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) {
8282
}
8383

8484
DartServiceIsolate::CallbackHandle DartServiceIsolate::AddServerStatusCallback(
85-
const DartServiceIsolate::ObservatoryServerStateCallback& callback) {
85+
const DartServiceIsolate::DartVMServiceServerStateCallback& callback) {
8686
if (!callback) {
8787
return 0;
8888
}
8989

9090
auto callback_pointer =
91-
std::make_unique<DartServiceIsolate::ObservatoryServerStateCallback>(
91+
std::make_unique<DartServiceIsolate::DartVMServiceServerStateCallback>(
9292
callback);
9393

9494
auto handle = reinterpret_cast<CallbackHandle>(callback_pointer.get());
@@ -98,8 +98,8 @@ DartServiceIsolate::CallbackHandle DartServiceIsolate::AddServerStatusCallback(
9898
callbacks_.insert(std::move(callback_pointer));
9999
}
100100

101-
if (!g_observatory_uri.empty()) {
102-
callback(g_observatory_uri);
101+
if (!g_vm_service_uri.empty()) {
102+
callback(g_vm_service_uri);
103103
}
104104

105105
return handle;

runtime/dart_service_isolate.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class DartServiceIsolate {
2727
using CallbackHandle = ptrdiff_t;
2828

2929
//----------------------------------------------------------------------------
30-
/// A callback made by the Dart VM when the observatory is ready. The argument
31-
/// indicates the observatory URI.
30+
/// A callback made by the Dart VM when the VM Service is ready. The argument
31+
/// indicates the VM Service URI.
3232
///
33-
using ObservatoryServerStateCallback =
34-
std::function<void(const std::string& observatory_uri)>;
33+
using DartVMServiceServerStateCallback =
34+
std::function<void(const std::string& vm_service_uri)>;
3535

3636
//----------------------------------------------------------------------------
3737
/// @brief Start the service isolate. This call may only be made in the
@@ -68,19 +68,19 @@ class DartServiceIsolate {
6868
char** error);
6969

7070
//----------------------------------------------------------------------------
71-
/// @brief Add a callback that will get invoked when the observatory
72-
/// starts up. If the observatory has already started before this
71+
/// @brief Add a callback that will get invoked when the VM Service
72+
/// starts up. If the VM Service has already started before this
7373
/// call is made, the callback is invoked immediately.
7474
///
7575
/// This method is thread safe.
7676
///
77-
/// @param[in] callback The callback with information about the observatory.
77+
/// @param[in] callback The callback with information about the VM Service.
7878
///
7979
/// @return A handle for the callback that can be used later in
8080
/// `RemoveServerStatusCallback`.
8181
///
8282
[[nodiscard]] static CallbackHandle AddServerStatusCallback(
83-
const ObservatoryServerStateCallback& callback);
83+
const DartVMServiceServerStateCallback& callback);
8484

8585
//----------------------------------------------------------------------------
8686
/// @brief Removed a callback previously registered via
@@ -101,7 +101,7 @@ class DartServiceIsolate {
101101
static void Shutdown(Dart_NativeArguments args);
102102

103103
static std::mutex callbacks_mutex_;
104-
static std::set<std::unique_ptr<ObservatoryServerStateCallback>> callbacks_;
104+
static std::set<std::unique_ptr<DartVMServiceServerStateCallback>> callbacks_;
105105
};
106106

107107
} // namespace flutter

shell/common/switches.cc

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,33 +235,55 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
235235
settings.executable_name = command_line.argv0();
236236
}
237237

238-
// Enable Observatory
239-
settings.enable_observatory =
238+
// Enable the VM Service
239+
settings.enable_vm_service =
240+
!command_line.HasOption(FlagForSwitch(Switch::DisableVMService)) &&
241+
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
242+
// See https://github.com/dart-lang/sdk/issues/50233
240243
!command_line.HasOption(FlagForSwitch(Switch::DisableObservatory));
241244

242-
// Enable mDNS Observatory Publication
243-
settings.enable_observatory_publication = !command_line.HasOption(
244-
FlagForSwitch(Switch::DisableObservatoryPublication));
245-
246-
// Set Observatory Host
247-
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryHost))) {
245+
// Enable mDNS VM Service Publication
246+
settings.enable_vm_service_publication =
247+
!command_line.HasOption(
248+
FlagForSwitch(Switch::DisableVMServicePublication)) &&
249+
!command_line.HasOption(
250+
FlagForSwitch(Switch::DisableObservatoryPublication));
251+
252+
// Set VM Service Host
253+
if (command_line.HasOption(FlagForSwitch(Switch::DeviceVMServiceHost))) {
254+
command_line.GetOptionValue(FlagForSwitch(Switch::DeviceVMServiceHost),
255+
&settings.vm_service_host);
256+
} else if (command_line.HasOption(
257+
FlagForSwitch(Switch::DeviceObservatoryHost))) {
258+
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
259+
// See https://github.com/dart-lang/sdk/issues/50233
248260
command_line.GetOptionValue(FlagForSwitch(Switch::DeviceObservatoryHost),
249-
&settings.observatory_host);
261+
&settings.vm_service_host);
250262
}
251-
// Default the observatory port based on --ipv6 if not set.
252-
if (settings.observatory_host.empty()) {
253-
settings.observatory_host =
263+
// Default the VM Service port based on --ipv6 if not set.
264+
if (settings.vm_service_host.empty()) {
265+
settings.vm_service_host =
254266
command_line.HasOption(FlagForSwitch(Switch::IPv6)) ? "::1"
255267
: "127.0.0.1";
256268
}
257269

258-
// Set Observatory Port
259-
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) {
270+
// Set VM Service Port
271+
if (command_line.HasOption(FlagForSwitch(Switch::DeviceVMServicePort))) {
272+
if (!GetSwitchValue(command_line, Switch::DeviceVMServicePort,
273+
&settings.vm_service_port)) {
274+
FML_LOG(INFO)
275+
<< "VM Service port specified was malformed. Will default to "
276+
<< settings.vm_service_port;
277+
}
278+
} else if (command_line.HasOption(
279+
FlagForSwitch(Switch::DeviceObservatoryPort))) {
280+
// TODO(bkonyi): remove once flutter_tools no longer uses this option.
281+
// See https://github.com/dart-lang/sdk/issues/50233
260282
if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,
261-
&settings.observatory_port)) {
283+
&settings.vm_service_port)) {
262284
FML_LOG(INFO)
263-
<< "Observatory port specified was malformed. Will default to "
264-
<< settings.observatory_port;
285+
<< "VM Service port specified was malformed. Will default to "
286+
<< settings.vm_service_port;
265287
}
266288
}
267289

0 commit comments

Comments
 (0)