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

Engine freezes when calling Sprite.new() from joy_connection_changed callback #78531

Closed
Minimuino opened this issue Jun 21, 2023 · 2 comments · Fixed by #80432
Closed

Engine freezes when calling Sprite.new() from joy_connection_changed callback #78531

Minimuino opened this issue Jun 21, 2023 · 2 comments · Fixed by #80432

Comments

@Minimuino
Copy link

Godot version

v3.5.stable.official [991bb6a]

System information

Debian 11 - Intel Ivybridge Mobile - GLES3

Issue description

Pretty much what the title says, the engine freezes when I call Sprite.new() from a method that I previously connected to joy_connection_changed signal. No errors are shown.

Steps to reproduce

  1. Run the minimal reproduction project, you will see the Godot icon moving around.
  2. Connect or disconnect a gamepad and you will see the icon stops moving due to engine freeze.

Minimal reproduction project

minimal-reproduction-project.zip

@rsubtil
Copy link
Contributor

rsubtil commented Aug 8, 2023

I recall having a similar issue on my addon, which required a hack to bypass (waiting a frame):
https://github.com/rsubtil/controller_icons/blob/db639c0288e3992c6f861b4f91041adfb5a2e2f4/addons/controller_icons/ControllerIcons.gd#L102-L111
This happened on Godot 3, but I never tested if it still happens on Godot 4. I can try to see what's going on.

In the meantime, to prevent this, you can yield for a frame:

func _on_joy_connection_changed(device, connected):
    yield(get_tree(), "idle_frame")
    # Now run your code, it should not freeze anymore

@Minimuino
Copy link
Author

@rsubtil Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants