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

Cyclic Autoload Singleton Plugin Bug. #58871

Closed
Multirious opened this issue Mar 7, 2022 · 5 comments · Fixed by #67714
Closed

Cyclic Autoload Singleton Plugin Bug. #58871

Multirious opened this issue Mar 7, 2022 · 5 comments · Fixed by #67714

Comments

@Multirious
Copy link

Godot version

v3.4.3.stable.official [242c05d]

System information

Windows 10

Issue description

Cannot enable plugin because autoload is not declared. Autoload is not declared because plugin is disable.

Reloading project does not help.
You have to remove all the singleton reference to temporary fix the bug.

Steps to reproduce

  1. Make a plugin.
  2. Create a singleton script and add to plugin.
  3. Create any script that reference to that singleton and add to plugin.
  4. Disable the plugin and reload project.
  5. Try to enable the plugin and now you can't until you remove that reference.

Minimal reproduction project

Cyclic Autoload Singleton Plugin Bug.zip

@Calinou
Copy link
Member

Calinou commented Mar 7, 2022

Related to #36001, #32165 and #21461. This probably can't be fixed until Godot 4.0.

@koodikulma-fi
Copy link

koodikulma-fi commented Nov 13, 2022

Ran into this or similar problem in Godot 4.0.beta4 (on Win 11). Here's some more info:

Steps

  1. Have a singleton, eg. MyGlobal.
  2. Make that singleton preload another class, eg. MySubGlobal (with some static funcs).
  3. Refer from that sub-singleton (MySubGlobal) back to the main singleton (MyGlobal).
  4. It works fine on the editor (including typing), but press F6 and there's a crash while parsing. (This worked still in v3.5.)

Pics

image

image

Extra notes

  • The error is triggered if MyGlobal is present in a sub script - but only on game side.
  • You can try to work around it, by eg. using another singleton to get the MyGlobal singleton, it will work:
    • For example, make a new singleton called Empty (with empty Node based script), and use Empty.get_parent().get_node("MyGlobal") in place of MyGlobal. It will work.
    • However. In a more complex project, this simple "hack ref" will tremendously increase the Godot start up time. Without that hack (using MyGlobal directly), the project loads up in about 10 seconds. Using the above Empty hack ref technique, the start up time goes up to about 45-50 seconds..!
      • Note. Also tested the hack without another singleton by: Engine.get_main_loop().get_first_node_in_group("MyGlobalSingleton") (with the singleton being added to "MyGlobalSingleton" group). However, the performance jumps up just the same. --> It seems having the singleton keyword (MyGlobal) in a sub script causes a crash on the game side, but makes loading up much faster on editor side..!
      • Note. I also noticed that preloading sub portions (like MySubGlobal) from other sub portions increases startup loading time - so that's why switched back to using the MyGlobal ref.
  • Note that using var MySubGlobal = load(...) if Engine.is_editor_hint() else null will also work. (But then you lose all that precious typing that comes with const preload.)
  • This could potentially be solved by Fix cyclic references in GDScript 2.0 #67714

Min. project

SingletonSelfRef.zip

@adamscott
Copy link
Member

adamscott commented Nov 15, 2022

@takaturre I tested your MRP and it worked flawlessly on my PR #67714.

@akien-mga akien-mga added this to the 4.0 milestone Nov 15, 2022
@koodikulma-fi
Copy link

koodikulma-fi commented Nov 19, 2022

Tested both MRP's in v4.0.beta5. The original MRP works, but there's still a compilation error when pressing F6 on the SingletonSelfRef MRP (the problem seems exactly like it was).

If I understood correctly, #67714 has been merged into beta5, and @adamscott did test this mrp before merge. ... So did something else break it? (And also, should this latter be another issue, since the original mrp works fine?)

@akien-mga
Copy link
Member

If I understood correctly, #67714 has been merged into beta5, and @adamscott did test this mrp before merge. ... So did something else break it?

This PR was merged 11 hours ago. Beta 5 was released 2 days prior, so it doesn't include it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment