Description
Tested versions
- Reproducible in v4.4.1.stable.official [49a5bc7], v4.3.stable.official [77dcf97], v4.2.2.stable.official [15073af]
- I could not reproduce in versions prior to 4.2 since the MRP does not work there
System information
Godot v4.4.1.stable - Steam Runtime 2 (soldier) 2 on X11 - X11 display driver, Multi-window, 2 monitors - Vulkan (Forward+) - dedicated AMD Radeon RX 5700 XT (RADV NAVI10) - AMD Ryzen 5 3600 6-Core Processor (12 threads)
Issue description
In an EditorPlugin
, an autoload added in the _enable_plugin
method using add_autload_singleton
, as is recommended in the documentation, seems to be loaded later than nodes instantiated in _enter_tree
. Trying to access the dynamically-added autoload in the _ready
method of one of these nodes produces an error:
ERROR: modules/gdscript/gdscript_vm.cpp:3677 - Condition ' !GDScriptLanguage::get_singleton()->get_named_globals_map().has(*globalname) ' is true. Breaking..:
ERROR: res://addons/example/test.gd:7 - Internal script error! Opcode: 113 (please report).
I believe this is contrary to what would be expected, since when the plugin is loaded along with the project (if it is enabled), the autoload will be ready before the _ready
method of the nodes in instantiated in _enter_tree
is called. This is also the behavior that occurs when these nodes are run directly; the autoload is already ready when their _ready
is called.
I am not sure if this is intended behavior, but I found it confusing. I do not know if it is an issue with the engine, or if the documentation could be clearer on this behavior.
Steps to reproduce
This assumes the attached minimal reproduction project is used.
- When the project is loaded, there should be no errors
- The console should print the messages of
ExampleContext
, and then ofTest
- I found this to be the opposite in v4.2.2.stable.official [15073af]
- An extra set of messages for
Test
is printed since it should be automatically opened in the Editor when the project is loaded
- `Successful!" is printed
- The console should print the messages of
- Run the project
- There should be no errors
- The console should print the messages of
ExampleContext
, and then ofTest
- `Successful!" is printed
- In the project settings, disable and enable the plugin
- The abovementioned error should be shown
- The print messages of
Test
should have been printed before those ofExampleContext
- `Successful!" is not printed
Minimal reproduction project (MRP)
add-autoload-singleton-mrp.zip
This minimal reproduction project has a single example
addon with:
- A
Test
scene that is loaded when the plugin enters the tree - An
ExampleContext
autoload, with ado_something
method thatTest
attempts to call in its_ready
method
This example
plugin is already enabled.
Metadata
Metadata
Assignees
Type
Projects
Status