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

Revert "Remove references to Observatory (#38919)" #39035

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -2508,8 +2508,6 @@ 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 @@ -2530,6 +2528,8 @@ 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,8 +4996,6 @@ 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 @@ -5018,6 +5016,8 @@ 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";

// VM Service settings
// Observatory settings

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

// Whether to publish the VM Service URL over mDNS.
// Whether to publish the observatory 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_vm_service_publication = true;
bool enable_observatory_publication = true;

// The IP address to which the Dart VM service is bound.
std::string vm_service_host;
std::string observatory_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 vm_service_port = 0;
uint32_t observatory_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 Dart VM Service URL for this browser.
/// The Observatory URL for this browser.
///
/// Returns `null` for browsers that aren't running the Dart VM, or
/// if the Dart VM Service URL can't be found.
Future<Uri>? get vmServiceUrl => null;
/// if the Observatory URL can't be found.
Future<Uri>? get observatoryUrl => 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.vmServiceUrl,
return _BrowserEnvironment(this, await _browser.observatoryUrl,
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 Dart VM Service to show the
// Instead, this is just additional metadata for the Observatory 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_vm_service) {
if (!settings.enable_observatory) {
return nullptr;
}

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

tonic::DartState::Scope scope(service_isolate);
if (!DartServiceIsolate::Startup(
settings.vm_service_host, // server IP address
settings.vm_service_port, // server VM service port
settings.observatory_host, // server IP address
settings.observatory_port, // server observatory 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_vm_service = true;
settings.vm_service_port = 0;
settings.vm_service_host = "127.0.0.1";
settings.enable_observatory = true;
settings.observatory_port = 0;
settings.observatory_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_vm_service = false;
settings.enable_observatory = 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_vm_service = false;
settings.enable_observatory = 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_vm_service = true;
settings.enable_observatory = 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_vm_service_uri;
static std::string g_observatory_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::DartVMServiceServerStateCallback>>
std::set<std::unique_ptr<DartServiceIsolate::ObservatoryServerStateCallback>>
DartServiceIsolate::callbacks_;

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

g_vm_service_uri = uri;
g_observatory_uri = uri;

// Collect callbacks to fire in a separate collection and invoke them outside
// the lock.
std::vector<DartServiceIsolate::DartVMServiceServerStateCallback>
std::vector<DartServiceIsolate::ObservatoryServerStateCallback>
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::DartVMServiceServerStateCallback& callback) {
const DartServiceIsolate::ObservatoryServerStateCallback& callback) {
if (!callback) {
return 0;
}

auto callback_pointer =
std::make_unique<DartServiceIsolate::DartVMServiceServerStateCallback>(
std::make_unique<DartServiceIsolate::ObservatoryServerStateCallback>(
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_vm_service_uri.empty()) {
callback(g_vm_service_uri);
if (!g_observatory_uri.empty()) {
callback(g_observatory_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 VM Service is ready. The argument
/// indicates the VM Service URI.
/// A callback made by the Dart VM when the observatory is ready. The argument
/// indicates the observatory URI.
///
using DartVMServiceServerStateCallback =
std::function<void(const std::string& vm_service_uri)>;
using ObservatoryServerStateCallback =
std::function<void(const std::string& observatory_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 VM Service
/// starts up. If the VM Service has already started before this
/// @brief Add a callback that will get invoked when the observatory
/// starts up. If the observatory 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 VM Service.
/// @param[in] callback The callback with information about the observatory.
///
/// @return A handle for the callback that can be used later in
/// `RemoveServerStatusCallback`.
///
[[nodiscard]] static CallbackHandle AddServerStatusCallback(
const DartVMServiceServerStateCallback& callback);
const ObservatoryServerStateCallback& 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<DartVMServiceServerStateCallback>> callbacks_;
static std::set<std::unique_ptr<ObservatoryServerStateCallback>> callbacks_;
};

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

// 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
// Enable Observatory
settings.enable_observatory =
!command_line.HasOption(FlagForSwitch(Switch::DisableObservatory));

// 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
// Enable mDNS Observatory Publication
settings.enable_observatory_publication = !command_line.HasOption(
FlagForSwitch(Switch::DisableObservatoryPublication));

// Set Observatory Host
if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryHost))) {
command_line.GetOptionValue(FlagForSwitch(Switch::DeviceObservatoryHost),
&settings.vm_service_host);
&settings.observatory_host);
}
// Default the VM Service port based on --ipv6 if not set.
if (settings.vm_service_host.empty()) {
settings.vm_service_host =
// Default the observatory port based on --ipv6 if not set.
if (settings.observatory_host.empty()) {
settings.observatory_host =
command_line.HasOption(FlagForSwitch(Switch::IPv6)) ? "::1"
: "127.0.0.1";
}

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

Expand Down
Loading