Programmatically set the root isolate's debug name (flutter/engine#6596)
An integration test will be added to the framework's repo as a followup. Addresses flutter/flutter#22009
This commit is contained in:
committed by
GitHub
parent
2d0aae4047
commit
29355af835
@@ -31,6 +31,8 @@ class UIDartState : public tonic::DartState {
|
||||
|
||||
Dart_Port main_port() const { return main_port_; }
|
||||
|
||||
void set_debug_name(const std::string name) { debug_name_ = name; }
|
||||
|
||||
const std::string& debug_name() const { return debug_name_; }
|
||||
|
||||
const std::string& logger_prefix() const { return logger_prefix_; }
|
||||
|
||||
@@ -714,6 +714,16 @@ class Window {
|
||||
/// semantics update cannot be used further.
|
||||
void updateSemantics(SemanticsUpdate update) native 'Window_updateSemantics';
|
||||
|
||||
/// Set the debug name associated with this window's root isolate.
|
||||
///
|
||||
/// Normally debug names are automatically generated from the Dart port, entry
|
||||
/// point, and source file. For example: `main.dart$main-1234`.
|
||||
///
|
||||
/// This can be combined with flutter tools `--isolate-filter` flag to debug
|
||||
/// specific root isolates. For example: `flutter attach --isolate-filter=[name]`.
|
||||
/// Note that this does not rename any child isolates of the root.
|
||||
void setIsolateDebugName(String name) native 'Window_setIsolateDebugName';
|
||||
|
||||
/// Sends a message to a platform-specific plugin.
|
||||
///
|
||||
/// The `name` parameter determines which plugin receives the message. The
|
||||
|
||||
@@ -54,6 +54,17 @@ void UpdateSemantics(Dart_NativeArguments args) {
|
||||
UIDartState::Current()->window()->client()->UpdateSemantics(update);
|
||||
}
|
||||
|
||||
void SetIsolateDebugName(Dart_NativeArguments args) {
|
||||
Dart_Handle exception = nullptr;
|
||||
const std::string name =
|
||||
tonic::DartConverter<std::string>::FromArguments(args, 1, exception);
|
||||
if (exception) {
|
||||
Dart_ThrowException(exception);
|
||||
return;
|
||||
}
|
||||
UIDartState::Current()->window()->client()->SetIsolateDebugName(name);
|
||||
}
|
||||
|
||||
Dart_Handle SendPlatformMessage(Dart_Handle window,
|
||||
const std::string& name,
|
||||
Dart_Handle callback,
|
||||
@@ -306,6 +317,7 @@ void Window::RegisterNatives(tonic::DartLibraryNatives* natives) {
|
||||
{"Window_respondToPlatformMessage", _RespondToPlatformMessage, 3, true},
|
||||
{"Window_render", Render, 2, true},
|
||||
{"Window_updateSemantics", UpdateSemantics, 2, true},
|
||||
{"Window_setIsolateDebugName", SetIsolateDebugName, 2, true},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class WindowClient {
|
||||
virtual void Render(Scene* scene) = 0;
|
||||
virtual void UpdateSemantics(SemanticsUpdate* update) = 0;
|
||||
virtual void HandlePlatformMessage(fml::RefPtr<PlatformMessage> message) = 0;
|
||||
virtual void SetIsolateDebugName(const std::string isolateName) = 0;
|
||||
virtual FontCollection& GetFontCollection() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -264,6 +264,14 @@ void RuntimeController::HandlePlatformMessage(
|
||||
client_.HandlePlatformMessage(std::move(message));
|
||||
}
|
||||
|
||||
void RuntimeController::SetIsolateDebugName(const std::string name) {
|
||||
std::shared_ptr<DartIsolate> root_isolate = root_isolate_.lock();
|
||||
if (!root_isolate) {
|
||||
return;
|
||||
}
|
||||
root_isolate->set_debug_name(name);
|
||||
}
|
||||
|
||||
FontCollection& RuntimeController::GetFontCollection() {
|
||||
return client_.GetFontCollection();
|
||||
}
|
||||
|
||||
@@ -150,6 +150,9 @@ class RuntimeController final : public WindowClient {
|
||||
// |blink::WindowClient|
|
||||
void HandlePlatformMessage(fml::RefPtr<PlatformMessage> message) override;
|
||||
|
||||
// |blink::WindowClient|
|
||||
void SetIsolateDebugName(const std::string name) override;
|
||||
|
||||
// |blink::WindowClient|
|
||||
FontCollection& GetFontCollection() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user