mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Reland "Remove references to Observatory (#38919)" (flutter/engine#39139)
This reverts commit 5dd945442b230a2c0549ee6d798fda71e031a4a9.
This commit is contained in:
parent
2db3612902
commit
d3f45828bf
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -54,11 +54,11 @@ abstract class BrowserEnvironment {
|
||||
/// Any errors starting or running the browser process are reported through
|
||||
/// [onExit].
|
||||
abstract class Browser {
|
||||
/// The Observatory URL for this browser.
|
||||
/// The Dart VM Service URL for this browser.
|
||||
///
|
||||
/// Returns `null` for browsers that aren't running the Dart VM, or
|
||||
/// if the Observatory URL can't be found.
|
||||
Future<Uri>? get observatoryUrl => null;
|
||||
/// if the Dart VM Service URL can't be found.
|
||||
Future<Uri>? get vmServiceUrl => null;
|
||||
|
||||
/// The remote debugger URL for this browser.
|
||||
///
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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::unique_ptr<DartServiceIsolate::ObservatoryServerStateCallback>>
|
||||
std::set<std::unique_ptr<DartServiceIsolate::DartVMServiceServerStateCallback>>
|
||||
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<DartServiceIsolate::ObservatoryServerStateCallback>
|
||||
std::vector<DartServiceIsolate::DartVMServiceServerStateCallback>
|
||||
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<DartServiceIsolate::ObservatoryServerStateCallback>(
|
||||
std::make_unique<DartServiceIsolate::DartVMServiceServerStateCallback>(
|
||||
callback);
|
||||
|
||||
auto handle = reinterpret_cast<CallbackHandle>(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;
|
||||
|
||||
@ -27,11 +27,11 @@ class DartServiceIsolate {
|
||||
using CallbackHandle = ptrdiff_t;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// A callback made by the Dart VM when the observatory is ready. The argument
|
||||
/// indicates the observatory URI.
|
||||
/// A callback made by the Dart VM when the VM Service is ready. The argument
|
||||
/// indicates the VM Service URI.
|
||||
///
|
||||
using ObservatoryServerStateCallback =
|
||||
std::function<void(const std::string& observatory_uri)>;
|
||||
using DartVMServiceServerStateCallback =
|
||||
std::function<void(const std::string& vm_service_uri)>;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
/// @brief Start the service isolate. This call may only be made in the
|
||||
@ -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<std::unique_ptr<ObservatoryServerStateCallback>> callbacks_;
|
||||
static std::set<std::unique_ptr<DartVMServiceServerStateCallback>> callbacks_;
|
||||
};
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@ -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));
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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. "
|
||||
|
||||
@ -59,7 +59,7 @@ fml::jni::ScopedJavaGlobalRef<jclass>* 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<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 @@ void FlutterMain::SetupObservatoryUriCallback(JNIEnv* env) {
|
||||
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); });
|
||||
});
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -321,9 +321,16 @@ public final class FlutterActivityDelegate
|
||||
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");
|
||||
|
||||
@ -215,7 +215,7 @@ public class FlutterJNI {
|
||||
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 class FlutterJNI {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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 class FlutterShellArgs {
|
||||
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);
|
||||
|
||||
@ -124,8 +124,13 @@ public class FlutterNativeView implements BinaryMessenger {
|
||||
return applicationIsRunning;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getObservatoryUri() {
|
||||
return FlutterJNI.getObservatoryUri();
|
||||
return FlutterJNI.getVMServiceUri();
|
||||
}
|
||||
|
||||
public static String getVMServiceUri() {
|
||||
return FlutterJNI.getVMServiceUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 <Foundation/Foundation.h>
|
||||
|
||||
@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_
|
||||
@ -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 @@
|
||||
//
|
||||
// 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 @@
|
||||
#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<NSObject<FlutterObservatoryPublisherDelegate>> delegate;
|
||||
@property(readonly) fml::scoped_nsobject<NSObject<FlutterDartVMServicePublisherDelegate>> delegate;
|
||||
@property(nonatomic, readwrite) NSURL* url;
|
||||
@property(readonly) BOOL enableObservatoryPublication;
|
||||
@property(readonly) BOOL enableVMServicePublication;
|
||||
|
||||
@end
|
||||
|
||||
@interface ObservatoryDNSServiceDelegate : NSObject <FlutterObservatoryPublisherDelegate>
|
||||
@interface DartVMServiceDNSServiceDelegate : NSObject <FlutterDartVMServicePublisherDelegate>
|
||||
@end
|
||||
|
||||
@implementation ObservatoryDNSServiceDelegate {
|
||||
@implementation DartVMServiceDNSServiceDelegate {
|
||||
DNSServiceRef _dnsServiceRef;
|
||||
DNSServiceRef _legacyDnsServiceRef;
|
||||
}
|
||||
|
||||
- (void)stopService {
|
||||
@ -72,6 +73,10 @@
|
||||
DNSServiceRefDeallocate(_dnsServiceRef);
|
||||
_dnsServiceRef = NULL;
|
||||
}
|
||||
if (_legacyDnsServiceRef) {
|
||||
DNSServiceRefDeallocate(_legacyDnsServiceRef);
|
||||
_legacyDnsServiceRef = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)publishServiceProtocolPort:(NSURL*)url {
|
||||
@ -83,32 +88,49 @@
|
||||
// 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);
|
||||
FlutterDartVMServicePublisher.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 {
|
||||
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<fml::WeakPtrFactory<FlutterObservatoryPublisher>> _weakFactory;
|
||||
std::unique_ptr<fml::WeakPtrFactory<FlutterDartVMServicePublisher>> _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<fml::WeakPtrFactory<FlutterObservatoryPublisher>>(self);
|
||||
_delegate.reset([[DartVMServiceDNSServiceDelegate alloc] init]);
|
||||
_enableVMServicePublication = enableVMServicePublication;
|
||||
_weakFactory = std::make_unique<fml::WeakPtrFactory<FlutterDartVMServicePublisher>>(self);
|
||||
|
||||
fml::MessageLoop::EnsureInitializedForCurrentThread();
|
||||
|
||||
@ -160,7 +182,7 @@ static void DNSSD_API RegistrationCallback(DNSServiceRef sdRef,
|
||||
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];
|
||||
}
|
||||
}
|
||||
@ -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 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
|
||||
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 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
|
||||
return [_publisher.get() url];
|
||||
}
|
||||
|
||||
- (NSURL*)vmServiceUrl {
|
||||
return [_publisher.get() url];
|
||||
}
|
||||
|
||||
- (void)resetChannels {
|
||||
_localizationChannel.reset();
|
||||
_navigationChannel.reset();
|
||||
@ -680,13 +684,13 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
|
||||
}
|
||||
|
||||
- (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 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
|
||||
<< 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 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ EmbedderConfigBuilder::EmbedderConfigBuilder(
|
||||
SetSemanticsCallbackHooks();
|
||||
SetLogMessageCallbackHook();
|
||||
SetLocalizationCallbackHooks();
|
||||
AddCommandLineArgument("--disable-observatory");
|
||||
AddCommandLineArgument("--disable-vm-service");
|
||||
|
||||
if (preference == InitializationPreference::kSnapshotsInitialize ||
|
||||
preference == InitializationPreference::kMultiAOTInitialize) {
|
||||
|
||||
@ -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<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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -76,7 +76,7 @@ using Sampler = std::function<ProfileSample(void)>;
|
||||
* @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);
|
||||
};
|
||||
|
||||
@ -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 @@ class ShellProcess {
|
||||
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 ShellProcess {
|
||||
|
||||
class ShellLauncher {
|
||||
final List<String> args = <String>[
|
||||
'--observatory-port=0',
|
||||
'--vm-service-port=0',
|
||||
'--non-interactive',
|
||||
'--run-forever',
|
||||
'--disable-service-auth-codes',
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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<bool> runTests(ShellLauncher launcher, List<TestFunction> 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();
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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<PlatformResponse> completer = Completer<PlatformResponse>();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user