diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 19fcdcfa36442..360e4054a7fa1 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/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 @@ -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 @@ -4992,6 +4992,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 @@ -5012,8 +5014,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 diff --git a/common/settings.h b/common/settings.h index 39017dbc1cd40..75f1e262fb0eb 100644 --- a/common/settings.h +++ b/common/settings.h @@ -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. diff --git a/lib/web_ui/dev/browser.dart b/lib/web_ui/dev/browser.dart index fda2bb9ca3281..b4e7d2383e833 100644 --- a/lib/web_ui/dev/browser.dart +++ b/lib/web_ui/dev/browser.dart @@ -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? get observatoryUrl => null; + /// if the Dart VM Service URL can't be found. + Future? 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 007670b78b0b6..17a66d0eff1fc 100644 --- a/lib/web_ui/dev/test_platform.dart +++ b/lib/web_ui/dev/test_platform.dart @@ -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); } diff --git a/runtime/dart_isolate.cc b/runtime/dart_isolate.cc index 0f819ef9981c1..6e4e3757cefc6 100644 --- a/runtime/dart_isolate.cc +++ b/runtime/dart_isolate.cc @@ -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 @@ -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; } @@ -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 diff --git a/runtime/dart_isolate_unittests.cc b/runtime/dart_isolate_unittests.cc index e5f43fd56616a..2a299f3150c2f 100644 --- a/runtime/dart_isolate_unittests.cc +++ b/runtime/dart_isolate_unittests.cc @@ -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(); diff --git a/runtime/dart_lifecycle_unittests.cc b/runtime/dart_lifecycle_unittests.cc index d3162905e3ae6..467df37d273af 100644 --- a/runtime/dart_lifecycle_unittests.cc +++ b/runtime/dart_lifecycle_unittests.cc @@ -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); @@ -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++) { @@ -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(); diff --git a/runtime/dart_service_isolate.cc b/runtime/dart_service_isolate.cc index 18b51a32a6f1a..9f27e16d323b9 100644 --- a/runtime/dart_service_isolate.cc +++ b/runtime/dart_service_isolate.cc @@ -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, @@ -51,7 +51,7 @@ const uint8_t* GetSymbol(Dart_NativeFunction native_function) { std::mutex DartServiceIsolate::callbacks_mutex_; -std::set> +std::set> DartServiceIsolate::callbacks_; void DartServiceIsolate::NotifyServerState(Dart_NativeArguments args) { @@ -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 + std::vector callbacks_to_fire; { std::scoped_lock lock(callbacks_mutex_); @@ -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( + std::make_unique( callback); auto handle = reinterpret_cast(callback_pointer.get()); @@ -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; diff --git a/runtime/dart_service_isolate.h b/runtime/dart_service_isolate.h index 754a963d13693..5078c28a78a83 100644 --- a/runtime/dart_service_isolate.h +++ b/runtime/dart_service_isolate.h @@ -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; + using DartVMServiceServerStateCallback = + std::function; //---------------------------------------------------------------------------- /// @brief Start the service isolate. This call may only be made in the @@ -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 @@ -101,7 +101,7 @@ class DartServiceIsolate { static void Shutdown(Dart_NativeArguments args); static std::mutex callbacks_mutex_; - static std::set> callbacks_; + static std::set> callbacks_; }; } // namespace flutter diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 1d518824aa819..1aec89b79b170 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -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; } } diff --git a/shell/common/switches.h b/shell/common/switches.h index a6512908cebe4..ce27a02e0fa01 100644 --- a/shell/common/switches.h +++ b/shell/common/switches.h @@ -70,30 +70,58 @@ DEF_SWITCH(DartFlags, "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 bf4930b1f1082..782b373c21d24 100644 --- a/shell/platform/android/flutter_main.cc +++ b/shell/platform/android/flutter_main.cc @@ -59,7 +59,7 @@ fml::jni::ScopedJavaGlobalRef* g_flutter_jni_class = nullptr; } // 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 @@ void FlutterMain::Init(JNIEnv* env, __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 @@ void FlutterMain::Init(JNIEnv* env, // 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( 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 @@ void FlutterMain::SetupObservatoryUriCallback(JNIEnv* env) { fml::RefPtr 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 b956377c8e295..bc78efce2d46a 100644 --- a/shell/platform/android/flutter_main.h +++ b/shell/platform/android/flutter_main.h @@ -25,7 +25,7 @@ class FlutterMain { 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 @@ class FlutterMain { 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 21a9443228156..9883d6efdb88f 100644 --- a/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java +++ b/shell/platform/android/io/flutter/app/FlutterActivityDelegate.java @@ -321,9 +321,16 @@ private static String[] getArgsFromIntent(Intent intent) { 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 aba6f671deb5d..3a20807bdf1f0 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 @@ public void init( 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 @@ public boolean getIsSoftwareRenderingEnabled() { } /** - * Observatory URI for the VM instance. + * VM Service URI for the VM instance. * *

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. + * + *

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 c741f6a3b58e4..49519f1f979ec 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 class FlutterShellArgs { 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 @@ public static FlutterShellArgs fromIntent(@NonNull Intent intent) { 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 190a9ecbb160e..2f027695b5ad3 100644 --- a/shell/platform/android/io/flutter/view/FlutterNativeView.java +++ b/shell/platform/android/io/flutter/view/FlutterNativeView.java @@ -124,8 +124,13 @@ public boolean isApplicationRunning() { 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 8492a1475e517..9838c341cf9c2 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -80,6 +80,8 @@ source_set("flutter_framework_source") { "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 @@ source_set("flutter_framework_source") { "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 57ac4c22d34bf..caf2b3dfd52a0 100644 --- a/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h +++ b/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h @@ -410,13 +410,23 @@ FLUTTER_DARWIN_EXPORT @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/FlutterObservatoryPublisher.h b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h similarity index 56% rename from shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h rename to shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h index 0c3fe202c6116..398e9f09e5a92 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.h @@ -2,14 +2,14 @@ // 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_ +#ifndef FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_ +#define FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_ #import -@interface FlutterObservatoryPublisher : NSObject +@interface FlutterDartVMServicePublisher : NSObject -- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication +- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication NS_DESIGNATED_INITIALIZER; - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @@ -18,4 +18,4 @@ @end -#endif // FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_ +#endif // FLUTTER_FLUTTERDARTVMSERVICEPUBLISHER_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm similarity index 59% rename from shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm rename to shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm index 9b3c437856c6f..c8083366af5ab 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterDartVMServicePublisher.mm @@ -4,12 +4,12 @@ #define FML_USED_ON_EMBEDDER -#import "FlutterObservatoryPublisher.h" +#import "FlutterDartVMServicePublisher.h" #if FLUTTER_RELEASE -@implementation FlutterObservatoryPublisher -- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication { +@implementation FlutterDartVMServicePublisher +- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication { return [super init]; } @end @@ -23,9 +23,9 @@ - (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPubl // // When debugging issues with this implementation, the following is helpful: // -// 1) Running `dns-sd -Z _dartobservatory`. This is a built-in macOS tool that +// 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 observatory is not getting advertized over any network +// 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 @@ -45,26 +45,27 @@ - (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPubl #include "flutter/fml/platform/darwin/scoped_nsobject.h" #include "flutter/runtime/dart_service_isolate.h" -@protocol FlutterObservatoryPublisherDelegate +@protocol FlutterDartVMServicePublisherDelegate - (void)publishServiceProtocolPort:(NSURL*)uri; - (void)stopService; @end -@interface FlutterObservatoryPublisher () +@interface FlutterDartVMServicePublisher () + (NSData*)createTxtData:(NSURL*)url; @property(readonly, class) NSString* serviceName; -@property(readonly) fml::scoped_nsobject> delegate; +@property(readonly) fml::scoped_nsobject> delegate; @property(nonatomic, readwrite) NSURL* url; -@property(readonly) BOOL enableObservatoryPublication; +@property(readonly) BOOL enableVMServicePublication; @end -@interface ObservatoryDNSServiceDelegate : NSObject +@interface DartVMServiceDNSServiceDelegate : NSObject @end -@implementation ObservatoryDNSServiceDelegate { +@implementation DartVMServiceDNSServiceDelegate { DNSServiceRef _dnsServiceRef; + DNSServiceRef _legacyDnsServiceRef; } - (void)stopService { @@ -72,6 +73,10 @@ - (void)stopService { DNSServiceRefDeallocate(_dnsServiceRef); _dnsServiceRef = NULL; } + if (_legacyDnsServiceRef) { + DNSServiceRefDeallocate(_legacyDnsServiceRef); + _legacyDnsServiceRef = NULL; + } } - (void)publishServiceProtocolPort:(NSURL*)url { @@ -83,32 +88,49 @@ - (void)publishServiceProtocolPort:(NSURL*)url { // Physical devices need to request all interfaces. uint32_t interfaceIndex = 0; #endif // TARGET_IPHONE_SIMULATOR - const char* registrationType = "_dartobservatory._tcp"; + const char* registrationType = "_dartVmService._tcp"; + const char* legacyRegistrationType = "_dartobservatory._tcp"; + const char* domain = "local."; // default domain uint16_t port = [[url port] unsignedShortValue]; - NSData* txtData = [FlutterObservatoryPublisher createTxtData:url]; + NSData* txtData = [FlutterDartVMServicePublisher 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 { + 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"; } } @@ -120,32 +142,32 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef, const char* domain, void* context) { if (errorCode == kDNSServiceErr_NoError) { - FML_DLOG(INFO) << "FlutterObservatoryPublisher is ready!"; + FML_DLOG(INFO) << "FlutterDartVMServicePublisher is ready!"; } else if (errorCode == kDNSServiceErr_PolicyDenied) { FML_LOG(ERROR) - << "Could not register as server for FlutterObservatoryPublisher, permission " + << "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 FlutterObservatoryPublisher. Check your " + FML_LOG(ERROR) << "Could not register as server for FlutterDartVMServicePublisher. Check your " "network settings and relaunch the application."; } } @end -@implementation FlutterObservatoryPublisher { +@implementation FlutterDartVMServicePublisher { flutter::DartServiceIsolate::CallbackHandle _callbackHandle; - std::unique_ptr> _weakFactory; + std::unique_ptr> _weakFactory; } -- (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPublication { +- (instancetype)initWithEnableVMServicePublication:(BOOL)enableVMServicePublication { self = [super init]; NSAssert(self, @"Super must not return null on init."); - _delegate.reset([[ObservatoryDNSServiceDelegate alloc] init]); - _enableObservatoryPublication = enableObservatoryPublication; - _weakFactory = std::make_unique>(self); + _delegate.reset([[DartVMServiceDNSServiceDelegate alloc] init]); + _enableVMServicePublication = enableVMServicePublication; + _weakFactory = std::make_unique>(self); fml::MessageLoop::EnsureInitializedForCurrentThread(); @@ -160,7 +182,7 @@ - (instancetype)initWithEnableObservatoryPublication:(BOOL)enableObservatoryPubl NSURL* url = [[[NSURL alloc] initWithString:[NSString stringWithUTF8String:uri.c_str()]] autorelease]; weak.get().url = url; - if (weak.get().enableObservatoryPublication) { + if (weak.get().enableVMServicePublication) { [[weak.get() delegate] publishServiceProtocolPort:url]; } } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 480b284678614..c4c434ecf18f7 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 @@ @implementation FlutterEngine { std::unique_ptr> _weakFactory; fml::WeakPtr _viewController; - fml::scoped_nsobject _publisher; + fml::scoped_nsobject _publisher; std::shared_ptr _platformViewsController; flutter::IOSRenderingAPI _renderingApi; @@ -502,6 +502,10 @@ - (NSURL*)observatoryUrl { return [_publisher.get() url]; } +- (NSURL*)vmServiceUrl { + return [_publisher.get() url]; +} + - (void)resetChannels { _localizationChannel.reset(); _navigationChannel.reset(); @@ -680,13 +684,13 @@ - (void)launchEngine:(NSString*)entrypoint } - (void)setupShell:(std::unique_ptr)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 @@ - (BOOL)createShell:(NSString*)entrypoint << 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 @@ - (FlutterEngine*)spawnWithEntrypoint:(/*nullable*/ NSString*)entrypoint 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/embedder/tests/embedder_config_builder.cc b/shell/platform/embedder/tests/embedder_config_builder.cc index 32d5ffa2d1de9..52764b4452ab5 100644 --- a/shell/platform/embedder/tests/embedder_config_builder.cc +++ b/shell/platform/embedder/tests/embedder_config_builder.cc @@ -113,7 +113,7 @@ EmbedderConfigBuilder::EmbedderConfigBuilder( 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 6c7ca066c673b..d331e96f44af6 100644 --- a/shell/platform/fuchsia/dart_runner/service_isolate.cc +++ b/shell/platform/fuchsia/dart_runner/service_isolate.cc @@ -209,17 +209,17 @@ Dart_Isolate CreateServiceIsolate( } // 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::ToDart( - reinterpret_cast(observatory_tar.address()), - observatory_tar.size()); + reinterpret_cast(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 a024974c13b84..3f21401c361df 100644 --- a/shell/platform/fuchsia/flutter/component_v1.cc +++ b/shell/platform/fuchsia/flutter/component_v1.cc @@ -363,12 +363,12 @@ ComponentV1::ComponentV1( } #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 93504818d8915..fdd577469d70b 100644 --- a/shell/platform/fuchsia/flutter/component_v2.cc +++ b/shell/platform/fuchsia/flutter/component_v2.cc @@ -426,12 +426,12 @@ ComponentV2::ComponentV2( } #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 c6058b76cd4c7..4b5e8d44b7997 100644 --- a/shell/profiling/sampling_profiler.cc +++ b/shell/profiling/sampling_profiler.cc @@ -33,7 +33,7 @@ void SamplingProfiler::Start() { << 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 @@ void SamplingProfiler::SampleRepeatedly(fml::TimeDelta task_delay) const { 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 d68f88a643d3e..1385613503494 100644 --- a/shell/profiling/sampling_profiler.h +++ b/shell/profiling/sampling_profiler.h @@ -76,7 +76,7 @@ using Sampler = std::function; * @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 @@ class SamplingProfiler { /** * @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 @@ class SamplingProfiler { /** * @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 2603e359c4b0e..0b4e91e3a5140 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 _observatoryUriCompleter = Completer(); + final Completer _vmServiceUriCompleter = Completer(); 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 @@ class ShellProcess { return _process.kill(); } - Future waitForObservatory() async { - return _observatoryUriCompleter.future; + Future 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 ShellProcess { class ShellLauncher { final List args = [ - '--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 160a17795468a..8d52c6ef1ca27 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 a351c444e69d9..ad944dfb74210 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 @@ Future runTests(ShellLauncher launcher, List tests) async { 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 ca4981e4b64fb..ff2280ed271f0 100644 --- a/testing/dart/observatory/shader_reload_test.dart +++ b/testing/dart/observatory/shader_reload_test.dart @@ -23,7 +23,7 @@ void main() { 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 0303702c7a3f5..00c7235b2fb0a 100644 --- a/testing/dart/observatory/skp_test.dart +++ b/testing/dart/observatory/skp_test.dart @@ -17,7 +17,7 @@ void main() { 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 3257a8ef06e3c..6f709bf64084e 100644 --- a/testing/dart/observatory/tracing_test.dart +++ b/testing/dart/observatory/tracing_test.dart @@ -15,7 +15,7 @@ void main() { 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 6fe14f0d5e697..e74caac65b692 100644 --- a/testing/dart/observatory/vmservice_methods_test.dart +++ b/testing/dart/observatory/vmservice_methods_test.dart @@ -18,7 +18,7 @@ void main() { 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 @@ void main() { 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 @@ void main() { 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 completer = Completer(); diff --git a/testing/dart_fixture.cc b/testing/dart_fixture.cc index 9fe8a5c5b0fc9..7c765dcb105a5 100644 --- a/testing/dart_fixture.cc +++ b/testing/dart_fixture.cc @@ -35,7 +35,7 @@ Settings DartFixture::CreateSettingsForFixture() { settings.isolate_create_callback = [this]() { native_resolver_->SetNativeResolverForIsolate(); }; - settings.enable_observatory = false; + settings.enable_vm_service = false; SetSnapshotsAndAssets(settings); return settings; }