Skip to content

Optimized ScriptEditor initialization when many scripts are loaded

Created by: pouleyKetchoupp

This change avoids the editor to freeze for several seconds when a project with lots of open scripts (> 50) is loaded in the editor.

It focuses on a few heavy operations previously executed on all loaded scripts:

  • Initialize script resource (script validation/parsing) now only on focus
  • ScriptTextEditor: code editor and menus are added to the scene only on focus
  • Add to "recently opened" now only when opening a new script (causes load/save metadata file)

Results Loading time 5x faster with ~100 scripts in release_debug (1s instead of 5s on my configuration)

Tests I've added safety nets in different places to avoid potential crashes, and tested as much as I could with gdscript, visual scripts and text files, but it probably needs more intensive tests to catch any potential remaining issue.

Merge request reports