defold / defold/defold

With shared state enabled, gui_script's fixed_update is called, and in fixed_update "#" posts to the GO's script instead of the gui_script

Open
#8,524 4 comments 0 reactions 0 assignees View on GitHub
bug engine
Dominant language
C++
Stars
6.3k
Forks
455
Avg merge
2d 2h
Merged PRs (30d)
129

Description

**Describe the bug (REQUIRED)**
With project setting `script.shared_state = 1`, if a gui_script has a `fixed_update` function, it will be called. Neither the [manual](https://defold.com/manuals/gui-script/) or [API docs](https://defold.com/ref/stable/gui/) show `fixed_update` as a valid function for gui_script.

If the gui_script posts a message to `"#"` from `fixed_update`, it will be sent to the GO's script instead of itself. If the gui_script explicitly specifies the name of itself, e.g. `"#my_gui"`, it will be sent to itself as expected.

With two gui_scripts, A and B, the A's `fixed_update` function may get called for both A and B.

**To Reproduce (REQUIRED)**
Steps to reproduce the behavior:
1. Download this minimal repro case project and run it: https://github.com/redoak/defold-gui-fixed-update-bug
2. Notice the issue as illustrated in the console output
3. Disable shared state, rename the gui_scripts' `fixed_update` to `update`, and run it again
4. Notice that the messages now arrive at the gui_script as expected

Steps to reproduce function mix-up behavior:
1. Download this minimal repro case project and run it: https://github.com/redoak/defold-gui-fixed-update-bug-nr2
2. Notice that in the console output you end up with two `gui_script_1 fixed_update`, but that the messages posted from `fixed_update` are received by gui_script_1 and gui_script_2 as expected:
```
gui_script_1 on_message: from gui_script_1 fixed_update
gui_script_2 on_message: from gui_script_1 fixed_update
```

**Expected behavior (REQUIRED)**
The shared state setting should not affect if gui_scripts get calls to `fixed_update` — it should be called always or never. If gui_scripts should support `fixed_update`, message addressing should work as normal.

**Defold version (REQUIRED):**
- Version 1.6.3

**Platforms (REQUIRED):**
- Platforms: Windows
- OS: Windows 10
- Device: None, didn't test

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.