Ericdowney / SignalVisualizer

A plugin for Godot 4.x. SignalVisualizer displays the current scene's signals and connections in a easy to read graph and tree dock.
MIT License
290 stars 7 forks source link

Signal Debugger may print signals in the wrong order #6

Open koyae opened 5 months ago

koyae commented 5 months ago

Describe the bug

If multiple signals are emitted in a single gameplay frame, they may be reflected in the Signal Debugger pane in the incorrect order (older signals can appear below newer signals).

To Reproduce

To see this behavior for yourself:

  1. Download attached file and extract to C:\projects\SignalDebugger_test_case\ or similar.
  2. Open ('Import') the project in Godot 4.1.3 Stable.
  3. Make sure the console shows no errors and that the Signal Visualizer and Signal Debugger have loaded successfully.
  4. Start the application and return your attention to the editor; there will not be visible objects in the game window.
  5. Navigate to the Signal Debugger under the main Debugger tab and choose Start.
  6. Wait a few seconds and compare the order of print-statements in the Output pane to the order of signals listed in the Signal Debugger.

Expected behavior

The Petitioner node's petition_submitted signal is the initiating signal, which in turn triggers a petition_rejected or petition_accepted response from the Approver node. This sequence is correctly reflected in the Output pane via print statements — oldest messages first, newer messages beneath, making it clear that petitions are first submitted before they are approved or rejected. Parallel output should appear in the Signal Debugger.

Actual behavior

The Signal Debugger does not preserve the signal order, at least on the machine used to test this behavior.

Example Output pane output:

Petition 1 submitted
Petition 1 accepted! Yay!
Petition 2 submitted
Petition 2 accepted! Yay!
Petition 3 submitted
Petition 3 rejected. Aww.
Petition 4 submitted
Petition 4 accepted! Yay!
Petition 5 submitted
Petition 5 rejected. Aww.
Petition 6 submitted
Petition 6 rejected. Aww.
Petition 7 submitted
Petition 7 rejected. Aww.

Example Signal Debugger pane output:

2024-02-08T24:34:11    Approver     petition_accepted
2024-02-08T24:34:11    Petitioner   petition_submitted
2024-02-08T24:34:13    Approver     petition_accepted
2024-02-08T24:34:13    Petitioner   petition_submitted
2024-02-08T24:34:15    Approver     petition_rejected
2024-02-08T24:34:15    Petitioner   petition_submitted
2024-02-08T24:34:17    Approver     petition_accepted
2024-02-08T24:34:17    Petitioner   petition_submitted
2024-02-08T24:34:19    Approver     petition_rejected
2024-02-08T24:34:19    Petitioner   petition_submitted
2024-02-08T24:34:21    Approver     petition_rejected
2024-02-08T24:34:21    Petitioner   petition_submitted
2024-02-08T24:34:23    Approver     petition_rejected
2024-02-08T24:34:23    Petitioner   petition_submitted

Desktop:

Additional context

I assume what I'm seeing is a quirk of EngineDebugger.send_message() using some kind of LIFO or other collection that won't (or may not) deliver messages in the same order they were sent. It presumably just empties this collection after some delay, dumping messages back in some non-FIFO order. This is confusing because it makes it hard to parse bursts of related signals (think dominoes) that may occur within a single frame. Knowing the exact order of signals occurring even within a single frame may be relevant to understanding bugs in game code.

A number of games developed by experienced Godot devs utilize signals every single frame to do things like update colors or animations to reflect game state. Others, like in my case, have a workflow that allows the player to attempt actions (sending a petition, in my very-dumb example here), which can then be accepted by the recipient or rejected, which in turn drives state-changes on the player object. Some of these responses will be instantaneous and simply occur within the same frame.

I wanted to highlight this issue because this is a really neat addon!

SignalDebugger_test_case.zip