diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index e7ea7f2144..74fbf17a1c 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -47,6 +47,11 @@ UIDartState* UIDartState::CreateForChildIsolate() { void UIDartState::DidSetIsolate() { main_port_ = Dart_GetMainPortId(); + DartApiScope api_scope; + Dart_Handle debug_name = Dart_DebugName(); + if (Dart_IsString(debug_name)) { + debug_name_ = tonic::StdStringFromDart(debug_name); + } } UIDartState* UIDartState::Current() { diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index 5eb15f0bd9..111630fbab 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -39,7 +39,7 @@ class UIDartState : public tonic::DartState { IsolateClient* isolate_client() { return isolate_client_; } Dart_Port main_port() const { return main_port_; } - + const std::string& debug_name() const { return debug_name_; } Window* window() const { return window_.get(); } void set_mojo_services(std::unique_ptr mojo_services); @@ -59,6 +59,7 @@ class UIDartState : public tonic::DartState { IsolateClient* isolate_client_; Dart_Port main_port_; + std::string debug_name_; std::unique_ptr mojo_services_; std::unique_ptr window_; diff --git a/engine/src/flutter/runtime/runtime_controller.cc b/engine/src/flutter/runtime/runtime_controller.cc index 071d68431b..943d9eb935 100644 --- a/engine/src/flutter/runtime/runtime_controller.cc +++ b/engine/src/flutter/runtime/runtime_controller.cc @@ -113,4 +113,15 @@ Dart_Port RuntimeController::GetMainPort() { return dart_controller_->dart_state()->main_port(); } +std::string RuntimeController::GetIsolateName() { + if (!dart_controller_) { + return ""; + } + if (!dart_controller_->dart_state()) { + return ""; + } + return dart_controller_->dart_state()->debug_name(); +} + + } // namespace blink diff --git a/engine/src/flutter/runtime/runtime_controller.h b/engine/src/flutter/runtime/runtime_controller.h index 9fbccb2b97..f6a13ef482 100644 --- a/engine/src/flutter/runtime/runtime_controller.h +++ b/engine/src/flutter/runtime/runtime_controller.h @@ -44,6 +44,8 @@ class RuntimeController : public WindowClient, public IsolateClient { Dart_Port GetMainPort(); + std::string GetIsolateName(); + private: explicit RuntimeController(RuntimeDelegate* client);