Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer addons loading after the first file scan/import #86453

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,24 +704,6 @@ void EditorNode::_notification(int p_what) {
} break;

case NOTIFICATION_READY: {
{
started_timestamp = Time::get_singleton()->get_unix_time_from_system();
_initializing_plugins = true;
Vector<String> addons;
if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
addons = GLOBAL_GET("editor_plugins/enabled");
}

for (int i = 0; i < addons.size(); i++) {
set_addon_plugin_enabled(addons[i], true);
}
_initializing_plugins = false;

if (!pending_addons.is_empty()) {
EditorFileSystem::get_singleton()->connect("script_classes_updated", callable_mp(this, &EditorNode::_enable_pending_addons));
}
}

Comment on lines -707 to -724
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm currently thinking if we should still import the addons here when were not in the "editor". We cannot import resources outside the editor, so we should import plugins faster for games.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what do you mean by "editor", but this code never executes at runtime.

RenderingServer::get_singleton()->viewport_set_disable_2d(get_scene_root()->get_viewport_rid(), true);
RenderingServer::get_singleton()->viewport_set_environment_mode(get_viewport()->get_viewport_rid(), RenderingServer::VIEWPORT_ENVIRONMENT_DISABLED);

Expand All @@ -740,6 +722,8 @@ void EditorNode::_notification(int p_what) {
CanvasItemEditor::ThemePreviewMode theme_preview_mode = (CanvasItemEditor::ThemePreviewMode)(int)EditorSettings::get_singleton()->get_project_metadata("2d_editor", "theme_preview", CanvasItemEditor::THEME_PREVIEW_PROJECT);
update_preview_themes(theme_preview_mode);

started_timestamp = Time::get_singleton()->get_unix_time_from_system();

/* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */
} break;

Expand Down Expand Up @@ -1073,35 +1057,51 @@ void EditorNode::_resources_reimported(const Vector<String> &p_resources) {
}

void EditorNode::_sources_changed(bool p_exist) {
if (waiting_for_first_scan) {
waiting_for_first_scan = false;
if (!waiting_for_first_scan) {
return;
}
Comment on lines +1060 to +1062
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, I just early exited instead of wrapping the whole contents of the function inside an if block.


OS::get_singleton()->benchmark_end_measure("Editor", "First Scan");
waiting_for_first_scan = false;

// Reload the global shader variables, but this time
// loading textures, as they are now properly imported.
RenderingServer::get_singleton()->global_shader_parameters_load_settings(true);
OS::get_singleton()->benchmark_end_measure("Editor", "First Scan");

_load_editor_layout();
// Reload the global shader variables, but this time
// loading textures, as they are now properly imported.
RenderingServer::get_singleton()->global_shader_parameters_load_settings(true);

if (!defer_load_scene.is_empty()) {
OS::get_singleton()->benchmark_begin_measure("Editor", "Load Scene");
_load_editor_layout();

load_scene(defer_load_scene);
defer_load_scene = "";
if (!defer_load_scene.is_empty()) {
OS::get_singleton()->benchmark_begin_measure("Editor", "Load Scene");

OS::get_singleton()->benchmark_end_measure("Editor", "Load Scene");
OS::get_singleton()->benchmark_dump();
}
load_scene(defer_load_scene);
defer_load_scene = "";

OS::get_singleton()->benchmark_end_measure("Editor", "Load Scene");
OS::get_singleton()->benchmark_dump();
}

if (SurfaceUpgradeTool::get_singleton()->is_show_requested()) {
SurfaceUpgradeTool::get_singleton()->show_popup();
}

if (SurfaceUpgradeTool::get_singleton()->is_show_requested()) {
SurfaceUpgradeTool::get_singleton()->show_popup();
// Start preview thread now that it's safe.
if (!singleton->cmdline_export_mode) {
EditorResourcePreview::get_singleton()->start();
}

// Load the addons.
{
_initializing_plugins = true;
Vector<String> addons;
if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) {
addons = GLOBAL_GET("editor_plugins/enabled");
}

// Start preview thread now that it's safe.
if (!singleton->cmdline_export_mode) {
EditorResourcePreview::get_singleton()->start();
for (int i = 0; i < addons.size(); i++) {
set_addon_plugin_enabled(addons[i], true);
}
_initializing_plugins = false;
}
}

Expand Down
Loading