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

Error on game start after just installing the addon: DialogicGameHandler.gd: Node not found: "Inputs" and "Portraits" (relative to "/root/Dialogic") #2222

Closed
hsandt opened this issue May 8, 2024 · 2 comments · Fixed by #2223
Labels
Bug 🐞 Something isn't working

Comments

@hsandt
Copy link

hsandt commented May 8, 2024

The problem

Describe the bug
Just after installing the addon, and making sure that it's enabled (you may first have to go through initial setup errors mentioned in #2221), you still get the same errors each time you start the game, in any scene, although you haven't done anything yet.

This is because the addon spawns a Dialogic node in any case, however I didn't expect it to cause errors until I actually try to play some dialogues. The runtime errors on start are:

E 0:00:00:0860 DialogicGameHandler.gd:346 @ get_subsystem(): Node not found: "Inputs" (relative to "/root/Dialogic").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1651 @ get_node()
DialogicGameHandler.gd:346 @ get_subsystem()
subsystem_text.gd:321 @ collect_text_effects()
subsystem_text.gd:390 @ _ready()
DialogicGameHandler.gd:355 @ add_subsystem()
DialogicGameHandler.gd:334 @ collect_subsystems()
DialogicGameHandler.gd:137 @ _ready()

3 times, and

E 0:00:00:0860 DialogicGameHandler.gd:346 @ get_subsystem(): Node not found: "Portraits" (relative to "/root/Dialogic").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1651 @ get_node()
DialogicGameHandler.gd:346 @ get_subsystem()
subsystem_text.gd:321 @ collect_text_effects()
subsystem_text.gd:390 @ _ready()
DialogicGameHandler.gd:355 @ add_subsystem()
DialogicGameHandler.gd:334 @ collect_subsystems()
DialogicGameHandler.gd:137 @ _ready()

1 time

I checked the Remote scene tree and Inputs and Portraits nodes are present. But using breakpoints, I see that they appear too late, after the get_node call.

To Reproduce
Steps to reproduce the behavior:

  1. Install addon and make sure it's enabled
  2. Run game from any scene
  3. See errors

Expected behavior
Inputs and Portraits nodes should be ready to avoid error

Screenshots

Errors in Debugger:

image

Remote tree when Inputs node is requested:

image

System (please complete the following information):

  • OS: Linux Ubuntu 22.04
  • Godot Version: v4.2.2.stable.official [15073afe3]
  • Dialogic Version: v2 alpha 13

Solutions

Workaround

What you tried to get the feature working

Possible fixes

I identified the issue coming from module dependency order: Text is loaded before Inputs, but Text requires the Inputs as subsystem.

I went up the call tree to identify how the order was determined:

DialogicGameHandler.collect_subsystems()
DialogicUtil.get_indexers()
DialogicUtil.listdir(path, ...)

And found out that the last method relies on native:

Error list_dir_begin()

Initializes the stream used to list all files and directories using the get_next() function, closing the currently opened stream if needed. Once the stream has been processed, it should typically be closed with list_dir_end().

Affected by include_hidden and include_navigational.

Note: The order of files and directories returned by this method is not deterministic, and can vary between operating systems. If you want a list of all files or folders sorted alphabetically, use get_files() or get_directories().

It is not deterministic and therefore my system could have an issue while other developers don't have any.

To fix this, we can:

  • make the order deterministic of dependency order
  • loads all modules in a first step, then only request their subsystems in a second phase (what we often do in games when an entity depends or affects another entity)
@Jowan-Spooner
Copy link
Collaborator

Thanks! This has been reported on discord recently too, I'll try to push a fix. We should call these in post_install() instead of ready, which works like the second option you suggested.

@Jowan-Spooner Jowan-Spooner added the Bug 🐞 Something isn't working label May 8, 2024
@hsandt
Copy link
Author

hsandt commented May 8, 2024

Thanks! This has been reported on discord recently too, I'll try to push a fix. We should call these in post_install() instead of ready, which works like the second option you suggested.

Yes, I just found post_install in the meantime and moved both collect methods there:

collect_text_effects()
collect_text_modifiers()

The second one, collect_text_modifiers(), may not trigger a bug right now, but it may later if we add a node-based modifier, so this looks safer and more consistent.

Result:

func post_install():
	dialogic.Settings.connect_to_change('text_speed', _update_user_speed)
	collect_text_effects()
	collect_text_modifiers()

func _ready():
	collect_character_names()
	dialogic.event_handled.connect(hide_next_indicators)

So it works with this workaround, and should make an easy PR! (but you can also check all occurrences of get_node in _ready methods too, if there are any)

I'm not on the Discord but I'll be notified if you update this issue.

hsandt added a commit to hsandt/lospec-jam-2-scaled-down-adventures that referenced this issue May 8, 2024
Jowan-Spooner added a commit to Jowan-Spooner/dialogic that referenced this issue May 8, 2024
@Jowan-Spooner Jowan-Spooner linked a pull request May 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants