Skip to content

Commit

Permalink
Remove references to Observatory (flutter#38919)
Browse files Browse the repository at this point in the history
Observatory is being deprecated for Dart 3.0 so it should no longer be referenced in tooling messaging / flags.

See dart-lang/sdk#50233
  • Loading branch information
bkonyi authored and ricardoamador committed Jan 25, 2023
1 parent e8fdbfc commit 9234df1
Show file tree
Hide file tree
Showing 36 changed files with 267 additions and 172 deletions.
8 changes: 4 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChann
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm + ../../../flutter/LICENSE
Expand All @@ -2526,8 +2528,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySe
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h + ../../../flutter/LICENSE
Expand Down Expand Up @@ -4996,6 +4996,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChannel
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProjectTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponder.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEmbedderKeyResponderTest.mm
Expand All @@ -5016,8 +5018,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeySeco
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManagerTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h
Expand Down
12 changes: 6 additions & 6 deletions common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,23 @@ struct Settings {
// Platform.executable from dart:io. If unknown, defaults to "Flutter".
std::string executable_name = "Flutter";

// Observatory settings
// VM Service settings

// Whether the Dart VM service should be enabled.
bool enable_observatory = false;
bool enable_vm_service = false;

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

// The IP address to which the Dart VM service is bound.
std::string observatory_host;
std::string vm_service_host;

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

// Determines whether an authentication code is required to communicate with
// the VM service.
Expand Down
6 changes: 3 additions & 3 deletions lib/web_ui/dev/browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ abstract class BrowserEnvironment {
/// Any errors starting or running the browser process are reported through
/// [onExit].
abstract class Browser {
/// The Observatory URL for this browser.
/// The Dart VM Service URL for this browser.
///
/// Returns `null` for browsers that aren't running the Dart VM, or
/// if the Observatory URL can't be found.
Future<Uri>? get observatoryUrl => null;
/// if the Dart VM Service URL can't be found.
Future<Uri>? get vmServiceUrl => null;

/// The remote debugger URL for this browser.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/dev/test_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ class BrowserManager {

/// Loads [_BrowserEnvironment].
Future<_BrowserEnvironment> _loadBrowserEnvironment() async {
return _BrowserEnvironment(this, await _browser.observatoryUrl,
return _BrowserEnvironment(this, await _browser.vmServiceUrl,
await _browser.remoteDebuggerUrl, _onRestartController.stream);
}

Expand Down
8 changes: 4 additions & 4 deletions runtime/dart_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void DartIsolate::SetMessageHandlingTaskRunner(
}

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

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

if (!settings.enable_observatory) {
if (!settings.enable_vm_service) {
return nullptr;
}

Expand Down Expand Up @@ -802,8 +802,8 @@ Dart_Isolate DartIsolate::DartCreateAndStartServiceIsolate(

tonic::DartState::Scope scope(service_isolate);
if (!DartServiceIsolate::Startup(
settings.observatory_host, // server IP address
settings.observatory_port, // server observatory port
settings.vm_service_host, // server IP address
settings.vm_service_port, // server VM service port
tonic::DartState::HandleLibraryTag, // embedder library tag handler
false, // disable websocket origin check
settings.disable_service_auth_codes, // disable VM service auth codes
Expand Down
6 changes: 3 additions & 3 deletions runtime/dart_isolate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ TEST_F(DartIsolateTest, CanCreateServiceIsolate) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
fml::AutoResetWaitableEvent service_isolate_latch;
auto settings = CreateSettingsForFixture();
settings.enable_observatory = true;
settings.observatory_port = 0;
settings.observatory_host = "127.0.0.1";
settings.enable_vm_service = true;
settings.vm_service_port = 0;
settings.vm_service_host = "127.0.0.1";
settings.enable_service_port_fallback = true;
settings.service_isolate_create_callback = [&service_isolate_latch]() {
service_isolate_latch.Signal();
Expand Down
6 changes: 3 additions & 3 deletions runtime/dart_lifecycle_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using DartLifecycleTest = FixtureTest;
TEST_F(DartLifecycleTest, CanStartAndShutdownVM) {
auto settings = CreateSettingsForFixture();
settings.leak_vm = false;
settings.enable_observatory = false;
settings.enable_vm_service = false;
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
{
auto vm_ref = DartVMRef::Create(settings);
Expand All @@ -31,7 +31,7 @@ TEST_F(DartLifecycleTest, CanStartAndShutdownVM) {
TEST_F(DartLifecycleTest, CanStartAndShutdownVMOverAndOver) {
auto settings = CreateSettingsForFixture();
settings.leak_vm = false;
settings.enable_observatory = false;
settings.enable_vm_service = false;
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto count = DartVM::GetVMLaunchCount();
for (size_t i = 0; i < 10; i++) {
Expand Down Expand Up @@ -89,7 +89,7 @@ TEST_F(DartLifecycleTest, DISABLED_ShuttingDownTheVMShutsDownAllIsolates) {
auto settings = CreateSettingsForFixture();
settings.leak_vm = false;
// Make sure the service protocol launches
settings.enable_observatory = true;
settings.enable_vm_service = true;

auto thread_task_runner = CreateNewThread();

Expand Down
16 changes: 8 additions & 8 deletions runtime/dart_service_isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace {

static Dart_LibraryTagHandler g_embedder_tag_handler;
static tonic::DartLibraryNatives* g_natives;
static std::string g_observatory_uri;
static std::string g_vm_service_uri;

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

std::mutex DartServiceIsolate::callbacks_mutex_;

std::set<std::unique_ptr<DartServiceIsolate::ObservatoryServerStateCallback>>
std::set<std::unique_ptr<DartServiceIsolate::DartVMServiceServerStateCallback>>
DartServiceIsolate::callbacks_;

void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) {
Expand All @@ -63,11 +63,11 @@ void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) {
return;
}

g_observatory_uri = uri;
g_vm_service_uri = uri;

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

DartServiceIsolate::CallbackHandle DartServiceIsolate::AddServerStatusCallback(
const DartServiceIsolate::ObservatoryServerStateCallback& callback) {
const DartServiceIsolate::DartVMServiceServerStateCallback& callback) {
if (!callback) {
return 0;
}

auto callback_pointer =
std::make_unique<DartServiceIsolate::ObservatoryServerStateCallback>(
std::make_unique<DartServiceIsolate::DartVMServiceServerStateCallback>(
callback);

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

if (!g_observatory_uri.empty()) {
callback(g_observatory_uri);
if (!g_vm_service_uri.empty()) {
callback(g_vm_service_uri);
}

return handle;
Expand Down
18 changes: 9 additions & 9 deletions runtime/dart_service_isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class DartServiceIsolate {
using CallbackHandle = ptrdiff_t;

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

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

//----------------------------------------------------------------------------
/// @brief Add a callback that will get invoked when the observatory
/// starts up. If the observatory has already started before this
/// @brief Add a callback that will get invoked when the VM Service
/// starts up. If the VM Service has already started before this
/// call is made, the callback is invoked immediately.
///
/// This method is thread safe.
///
/// @param[in] callback The callback with information about the observatory.
/// @param[in] callback The callback with information about the VM Service.
///
/// @return A handle for the callback that can be used later in
/// `RemoveServerStatusCallback`.
///
[[nodiscard]] static CallbackHandle AddServerStatusCallback(
const ObservatoryServerStateCallback& callback);
const DartVMServiceServerStateCallback& callback);

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

static std::mutex callbacks_mutex_;
static std::set<std::unique_ptr<ObservatoryServerStateCallback>> callbacks_;
static std::set<std::unique_ptr<DartVMServiceServerStateCallback>> callbacks_;
};

} // namespace flutter
Expand Down
56 changes: 39 additions & 17 deletions shell/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -235,33 +235,55 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) {
settings.executable_name = command_line.argv0();
}

// Enable Observatory
settings.enable_observatory =
// 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));

// Enable mDNS Observatory Publication
settings.enable_observatory_publication = !command_line.HasOption(
FlagForSwitch(Switch::DisableObservatoryPublication));

// Set Observatory Host
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryHost))) {
// Enable mDNS VM Service Publication
settings.enable_vm_service_publication =
!command_line.HasOption(
FlagForSwitch(Switch::DisableVMServicePublication)) &&
!command_line.HasOption(
FlagForSwitch(Switch::DisableObservatoryPublication));

// 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.observatory_host);
&settings.vm_service_host);
}
// Default the observatory port based on --ipv6 if not set.
if (settings.observatory_host.empty()) {
settings.observatory_host =
// Default the VM Service port based on --ipv6 if not set.
if (settings.vm_service_host.empty()) {
settings.vm_service_host =
command_line.HasOption(FlagForSwitch(Switch::IPv6)) ? "::1"
: "127.0.0.1";
}

// Set Observatory Port
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) {
// Set VM Service Port
if (command_line.HasOption(FlagForSwitch(Switch::DeviceVMServicePort))) {
if (!GetSwitchValue(command_line, Switch::DeviceVMServicePort,
&settings.vm_service_port)) {
FML_LOG(INFO)
<< "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.observatory_port)) {
&settings.vm_service_port)) {
FML_LOG(INFO)
<< "Observatory port specified was malformed. Will default to "
<< settings.observatory_port;
<< "VM Service port specified was malformed. Will default to "
<< settings.vm_service_port;
}
}

Expand Down
Loading

0 comments on commit 9234df1

Please sign in to comment.