Reland "Remove references to Observatory (#38919)" (#39139)
This reverts commit 5dd945442b230a2c0549ee6d798fda71e031a4a9.
diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter
index 19fcdcf..360e405 100644
--- a/ci/licenses_golden/licenses_flutter
+++ b/ci/licenses_golden/licenses_flutter
@@ -2506,6 +2506,8 @@
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
@@ -2526,8 +2528,6 @@
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
@@ -4992,6 +4992,8 @@
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
@@ -5012,8 +5014,6 @@
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
diff --git a/common/settings.h b/common/settings.h
index 39017db..75f1e26 100644
--- a/common/settings.h
+++ b/common/settings.h
@@ -161,23 +161,23 @@
// 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.
diff --git a/lib/web_ui/dev/browser.dart b/lib/web_ui/dev/browser.dart
index fda2bb9..b4e7d23 100644
--- a/lib/web_ui/dev/browser.dart
+++ b/lib/web_ui/dev/browser.dart
@@ -54,11 +54,11 @@
/// 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.
///
diff --git a/lib/web_ui/dev/test_platform.dart b/lib/web_ui/dev/test_platform.dart
index 007670b..17a66d0 100644
--- a/lib/web_ui/dev/test_platform.dart
+++ b/lib/web_ui/dev/test_platform.dart
@@ -820,7 +820,7 @@
/// Loads [_BrowserEnvironment].
Future<_BrowserEnvironment> _loadBrowserEnvironment() async {
- return _BrowserEnvironment(this, await _browser.observatoryUrl,
+ return _BrowserEnvironment(this, await _browser.vmServiceUrl,
await _browser.remoteDebuggerUrl, _onRestartController.stream);
}
diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc
index 0f819ef..6e4e375 100644
--- a/runtime/dart_isolate.cc
+++ b/runtime/dart_isolate.cc
@@ -412,7 +412,7 @@
}
// 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
@@ -766,7 +766,7 @@
const auto& settings = vm_data->GetSettings();
- if (!settings.enable_observatory) {
+ if (!settings.enable_vm_service) {
return nullptr;
}
@@ -802,8 +802,8 @@
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
diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc
index e5f43fd..2a299f3 100644
--- a/runtime/dart_isolate_unittests.cc
+++ b/runtime/dart_isolate_unittests.cc
@@ -404,9 +404,9 @@
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();
diff --git a/runtime/dart_lifecycle_unittests.cc b/runtime/dart_lifecycle_unittests.cc
index d316290..467df37 100644
--- a/runtime/dart_lifecycle_unittests.cc
+++ b/runtime/dart_lifecycle_unittests.cc
@@ -19,7 +19,7 @@
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);
@@ -31,7 +31,7 @@
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++) {
@@ -89,7 +89,7 @@
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();
diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc
index 18b51a3..9f27e16 100644
--- a/runtime/dart_service_isolate.cc
+++ b/runtime/dart_service_isolate.cc
@@ -33,7 +33,7 @@
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,
@@ -51,7 +51,7 @@
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) {
@@ -63,11 +63,11 @@
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_);
@@ -82,13 +82,13 @@
}
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());
@@ -98,8 +98,8 @@
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;
diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h
index 754a963..5078c28 100644
--- a/runtime/dart_service_isolate.h
+++ b/runtime/dart_service_isolate.h
@@ -27,11 +27,11 @@
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
@@ -68,19 +68,19 @@
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
@@ -101,7 +101,7 @@
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
diff --git a/shell/common/switches.cc b/shell/common/switches.cc
index 1d51882..1aec89b 100644
--- a/shell/common/switches.cc
+++ b/shell/common/switches.cc
@@ -235,33 +235,55 @@
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));
+ // Enable mDNS VM Service Publication
+ settings.enable_vm_service_publication =
+ !command_line.HasOption(
+ FlagForSwitch(Switch::DisableVMServicePublication)) &&
+ !command_line.HasOption(
+ FlagForSwitch(Switch::DisableObservatoryPublication));
- // Set Observatory Host
- if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryHost))) {
+ // 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))) {
- if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort,
- &settings.observatory_port)) {
+ // Set VM Service Port
+ if (command_line.HasOption(FlagForSwitch(Switch::DeviceVMServicePort))) {
+ if (!GetSwitchValue(command_line, Switch::DeviceVMServicePort,
+ &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;
+ }
+ } 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.vm_service_port)) {
+ FML_LOG(INFO)
+ << "VM Service port specified was malformed. Will default to "
+ << settings.vm_service_port;
}
}
diff --git a/shell/common/switches.h b/shell/common/switches.h
index a651290..ce27a02 100644
--- a/shell/common/switches.h
+++ b/shell/common/switches.h
@@ -70,30 +70,58 @@
"dart-flags",
"Flags passed directly to the Dart VM without being interpreted "
"by the Flutter shell.")
-DEF_SWITCH(DeviceObservatoryHost,
- "observatory-host",
- "The hostname/IP address on which the Dart Observatory should "
+DEF_SWITCH(DeviceVMServiceHost,
+ "vm-service-host",
+ "The hostname/IP address on which the Dart VM Service should "
"be served. If not set, defaults to 127.0.0.1 or ::1 depending on "
"whether --ipv6 is specified.")
+// TODO(bkonyi): remove once flutter_tools no longer uses this option.
+// See https://github.com/dart-lang/sdk/issues/50233
+DEF_SWITCH(
+ DeviceObservatoryHost,
+ "observatory-host",
+ "(deprecated) The hostname/IP address on which the Dart VM Service should "
+ "be served. If not set, defaults to 127.0.0.1 or ::1 depending on "
+ "whether --ipv6 is specified.")
+DEF_SWITCH(DeviceVMServicePort,
+ "vm-service-port",
+ "A custom Dart VM Service port. The default is to pick a randomly "
+ "available open port.")
+// TODO(bkonyi): remove once flutter_tools no longer uses this option.
+// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DeviceObservatoryPort,
"observatory-port",
- "A custom Dart Observatory port. The default is to pick a randomly "
+ "(deprecated) A custom Dart VM Service port. The default is to pick "
+ "a randomly "
"available open port.")
+DEF_SWITCH(
+ DisableVMService,
+ "disable-vm-service",
+ "Disable the Dart VM Service. The Dart VM Service is never available "
+ "in release mode.")
+// TODO(bkonyi): remove once flutter_tools no longer uses this option.
+// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DisableObservatory,
"disable-observatory",
- "Disable the Dart Observatory. The observatory is never available "
+ "(deprecated) Disable the Dart VM Service. The Dart VM Service is "
+ "never available "
"in release mode.")
+DEF_SWITCH(DisableVMServicePublication,
+ "disable-vm-service-publication",
+ "Disable mDNS Dart VM Service publication.")
+// TODO(bkonyi): remove once flutter_tools no longer uses this option.
+// See https://github.com/dart-lang/sdk/issues/50233
DEF_SWITCH(DisableObservatoryPublication,
"disable-observatory-publication",
- "Disable mDNS Dart Observatory publication.")
+ "(deprecated) Disable mDNS Dart VM Service publication.")
DEF_SWITCH(IPv6,
"ipv6",
- "Bind to the IPv6 localhost address for the Dart Observatory. "
- "Ignored if --observatory-host is set.")
+ "Bind to the IPv6 localhost address for the Dart VM Service. "
+ "Ignored if --vm-service-host is set.")
DEF_SWITCH(EnableDartProfiling,
"enable-dart-profiling",
"Enable Dart profiling. Profiling information can be viewed from "
- "the observatory.")
+ "Dart / Flutter DevTools.")
DEF_SWITCH(EndlessTraceBuffer,
"endless-trace-buffer",
"Enable an endless trace buffer. The default is a ring buffer. "
diff --git a/shell/platform/android/flutter_main.cc b/shell/platform/android/flutter_main.cc
index bf4930b..782b373 100644
--- a/shell/platform/android/flutter_main.cc
+++ b/shell/platform/android/flutter_main.cc
@@ -59,7 +59,7 @@
} // anonymous namespace
FlutterMain::FlutterMain(const flutter::Settings& settings)
- : settings_(settings), observatory_uri_callback_() {}
+ : settings_(settings), vm_service_uri_callback_() {}
FlutterMain::~FlutterMain() = default;
@@ -100,8 +100,8 @@
__android_log_print(
ANDROID_LOG_INFO, "Flutter",
"ATrace was enabled at startup. Flutter and Dart "
- "tracing will be forwarded to systrace and will not show up in the "
- "Observatory timeline or Dart DevTools.");
+ "tracing will be forwarded to systrace and will not show up in "
+ "Dart DevTools.");
}
}
@@ -164,17 +164,17 @@
// longer be a singleton.
g_flutter_main.reset(new FlutterMain(settings));
- g_flutter_main->SetupObservatoryUriCallback(env);
+ g_flutter_main->SetupDartVMServiceUriCallback(env);
}
-void FlutterMain::SetupObservatoryUriCallback(JNIEnv* env) {
+void FlutterMain::SetupDartVMServiceUriCallback(JNIEnv* env) {
g_flutter_jni_class = new fml::jni::ScopedJavaGlobalRef<jclass>(
env, env->FindClass("io/flutter/embedding/engine/FlutterJNI"));
if (g_flutter_jni_class->is_null()) {
return;
}
jfieldID uri_field = env->GetStaticFieldID(
- g_flutter_jni_class->obj(), "observatoryUri", "Ljava/lang/String;");
+ g_flutter_jni_class->obj(), "vmServiceUri", "Ljava/lang/String;");
if (uri_field == nullptr) {
return;
}
@@ -190,7 +190,7 @@
fml::RefPtr<fml::TaskRunner> platform_runner =
fml::MessageLoop::GetCurrent().GetTaskRunner();
- observatory_uri_callback_ = DartServiceIsolate::AddServerStatusCallback(
+ vm_service_uri_callback_ = DartServiceIsolate::AddServerStatusCallback(
[platform_runner, set_uri](const std::string& uri) {
platform_runner->PostTask([uri, set_uri] { set_uri(uri); });
});
diff --git a/shell/platform/android/flutter_main.h b/shell/platform/android/flutter_main.h
index b956377..bc78efc 100644
--- a/shell/platform/android/flutter_main.h
+++ b/shell/platform/android/flutter_main.h
@@ -25,7 +25,7 @@
private:
const flutter::Settings settings_;
- DartServiceIsolate::CallbackHandle observatory_uri_callback_;
+ DartServiceIsolate::CallbackHandle vm_service_uri_callback_;
explicit FlutterMain(const flutter::Settings& settings);
@@ -38,7 +38,7 @@
jstring engineCachesPath,
jlong initTimeMillis);
- void SetupObservatoryUriCallback(JNIEnv* env);
+ void SetupDartVMServiceUriCallback(JNIEnv* env);
FML_DISALLOW_COPY_AND_ASSIGN(FlutterMain);
};
diff --git a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java
index 21a9443..9883d6e 100644
--- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java
+++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java
@@ -321,9 +321,16 @@
if (intent.getBooleanExtra("verbose-logging", false)) {
args.add("--verbose-logging");
}
- final int observatoryPort = intent.getIntExtra("observatory-port", 0);
- if (observatoryPort > 0) {
- args.add("--observatory-port=" + Integer.toString(observatoryPort));
+ int vmServicePort = intent.getIntExtra("vm-service-port", 0);
+ if (vmServicePort > 0) {
+ args.add("--vm-service-port=" + Integer.toString(vmServicePort));
+ } else {
+ // TODO(bkonyi): remove once flutter_tools no longer uses this option.
+ // See https://github.com/dart-lang/sdk/issues/50233
+ vmServicePort = intent.getIntExtra("observatory-port", 0);
+ if (vmServicePort > 0) {
+ args.add("--vm-service-port=" + Integer.toString(vmServicePort));
+ }
}
if (intent.getBooleanExtra("endless-trace-buffer", false)) {
args.add("--endless-trace-buffer");
diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
index aba6f67..3a20807 100644
--- a/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
+++ b/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
@@ -215,7 +215,7 @@
private static float refreshRateFPS = 60.0f;
// This is set from native code via JNI.
- @Nullable private static String observatoryUri;
+ @Nullable private static String vmServiceUri;
private native boolean nativeGetIsSoftwareRenderingEnabled();
@@ -230,14 +230,28 @@
}
/**
- * Observatory URI for the VM instance.
+ * VM Service URI for the VM instance.
*
* <p>Its value is set by the native engine once {@link #init(Context, String[], String, String,
* String, long)} is run.
*/
@Nullable
+ public static String getVMServiceUri() {
+ return vmServiceUri;
+ }
+
+ /**
+ * VM Service URI for the VM instance.
+ *
+ * <p>Its value is set by the native engine once {@link #init(Context, String[], String, String,
+ * String, long)} is run.
+ *
+ * @deprecated replaced by {@link #getVMServiceUri()}.
+ */
+ @Deprecated
+ @Nullable
public static String getObservatoryUri() {
- return observatoryUri;
+ return vmServiceUri;
}
/**
diff --git a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
index c741f6a..49519f1 100644
--- a/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
+++ b/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
@@ -54,8 +54,11 @@
public static final String ARG_PURGE_PERSISTENT_CACHE = "--purge-persistent-cache";
public static final String ARG_KEY_VERBOSE_LOGGING = "verbose-logging";
public static final String ARG_VERBOSE_LOGGING = "--verbose-logging";
+ public static final String ARG_KEY_VM_SERVICE_PORT = "vm-service-port";
+ public static final String ARG_VM_SERVICE_PORT = "--vm-service-port=";
+ // TODO(bkonyi): remove once flutter_tools no longer uses this option.
+ // See https://github.com/dart-lang/sdk/issues/50233
public static final String ARG_KEY_OBSERVATORY_PORT = "observatory-port";
- public static final String ARG_OBSERVATORY_PORT = "--observatory-port=";
public static final String ARG_KEY_DART_FLAGS = "dart-flags";
public static final String ARG_DART_FLAGS = "--dart-flags";
public static final String ARG_KEY_MSAA_SAMPLES = "msaa-samples";
@@ -76,9 +79,16 @@
if (intent.getBooleanExtra(ARG_KEY_START_PAUSED, false)) {
args.add(ARG_START_PAUSED);
}
- final int observatoryPort = intent.getIntExtra(ARG_KEY_OBSERVATORY_PORT, 0);
- if (observatoryPort > 0) {
- args.add(ARG_OBSERVATORY_PORT + Integer.toString(observatoryPort));
+ int vmServicePort = intent.getIntExtra(ARG_KEY_VM_SERVICE_PORT, 0);
+ if (vmServicePort > 0) {
+ args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort));
+ } else {
+ // TODO(bkonyi): remove once flutter_tools no longer uses this option.
+ // See https://github.com/dart-lang/sdk/issues/50233
+ vmServicePort = intent.getIntExtra(ARG_KEY_OBSERVATORY_PORT, 0);
+ if (vmServicePort > 0) {
+ args.add(ARG_VM_SERVICE_PORT + Integer.toString(vmServicePort));
+ }
}
if (intent.getBooleanExtra(ARG_KEY_DISABLE_SERVICE_AUTH_CODES, false)) {
args.add(ARG_DISABLE_SERVICE_AUTH_CODES);
diff --git a/shell/platform/android/io/flutter/view/FlutterNativeView.java b/shell/platform/android/io/flutter/view/FlutterNativeView.java
index 190a9ec..2f02769 100644
--- a/shell/platform/android/io/flutter/view/FlutterNativeView.java
+++ b/shell/platform/android/io/flutter/view/FlutterNativeView.java
@@ -124,8 +124,13 @@
return applicationIsRunning;
}
+ @Deprecated
public static String getObservatoryUri() {
- return FlutterJNI.getObservatoryUri();
+ return FlutterJNI.getVMServiceUri();
+ }
+
+ public static String getVMServiceUri() {
+ return FlutterJNI.getVMServiceUri();
}
@Override
diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn
index 8492a14..9838c34 100644
--- a/shell/platform/darwin/ios/BUILD.gn
+++ b/shell/platform/darwin/ios/BUILD.gn
@@ -80,6 +80,8 @@
"framework/Source/FlutterChannelKeyResponder.mm",
"framework/Source/FlutterDartProject.mm",
"framework/Source/FlutterDartProject_Internal.h",
+ "framework/Source/FlutterDartVMServicePublisher.h",
+ "framework/Source/FlutterDartVMServicePublisher.mm",
"framework/Source/FlutterEmbedderKeyResponder.h",
"framework/Source/FlutterEmbedderKeyResponder.mm",
"framework/Source/FlutterEngine.mm",
@@ -90,8 +92,6 @@
"framework/Source/FlutterKeySecondaryResponder.h",
"framework/Source/FlutterKeyboardManager.h",
"framework/Source/FlutterKeyboardManager.mm",
- "framework/Source/FlutterObservatoryPublisher.h",
- "framework/Source/FlutterObservatoryPublisher.mm",
"framework/Source/FlutterOverlayView.h",
"framework/Source/FlutterOverlayView.mm",
"framework/Source/FlutterPlatformPlugin.h",
diff --git a/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h b/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h
index 57ac4c2..caf2b3d 100644
--- a/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h
+++ b/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h
@@ -410,13 +410,23 @@
@property(nonatomic, readonly) FlutterBasicMessageChannel* keyEventChannel;
/**
- * The `NSURL` of the observatory for the service isolate.
+ * The depcreated `NSURL` of the Dart VM Service for the service isolate.
*
* This is only set in debug and profile runtime modes, and only after the
- * observatory service is ready. In release mode or before the observatory has
+ * Dart VM Service is ready. In release mode or before the Dart VM Service has
* started, it returns `nil`.
*/
-@property(nonatomic, readonly, nullable) NSURL* observatoryUrl;
+@property(nonatomic, readonly, nullable)
+ NSURL* observatoryUrl FLUTTER_DEPRECATED("Use vmServiceUrl instead");
+
+/**
+ * The `NSURL` of the Dart VM Service for the service isolate.
+ *
+ * This is only set in debug and profile runtime modes, and only after the
+ * Dart VM Service is ready. In release mode or before the Dart VM Service has
+ * started, it returns `nil`.
+ */
+@property(nonatomic, readonly, nullable) NSURL* vmServiceUrl;
/**
* The `FlutterBinaryMessenger` associated with this FlutterEngine (used for communicating with
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h
new file mode 100644
index 0000000..398e9f0
--- /dev/null
+++ b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h
@@ -0,0 +1,21 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_
+#define FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_
+
+#import <Foundation/Foundation.h>
+
+@interface FlutterDartVMServicePublisher : NSObject
+
+- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication
+ NS_DESIGNATED_INITIALIZER;
+- (instancetype)init NS_UNAVAILABLE;
++ (instancetype)new NS_UNAVAILABLE;
+
+@property(nonatomic, retain, readonly) NSURL* url;
+
+@end
+
+#endif // FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm
new file mode 100644
index 0000000..c808336
--- /dev/null
+++ b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm
@@ -0,0 +1,224 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#define FML_USED_ON_EMBEDDER
+
+#import "FlutterDartVMServicePublisher.h"
+
+#if FLUTTER_RELEASE
+
+@implementation FlutterDartVMServicePublisher
+- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication {
+ return [super init];
+}
+@end
+
+#else // FLUTTER_RELEASE
+
+#import <TargetConditionals.h>
+// NSNetService works fine on physical devices before iOS 13.2.
+// However, it doesn't expose the services to regular mDNS
+// queries on the Simulator or on iOS 13.2+ devices.
+//
+// When debugging issues with this implementation, the following is helpful:
+//
+// 1) Running `dns-sd -Z _dartVmService`. This is a built-in macOS tool that
+// can find advertized observatories using this method. If dns-sd can't find
+// it, then the VM service is not getting advertised over any network
+// interface that the host machine has access to.
+// 2) The Python zeroconf package. The dns-sd tool can sometimes see things
+// that aren't advertizing over a network interface - for example, simulators
+// using NSNetService has been observed using dns-sd, but doesn't show up in
+// the Python package (which is a high quality socket based implementation).
+// If that happens, this code should be tweaked such that it shows up in both
+// dns-sd's output and Python zeroconf's detection.
+// 3) The Dart multicast_dns package, which is what Flutter uses to find the
+// port and auth code. If the advertizement shows up in dns-sd and Python
+// zeroconf but not multicast_dns, then it is a bug in multicast_dns.
+#include <dns_sd.h>
+#include <net/if.h>
+
+#include "flutter/fml/logging.h"
+#include "flutter/fml/memory/weak_ptr.h"
+#include "flutter/fml/message_loop.h"
+#include "flutter/fml/platform/darwin/scoped_nsobject.h"
+#include "flutter/runtime/dart_service_isolate.h"
+
+@protocol FlutterDartVMServicePublisherDelegate
+- (void)publishServiceProtocolPort:(NSURL*)uri;
+- (void)stopService;
+@end
+
+@interface FlutterDartVMServicePublisher ()
++ (NSData*)createTxtData:(NSURL*)url;
+
+@property(readonly, class) NSString* serviceName;
+@property(readonly) fml::scoped_nsobject<NSObject<FlutterDartVMServicePublisherDelegate>> delegate;
+@property(nonatomic, readwrite) NSURL* url;
+@property(readonly) BOOL enableVMServicePublication;
+
+@end
+
+@interface DartVMServiceDNSServiceDelegate : NSObject <FlutterDartVMServicePublisherDelegate>
+@end
+
+@implementation DartVMServiceDNSServiceDelegate {
+ DNSServiceRef _dnsServiceRef;
+ DNSServiceRef _legacyDnsServiceRef;
+}
+
+- (void)stopService {
+ if (_dnsServiceRef) {
+ DNSServiceRefDeallocate(_dnsServiceRef);
+ _dnsServiceRef = NULL;
+ }
+ if (_legacyDnsServiceRef) {
+ DNSServiceRefDeallocate(_legacyDnsServiceRef);
+ _legacyDnsServiceRef = NULL;
+ }
+}
+
+- (void)publishServiceProtocolPort:(NSURL*)url {
+ DNSServiceFlags flags = kDNSServiceFlagsDefault;
+#if TARGET_IPHONE_SIMULATOR
+ // Simulator needs to use local loopback explicitly to work.
+ uint32_t interfaceIndex = if_nametoindex("lo0");
+#else // TARGET_IPHONE_SIMULATOR
+ // Physical devices need to request all interfaces.
+ uint32_t interfaceIndex = 0;
+#endif // TARGET_IPHONE_SIMULATOR
+ const char* registrationType = "_dartVmService._tcp";
+ const char* legacyRegistrationType = "_dartobservatory._tcp";
+
+ const char* domain = "local."; // default domain
+ uint16_t port = [[url port] unsignedShortValue];
+
+ NSData* txtData = [FlutterDartVMServicePublisher createTxtData:url];
+ int err = DNSServiceRegister(&_dnsServiceRef, flags, interfaceIndex,
+ FlutterDartVMServicePublisher.serviceName.UTF8String,
+ registrationType, domain, NULL, htons(port), txtData.length,
+ txtData.bytes, RegistrationCallback, NULL);
+
+ if (err == 0) {
+ DNSServiceSetDispatchQueue(_dnsServiceRef, dispatch_get_main_queue());
+ return;
+ }
+
+ // TODO(bkonyi): remove once flutter_tools no longer looks for the legacy registration type.
+ // See https://github.com/dart-lang/sdk/issues/50233
+ //
+ // Try to fallback on the legacy registration type.
+ err = DNSServiceRegister(&_legacyDnsServiceRef, flags, interfaceIndex,
+ FlutterDartVMServicePublisher.serviceName.UTF8String,
+ legacyRegistrationType, domain, NULL, htons(port), txtData.length,
+ txtData.bytes, RegistrationCallback, NULL);
+
+ if (err == 0) {
+ DNSServiceSetDispatchQueue(_legacyDnsServiceRef, dispatch_get_main_queue());
+ return;
+ }
+
+ FML_LOG(ERROR) << "Failed to register Dart VM Service port with mDNS with error " << err << ".";
+ if (@available(iOS 14.0, *)) {
+ FML_LOG(ERROR) << "On iOS 14+, local network broadcast in apps need to be declared in "
+ << "the app's Info.plist. Debug and profile Flutter apps and modules host "
+ << "VM services on the local network to support debugging features such "
+ << "as hot reload and DevTools. To make your Flutter app or module "
+ << "attachable and debuggable, add a '" << registrationType << "' value "
+ << "to the 'NSBonjourServices' key in your Info.plist for the Debug/"
+ << "Profile configurations. "
+ << "For more information, see "
+ << "https://flutter.dev/docs/development/add-to-app/ios/"
+ "project-setup#local-network-privacy-permissions";
+ }
+}
+
+static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ DNSServiceErrorType errorCode,
+ const char* name,
+ const char* regType,
+ const char* domain,
+ void* context) {
+ if (errorCode == kDNSServiceErr_NoError) {
+ FML_DLOG(INFO) << "FlutterDartVMServicePublisher is ready!";
+ } else if (errorCode == kDNSServiceErr_PolicyDenied) {
+ FML_LOG(ERROR)
+ << "Could not register as server for FlutterDartVMServicePublisher, permission "
+ << "denied. Check your 'Local Network' permissions for this app in the Privacy section of "
+ << "the system Settings.";
+ } else {
+ FML_LOG(ERROR) << "Could not register as server for FlutterDartVMServicePublisher. Check your "
+ "network settings and relaunch the application.";
+ }
+}
+
+@end
+
+@implementation FlutterDartVMServicePublisher {
+ flutter::DartServiceIsolate::CallbackHandle _callbackHandle;
+ std::unique_ptr<fml::WeakPtrFactory<FlutterDartVMServicePublisher>> _weakFactory;
+}
+
+- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication {
+ self = [super init];
+ NSAssert(self, @"Super must not return null on init.");
+
+ _delegate.reset([[DartVMServiceDNSServiceDelegate alloc] init]);
+ _enableVMServicePublication = enableVMServicePublication;
+ _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterDartVMServicePublisher>>(self);
+
+ fml::MessageLoop::EnsureInitializedForCurrentThread();
+
+ _callbackHandle = flutter::DartServiceIsolate::AddServerStatusCallback(
+ [weak = _weakFactory->GetWeakPtr(),
+ runner = fml::MessageLoop::GetCurrent().GetTaskRunner()](const std::string& uri) {
+ if (!uri.empty()) {
+ runner->PostTask([weak, uri]() {
+ // uri comes in as something like 'http://127.0.0.1:XXXXX/' where XXXXX is the port
+ // number.
+ if (weak) {
+ NSURL* url = [[[NSURL alloc]
+ initWithString:[NSString stringWithUTF8String:uri.c_str()]] autorelease];
+ weak.get().url = url;
+ if (weak.get().enableVMServicePublication) {
+ [[weak.get() delegate] publishServiceProtocolPort:url];
+ }
+ }
+ });
+ }
+ });
+
+ return self;
+}
+
++ (NSString*)serviceName {
+ return NSBundle.mainBundle.bundleIdentifier;
+}
+
++ (NSData*)createTxtData:(NSURL*)url {
+ // Check to see if there's an authentication code. If there is, we'll provide
+ // it as a txt record so flutter tools can establish a connection.
+ NSString* path = [[url path] substringFromIndex:MIN(1, [[url path] length])];
+ NSData* pathData = [path dataUsingEncoding:NSUTF8StringEncoding];
+ NSDictionary<NSString*, NSData*>* txtDict = @{
+ @"authCode" : pathData,
+ };
+ return [NSNetService dataFromTXTRecordDictionary:txtDict];
+}
+
+- (void)dealloc {
+ // It will be destroyed and invalidate its weak pointers
+ // before any other members are destroyed.
+ _weakFactory.reset();
+
+ [_delegate stopService];
+ [_url release];
+
+ flutter::DartServiceIsolate::RemoveServerStatusCallback(_callbackHandle);
+ [super dealloc];
+}
+@end
+
+#endif // FLUTTER_RELEASE
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
index 480b284..c4c434e 100644
--- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
+++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
@@ -21,8 +21,8 @@
#import "flutter/shell/platform/darwin/common/command_line.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
+#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterIndirectScribbleDelegate.h"
-#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterSpellCheckPlugin.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
@@ -108,7 +108,7 @@
std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory;
fml::WeakPtr<FlutterViewController> _viewController;
- fml::scoped_nsobject<FlutterObservatoryPublisher> _publisher;
+ fml::scoped_nsobject<FlutterDartVMServicePublisher> _publisher;
std::shared_ptr<flutter::FlutterPlatformViewsController> _platformViewsController;
flutter::IOSRenderingAPI _renderingApi;
@@ -502,6 +502,10 @@
return [_publisher.get() url];
}
+- (NSURL*)vmServiceUrl {
+ return [_publisher.get() url];
+}
+
- (void)resetChannels {
_localizationChannel.reset();
_navigationChannel.reset();
@@ -680,13 +684,13 @@
}
- (void)setupShell:(std::unique_ptr<flutter::Shell>)shell
- withObservatoryPublication:(BOOL)doesObservatoryPublication {
+ withVMServicePublication:(BOOL)doesVMServicePublication {
_shell = std::move(shell);
[self setupChannels];
[self onLocaleUpdated:nil];
[self initializeDisplays];
- _publisher.reset([[FlutterObservatoryPublisher alloc]
- initWithEnableObservatoryPublication:doesObservatoryPublication]);
+ _publisher.reset([[FlutterDartVMServicePublisher alloc]
+ initWithEnableVMServicePublication:doesVMServicePublication]);
[self maybeSetupPlatformViewChannels];
_shell->SetGpuAvailability(_isGpuDisabled ? flutter::GpuAvailability::kUnavailable
: flutter::GpuAvailability::kAvailable);
@@ -816,7 +820,7 @@
<< entrypoint.UTF8String;
} else {
[self setupShell:std::move(shell)
- withObservatoryPublication:settings.enable_observatory_publication];
+ withVMServicePublication:settings.enable_vm_service_publication];
if ([FlutterEngine isProfilerEnabled]) {
[self startProfiler];
}
@@ -1312,7 +1316,7 @@
result->_profiler = _profiler;
result->_profiler_metrics = _profiler_metrics;
result->_isGpuDisabled = _isGpuDisabled;
- [result setupShell:std::move(shell) withObservatoryPublication:NO];
+ [result setupShell:std::move(shell) withVMServicePublication:NO];
return [result autorelease];
}
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h b/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h
deleted file mode 100644
index 0c3fe20..0000000
--- a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
-#define FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
-
-#import <Foundation/Foundation.h>
-
-@interface FlutterObservatoryPublisher : NSObject
-
-- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication
- NS_DESIGNATED_INITIALIZER;
-- (instancetype)init NS_UNAVAILABLE;
-+ (instancetype)new NS_UNAVAILABLE;
-
-@property(nonatomic, retain, readonly) NSURL* url;
-
-@end
-
-#endif // FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
diff --git a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm b/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm
deleted file mode 100644
index 9b3c437..0000000
--- a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm
+++ /dev/null
@@ -1,202 +0,0 @@
-// Copyright 2013 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#define FML_USED_ON_EMBEDDER
-
-#import "FlutterObservatoryPublisher.h"
-
-#if FLUTTER_RELEASE
-
-@implementation FlutterObservatoryPublisher
-- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication {
- return [super init];
-}
-@end
-
-#else // FLUTTER_RELEASE
-
-#import <TargetConditionals.h>
-// NSNetService works fine on physical devices before iOS 13.2.
-// However, it doesn't expose the services to regular mDNS
-// queries on the Simulator or on iOS 13.2+ devices.
-//
-// When debugging issues with this implementation, the following is helpful:
-//
-// 1) Running `dns-sd -Z _dartobservatory`. This is a built-in macOS tool that
-// can find advertized observatories using this method. If dns-sd can't find
-// it, then the observatory is not getting advertized over any network
-// interface that the host machine has access to.
-// 2) The Python zeroconf package. The dns-sd tool can sometimes see things
-// that aren't advertizing over a network interface - for example, simulators
-// using NSNetService has been observed using dns-sd, but doesn't show up in
-// the Python package (which is a high quality socket based implementation).
-// If that happens, this code should be tweaked such that it shows up in both
-// dns-sd's output and Python zeroconf's detection.
-// 3) The Dart multicast_dns package, which is what Flutter uses to find the
-// port and auth code. If the advertizement shows up in dns-sd and Python
-// zeroconf but not multicast_dns, then it is a bug in multicast_dns.
-#include <dns_sd.h>
-#include <net/if.h>
-
-#include "flutter/fml/logging.h"
-#include "flutter/fml/memory/weak_ptr.h"
-#include "flutter/fml/message_loop.h"
-#include "flutter/fml/platform/darwin/scoped_nsobject.h"
-#include "flutter/runtime/dart_service_isolate.h"
-
-@protocol FlutterObservatoryPublisherDelegate
-- (void)publishServiceProtocolPort:(NSURL*)uri;
-- (void)stopService;
-@end
-
-@interface FlutterObservatoryPublisher ()
-+ (NSData*)createTxtData:(NSURL*)url;
-
-@property(readonly, class) NSString* serviceName;
-@property(readonly) fml::scoped_nsobject<NSObject<FlutterObservatoryPublisherDelegate>> delegate;
-@property(nonatomic, readwrite) NSURL* url;
-@property(readonly) BOOL enableObservatoryPublication;
-
-@end
-
-@interface ObservatoryDNSServiceDelegate : NSObject <FlutterObservatoryPublisherDelegate>
-@end
-
-@implementation ObservatoryDNSServiceDelegate {
- DNSServiceRef _dnsServiceRef;
-}
-
-- (void)stopService {
- if (_dnsServiceRef) {
- DNSServiceRefDeallocate(_dnsServiceRef);
- _dnsServiceRef = NULL;
- }
-}
-
-- (void)publishServiceProtocolPort:(NSURL*)url {
- DNSServiceFlags flags = kDNSServiceFlagsDefault;
-#if TARGET_IPHONE_SIMULATOR
- // Simulator needs to use local loopback explicitly to work.
- uint32_t interfaceIndex = if_nametoindex("lo0");
-#else // TARGET_IPHONE_SIMULATOR
- // Physical devices need to request all interfaces.
- uint32_t interfaceIndex = 0;
-#endif // TARGET_IPHONE_SIMULATOR
- const char* registrationType = "_dartobservatory._tcp";
- const char* domain = "local."; // default domain
- uint16_t port = [[url port] unsignedShortValue];
-
- NSData* txtData = [FlutterObservatoryPublisher createTxtData:url];
- int err = DNSServiceRegister(&_dnsServiceRef, flags, interfaceIndex,
- FlutterObservatoryPublisher.serviceName.UTF8String, registrationType,
- domain, NULL, htons(port), txtData.length, txtData.bytes,
- RegistrationCallback, NULL);
-
- if (err != 0) {
- FML_LOG(ERROR) << "Failed to register observatory port with mDNS with error " << err << ".";
- if (@available(iOS 14.0, *)) {
- FML_LOG(ERROR) << "On iOS 14+, local network broadcast in apps need to be declared in "
- << "the app's Info.plist. Debug and profile Flutter apps and modules host "
- << "VM services on the local network to support debugging features such "
- << "as hot reload and DevTools. To make your Flutter app or module "
- << "attachable and debuggable, add a '" << registrationType << "' value "
- << "to the 'NSBonjourServices' key in your Info.plist for the Debug/"
- << "Profile configurations. "
- << "For more information, see "
- << "https://flutter.dev/docs/development/add-to-app/ios/"
- "project-setup#local-network-privacy-permissions";
- }
- } else {
- DNSServiceSetDispatchQueue(_dnsServiceRef, dispatch_get_main_queue());
- }
-}
-
-static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
- DNSServiceFlags flags,
- DNSServiceErrorType errorCode,
- const char* name,
- const char* regType,
- const char* domain,
- void* context) {
- if (errorCode == kDNSServiceErr_NoError) {
- FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!";
- } else if (errorCode == kDNSServiceErr_PolicyDenied) {
- FML_LOG(ERROR)
- << "Could not register as server for FlutterObservatoryPublisher, permission "
- << "denied. Check your 'Local Network' permissions for this app in the Privacy section of "
- << "the system Settings.";
- } else {
- FML_LOG(ERROR) << "Could not register as server for FlutterObservatoryPublisher. Check your "
- "network settings and relaunch the application.";
- }
-}
-
-@end
-
-@implementation FlutterObservatoryPublisher {
- flutter::DartServiceIsolate::CallbackHandle _callbackHandle;
- std::unique_ptr<fml::WeakPtrFactory<FlutterObservatoryPublisher>> _weakFactory;
-}
-
-- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication {
- self = [super init];
- NSAssert(self, @"Super must not return null on init.");
-
- _delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]);
- _enableObservatoryPublication = enableObservatoryPublication;
- _weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterObservatoryPublisher>>(self);
-
- fml::MessageLoop::EnsureInitializedForCurrentThread();
-
- _callbackHandle = flutter::DartServiceIsolate::AddServerStatusCallback(
- [weak = _weakFactory->GetWeakPtr(),
- runner = fml::MessageLoop::GetCurrent().GetTaskRunner()](const std::string& uri) {
- if (!uri.empty()) {
- runner->PostTask([weak, uri]() {
- // uri comes in as something like 'http://127.0.0.1:XXXXX/' where XXXXX is the port
- // number.
- if (weak) {
- NSURL* url = [[[NSURL alloc]
- initWithString:[NSString stringWithUTF8String:uri.c_str()]] autorelease];
- weak.get().url = url;
- if (weak.get().enableObservatoryPublication) {
- [[weak.get() delegate] publishServiceProtocolPort:url];
- }
- }
- });
- }
- });
-
- return self;
-}
-
-+ (NSString*)serviceName {
- return NSBundle.mainBundle.bundleIdentifier;
-}
-
-+ (NSData*)createTxtData:(NSURL*)url {
- // Check to see if there's an authentication code. If there is, we'll provide
- // it as a txt record so flutter tools can establish a connection.
- NSString* path = [[url path] substringFromIndex:MIN(1, [[url path] length])];
- NSData* pathData = [path dataUsingEncoding:NSUTF8StringEncoding];
- NSDictionary<NSString*, NSData*>* txtDict = @{
- @"authCode" : pathData,
- };
- return [NSNetService dataFromTXTRecordDictionary:txtDict];
-}
-
-- (void)dealloc {
- // It will be destroyed and invalidate its weak pointers
- // before any other members are destroyed.
- _weakFactory.reset();
-
- [_delegate stopService];
- [_url release];
-
- flutter::DartServiceIsolate::RemoveServerStatusCallback(_callbackHandle);
- [super dealloc];
-}
-@end
-
-#endif // FLUTTER_RELEASE
diff --git a/shell/platform/embedder/tests/embedder_config_builder.cc b/shell/platform/embedder/tests/embedder_config_builder.cc
index 32d5ffa..52764b4 100644
--- a/shell/platform/embedder/tests/embedder_config_builder.cc
+++ b/shell/platform/embedder/tests/embedder_config_builder.cc
@@ -113,7 +113,7 @@
SetSemanticsCallbackHooks();
SetLogMessageCallbackHook();
SetLocalizationCallbackHooks();
- AddCommandLineArgument("--disable-observatory");
+ AddCommandLineArgument("--disable-vm-service");
if (preference == InitializationPreference::kSnapshotsInitialize ||
preference == InitializationPreference::kMultiAOTInitialize) {
diff --git a/shell/platform/fuchsia/dart_runner/service_isolate.cc b/shell/platform/fuchsia/dart_runner/service_isolate.cc
index 6c7ca06..d331e96 100644
--- a/shell/platform/fuchsia/dart_runner/service_isolate.cc
+++ b/shell/platform/fuchsia/dart_runner/service_isolate.cc
@@ -209,17 +209,17 @@
} // namespace dart_runner
Dart_Handle GetVMServiceAssetsArchiveCallback() {
- dart_utils::MappedResource observatory_tar;
+ dart_utils::MappedResource vm_service_tar;
if (!dart_utils::MappedResource::LoadFromNamespace(
- nullptr, "/pkg/data/observatory.tar", observatory_tar)) {
+ nullptr, "/pkg/data/observatory.tar", vm_service_tar)) {
FX_LOG(ERROR, LOG_TAG, "Failed to load Observatory assets");
return nullptr;
}
// TODO(rmacnak): Should we avoid copying the tar? Or does the service
// library not hold onto it anyway?
return tonic::DartConverter<tonic::Uint8List>::ToDart(
- reinterpret_cast<const uint8_t*>(observatory_tar.address()),
- observatory_tar.size());
+ reinterpret_cast<const uint8_t*>(vm_service_tar.address()),
+ vm_service_tar.size());
}
} // namespace dart_runner
diff --git a/shell/platform/fuchsia/flutter/component_v1.cc b/shell/platform/fuchsia/flutter/component_v1.cc
index a024974..3f21401 100644
--- a/shell/platform/fuchsia/flutter/component_v1.cc
+++ b/shell/platform/fuchsia/flutter/component_v1.cc
@@ -363,12 +363,12 @@
}
#if defined(DART_PRODUCT)
- settings_.enable_observatory = false;
+ settings_.enable_vm_service = false;
#else
- settings_.enable_observatory = true;
+ settings_.enable_vm_service = true;
// TODO(cbracken): pass this in as a param to allow 0.0.0.0, ::1, etc.
- settings_.observatory_host = "127.0.0.1";
+ settings_.vm_service_host = "127.0.0.1";
#endif
// Controls whether category "skia" trace events are enabled.
diff --git a/shell/platform/fuchsia/flutter/component_v2.cc b/shell/platform/fuchsia/flutter/component_v2.cc
index 9350481..fdd5774 100644
--- a/shell/platform/fuchsia/flutter/component_v2.cc
+++ b/shell/platform/fuchsia/flutter/component_v2.cc
@@ -426,12 +426,12 @@
}
#if defined(DART_PRODUCT)
- settings_.enable_observatory = false;
+ settings_.enable_vm_service = false;
#else
- settings_.enable_observatory = true;
+ settings_.enable_vm_service = true;
// TODO(cbracken): pass this in as a param to allow 0.0.0.0, ::1, etc.
- settings_.observatory_host = "127.0.0.1";
+ settings_.vm_service_host = "127.0.0.1";
#endif
// Controls whether category "skia" trace events are enabled.
diff --git a/shell/profiling/sampling_profiler.cc b/shell/profiling/sampling_profiler.cc
index c6058b7..4b5e8d4 100644
--- a/shell/profiling/sampling_profiler.cc
+++ b/shell/profiling/sampling_profiler.cc
@@ -33,7 +33,7 @@
<< num_samples_per_sec_;
double delay_between_samples = 1.0 / num_samples_per_sec_;
auto task_delay = fml::TimeDelta::FromSecondsF(delay_between_samples);
- UpdateObservatoryThreadName();
+ UpdateDartVMServiceThreadName();
is_running_ = true;
SampleRepeatedly(task_delay);
}
@@ -88,7 +88,7 @@
task_delay);
}
-void SamplingProfiler::UpdateObservatoryThreadName() const {
+void SamplingProfiler::UpdateDartVMServiceThreadName() const {
FML_CHECK(profiler_task_runner_);
profiler_task_runner_->PostTask(
diff --git a/shell/profiling/sampling_profiler.h b/shell/profiling/sampling_profiler.h
index d68f88a..1385613 100644
--- a/shell/profiling/sampling_profiler.h
+++ b/shell/profiling/sampling_profiler.h
@@ -76,7 +76,7 @@
* @brief a Sampling Profiler that runs peridically and calls the `Sampler`
* which servers as a value function to gather various profiling metrics as
* represented by `ProfileSample`. These profiling metrics are then posted to
- * the observatory timeline.
+ * the Dart VM Service timeline.
*
*/
class SamplingProfiler {
@@ -84,7 +84,7 @@
/**
* @brief Construct a new Sampling Profiler object
*
- * @param thread_label observatory prefix to be set for the profiling task
+ * @param thread_label Dart VM Service prefix to be set for the profiling task
* runner.
* @param profiler_task_runner the task runner to service sampling requests.
* @param sampler the value function to collect the profiling metrics.
@@ -121,10 +121,10 @@
/**
* @brief This doesn't update the underlying OS thread name for the thread
* backing `profiler_task_runner_`. Instead, this is just additional metadata
- * for the Observatory to show the thread name of the isolate.
+ * for the VM Service to show the thread name of the isolate.
*
*/
- void UpdateObservatoryThreadName() const;
+ void UpdateDartVMServiceThreadName() const;
FML_DISALLOW_COPY_AND_ASSIGN(SamplingProfiler);
};
diff --git a/shell/testing/observatory/launcher.dart b/shell/testing/observatory/launcher.dart
index 2603e35..0b4e91e 100644
--- a/shell/testing/observatory/launcher.dart
+++ b/shell/testing/observatory/launcher.dart
@@ -2,25 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-library observatory_sky_shell_launcher;
-
import 'dart:async';
import 'dart:convert';
import 'dart:io';
class ShellProcess {
- final Completer<Uri> _observatoryUriCompleter = Completer<Uri>();
+ final Completer<Uri> _vmServiceUriCompleter = Completer<Uri>();
final Process _process;
ShellProcess(this._process) {
- // Scan stdout and scrape the Observatory Uri.
+ // Scan stdout and scrape the VM Service Uri.
_process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter())
.listen((String line) {
final uri = _extractVMServiceUri(line);
if (uri != null) {
- _observatoryUriCompleter.complete(uri);
+ _vmServiceUriCompleter.complete(uri);
}
});
}
@@ -29,13 +27,13 @@
return _process.kill();
}
- Future<Uri> waitForObservatory() async {
- return _observatoryUriCompleter.future;
+ Future<Uri> waitForVMService() async {
+ return _vmServiceUriCompleter.future;
}
Uri? _extractVMServiceUri(String str) {
final listeningMessageRegExp = RegExp(
- r'(?:Observatory|The Dart VM service is) listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)',
+ r'The Dart VM service is listening on ((http|//)[a-zA-Z0-9:/=_\-\.\[\]]+)',
);
final match = listeningMessageRegExp.firstMatch(str);
if (match != null) {
@@ -47,7 +45,7 @@
class ShellLauncher {
final List<String> args = <String>[
- '--observatory-port=0',
+ '--vm-service-port=0',
'--non-interactive',
'--run-forever',
'--disable-service-auth-codes',
diff --git a/shell/testing/observatory/service_client.dart b/shell/testing/observatory/service_client.dart
index 160a177..8d52c6e 100644
--- a/shell/testing/observatory/service_client.dart
+++ b/shell/testing/observatory/service_client.dart
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-library observatory_sky_shell_service_client;
-
import 'dart:async';
import 'dart:convert';
import 'dart:io';
diff --git a/shell/testing/observatory/test.dart b/shell/testing/observatory/test.dart
index a351c44..ad944df 100644
--- a/shell/testing/observatory/test.dart
+++ b/shell/testing/observatory/test.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This is a minimal dependency heart beat test for Observatory.
+// This is a minimal dependency heart beat test for the Dart VM Service.
import 'dart:async';
import 'dart:convert';
@@ -170,14 +170,14 @@
if (process == null) {
return false;
}
- final Uri uri = await process.waitForObservatory();
+ final Uri uri = await process.waitForVMService();
try {
for (int i = 0; i < tests.length; i++) {
print('Executing test ${i + 1}/${tests.length}');
await tests[i](uri);
}
} catch (e, st) {
- print('Observatory test failure: $e\n$st');
+ print('Dart VM Service test failure: $e\n$st');
exitCode = -1;
}
await process.kill();
diff --git a/testing/dart/observatory/shader_reload_test.dart b/testing/dart/observatory/shader_reload_test.dart
index ca4981e..ff2280e 100644
--- a/testing/dart/observatory/shader_reload_test.dart
+++ b/testing/dart/observatory/shader_reload_test.dart
@@ -23,7 +23,7 @@
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
vmService = await vmServiceConnectUri(
diff --git a/testing/dart/observatory/skp_test.dart b/testing/dart/observatory/skp_test.dart
index 0303702..00c7235 100644
--- a/testing/dart/observatory/skp_test.dart
+++ b/testing/dart/observatory/skp_test.dart
@@ -17,7 +17,7 @@
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
final vms.VmService vmService = await vmServiceConnectUri(
diff --git a/testing/dart/observatory/tracing_test.dart b/testing/dart/observatory/tracing_test.dart
index 3257a8e..6f709bf 100644
--- a/testing/dart/observatory/tracing_test.dart
+++ b/testing/dart/observatory/tracing_test.dart
@@ -15,7 +15,7 @@
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
final vms.VmService vmService = await vmServiceConnectUri(
diff --git a/testing/dart/observatory/vmservice_methods_test.dart b/testing/dart/observatory/vmservice_methods_test.dart
index 6fe14f0..e74caac 100644
--- a/testing/dart/observatory/vmservice_methods_test.dart
+++ b/testing/dart/observatory/vmservice_methods_test.dart
@@ -18,7 +18,7 @@
try {
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
vmService = await vmServiceConnectUri(
@@ -47,7 +47,7 @@
try {
final developer.ServiceProtocolInfo info = await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
vmService = await vmServiceConnectUri(
@@ -71,7 +71,7 @@
final developer.ServiceProtocolInfo info =
await developer.Service.getInfo();
if (info.serverUri == null) {
- fail('This test must not be run with --disable-observatory.');
+ fail('This test must not be run with --disable-vm-service.');
}
final Completer<PlatformResponse> completer = Completer<PlatformResponse>();
diff --git a/testing/dart_fixture.cc b/testing/dart_fixture.cc
index 9fe8a5c..7c765dc 100644
--- a/testing/dart_fixture.cc
+++ b/testing/dart_fixture.cc
@@ -35,7 +35,7 @@
settings.isolate_create_callback = [this]() {
native_resolver_->SetNativeResolverForIsolate();
};
- settings.enable_observatory = false;
+ settings.enable_vm_service = false;
SetSnapshotsAndAssets(settings);
return settings;
}