diff --git a/engine/src/flutter/lib/ui/ui_dart_state.cc b/engine/src/flutter/lib/ui/ui_dart_state.cc index de40bc9b4f..ef6796fc47 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.cc +++ b/engine/src/flutter/lib/ui/ui_dart_state.cc @@ -34,12 +34,11 @@ UIDartState* UIDartState::CreateForChildIsolate() { } void UIDartState::DidSetIsolate() { + FTL_DCHECK(!debug_name_prefix_.empty()); main_port_ = Dart_GetMainPortId(); - tonic::DartApiScope api_scope; - Dart_Handle debug_name = Dart_DebugName(); - if (Dart_IsString(debug_name)) { - debug_name_ = tonic::StdStringFromDart(debug_name); - } + std::ostringstream debug_name; + debug_name << debug_name_prefix_ << "$main-" << main_port_; + debug_name_ = debug_name.str(); } UIDartState* UIDartState::Current() { @@ -50,8 +49,13 @@ void UIDartState::set_font_selector(PassRefPtr selector) { font_selector_ = selector; } + PassRefPtr UIDartState::font_selector() { return font_selector_; } +void UIDartState::set_debug_name_prefix(const std::string& debug_name_prefix) { + debug_name_prefix_ = debug_name_prefix; +} + } // namespace blink diff --git a/engine/src/flutter/lib/ui/ui_dart_state.h b/engine/src/flutter/lib/ui/ui_dart_state.h index 23b3eee4ef..99af0a432d 100644 --- a/engine/src/flutter/lib/ui/ui_dart_state.h +++ b/engine/src/flutter/lib/ui/ui_dart_state.h @@ -39,6 +39,7 @@ class UIDartState : public tonic::DartState { const std::string& debug_name() const { return debug_name_; } Window* window() const { return window_.get(); } + void set_debug_name_prefix(const std::string& debug_name_prefix); void set_font_selector(PassRefPtr selector); PassRefPtr font_selector(); @@ -47,6 +48,7 @@ class UIDartState : public tonic::DartState { IsolateClient* isolate_client_; Dart_Port main_port_; + std::string debug_name_prefix_; std::string debug_name_; std::unique_ptr window_; RefPtr font_selector_; diff --git a/engine/src/flutter/runtime/dart_controller.cc b/engine/src/flutter/runtime/dart_controller.cc index 1f298ca5ea..d5a15b30e4 100644 --- a/engine/src/flutter/runtime/dart_controller.cc +++ b/engine/src/flutter/runtime/dart_controller.cc @@ -196,6 +196,7 @@ void DartController::CreateIsolateFor(const std::string& script_uri, Dart_SetShouldPauseOnStart(Settings::Get().start_paused); + ui_dart_state_->set_debug_name_prefix(script_uri); ui_dart_state_->SetIsolate(isolate); FTL_CHECK(!LogIfError( Dart_SetLibraryTagHandler(tonic::DartState::HandleLibraryTag)));