dialogic-godot / dialogic

💬 Create Dialogs, Visual Novels, RPGs, and manage Characters with Godot to create your Game!
https://dialogic.pro
MIT License
4.05k stars 239 forks source link

Dialogue sometimes fails to show after changing scenes #2487

Open CaseyWalshWarder opened 5 days ago

CaseyWalshWarder commented 5 days ago

The problem

Describe the bug When a couple lines of dialogue play and then a dialogic signal causes a scene change, if dialogue starts in the _ready function in the next scene, that dialogue sometimes fails to be shown. It appears to be a threading bug.

To Reproduce Steps to reproduce the behavior:

  1. Clone the repo from https://github.com/CaseyWalshWarder/DialogicThreadingBugReproduction and open it with Godot 4.3
  2. Run the project
  3. Click through the dialogue until the text in the upper left corner says SecondScene
  4. Sometimes, the next dialogue will be shown, and sometimes not. You may need to run the project many times to get a different result.

Expected behavior The dialogue in the second scene should always be shown.

System:

Solutions

Workaround

Rather than starting the dialogue in _ready, starting it the first time _process runs seems to avoid the issue. I don't know whether this just makes the issue more rare.

Possible fixes

When the second dialogue fails to show, the DialogicGameHandler.gd ends up in state 1 (REVEALING_TEXT), set from line 125 of subsystem_text.gd. It ends up in state 0 (IDLE) if the second dialogue shows.

As far as I can tell, the result isn't deterministic even when I click through the dialogue the same way, so I think it's a threading issue.

I was able to reproduce it on the main branch of dialogic recently.