Will Godot miss lines if you try run too many things at once?

  • Thread starter Darkmisc
  • Start date
  • Tags
    godot
  • #1
Darkmisc
204
27
TL;DR Summary
I have twelve buttons that are constantly moving. Sometimes they don't do what they are supposed to when pressed. Is it because I have too many things running simultaneously?
Hi everyone

I made a game for memorising Scrabble two-letter words. When you press a tile, it lights up and a button_on variable gets set to true. If the two tiles you press form a valid two-letter word, the tiles disappear (and get replaced with new tiles). I have 12 tiles running at any given time. The left column scrolls down and the right column scrolls up.

1702684245-931062-image.png


The game runs fine for the most part, but very occasionally when you press a pair of tiles that form a valid word, the tiles will light up but not disappear. (They will disappear if you press on the tile a second time)

I suspected it was because I was running too many functions at once, and maybe the button_on=true line gets missed. All the buttons belong to the "all_buttons" group and they all have a "word_made" function that gets called when a valid word is made. I gave each button its own group (i.e. one, two, three... twelve) and instead only called functions for two buttons whenever a word was made. This made the problem appear less frequently, but didn't eliminate it.

I also tried using physics_process instead of _process, but I'm not sure if this made any difference.

Am I correct in suspecting the problem stems from running too many things at once? I tried using only ten buttons, but that didn't eliminate the problem.

I had also labelled each button (not in screenshot) and kept a track of which pairs failed to light up. I've retried those pairs and they almost always work as intended.

Am I right in guessing that I'm running too many things at once? If so, can the problem be fixed?

Thanks
 
Technology news on Phys.org
  • #2
Darkmisc said:
Am I correct in suspecting the problem stems from running too many things at once?
That callbacks should be skipped entirely is not likely, but depending on what your are doing in your callbacks and how you implemented timed actions (GUI-thread timer or separate thread) you likely have a race conditions between button presses and timed actions. Since you say the program seems to miss clicks you may also want to look at you button enable/disable timing if you have any of those. Race conditions can in general be very subtle and difficult to pinpoint even when having the code in a debugger (because debugging usually alters the timing). The right amount of code tracing (logging when entering and leaving selected functions) may provide you with data for pinpointing the situation.

Also want to mention, that if your code firing events at a very high rate (e.g. a burst or a recursive update) you may experience a build up of events in the event queue where user interactions can get perceptively delayed.
 
  • Like
Likes Darkmisc

1. What happens if I run too many processes at once in Godot?

When you run too many processes simultaneously in Godot, the engine may experience performance issues such as lag or decreased frame rates. However, Godot's architecture is designed to handle multiple tasks efficiently using its scene tree and nodes system, which helps in managing different processes. Proper optimization and task management can mitigate most issues.

2. Can Godot miss executing some script lines if the game is overloaded?

Godot does not typically miss executing lines of script under normal circumstances. Scripts are executed in a deterministic manner. However, if the game is overloaded and experiencing significant frame drops, it might skip frames to maintain performance. This does not mean it misses script lines, but rather, it might delay execution until resources are available.

3. How does Godot handle multiple concurrent tasks in a game?

Godot handles multiple tasks using its robust scene and node system where each node can be scripted to perform specific functions independently or in coordination with other nodes. For concurrency, Godot supports threading and co-routines (yield), allowing developers to run processes in parallel or spread tasks across frames.

4. Is there a risk of data loss in Godot if too many actions are triggered at once?

There is minimal risk of data loss from triggering too many actions simultaneously, as Godot manages game states and data robustly. However, excessive load can cause performance issues. To minimize risks, it's advisable to optimize game logic and manage resource loading and processing efficiently.

5. What are the best practices to avoid overloading in Godot?

To avoid overloading in Godot, it is recommended to optimize your game by profiling and identifying bottlenecks, using efficient data structures and algorithms, managing resource loading and unloading wisely, and making use of Godot's built-in tools like threading and signals. Also, keeping your scene tree organized and avoiding unnecessary complexity in scripts can help maintain smooth performance.

Similar threads

  • Programming and Computer Science
Replies
4
Views
340
  • Programming and Computer Science
Replies
29
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
281
Replies
8
Views
2K
Replies
7
Views
2K
Replies
5
Views
1K
  • Sci-Fi Writing and World Building
Replies
9
Views
2K
Replies
3
Views
989
  • Programming and Computer Science
Replies
18
Views
5K
  • Mechanical Engineering
Replies
18
Views
2K
Back
Top