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

Control nodes multiply in size when child animationPlayer contains RESET track and a different scene is launched #90079

Closed
Voidraizer opened this issue Mar 31, 2024 · 12 comments · Fixed by #91495

Comments

@Voidraizer
Copy link

Voidraizer commented Mar 31, 2024

Tested versions

  • Reproducible in Godot Engine v4.2.stable.mono.official [46dc277]

Bugsquad edited:

  • Reproducible in Godot Engine v4.2.stable
  • Reproducible in Godot Engine v4.1.stable
  • Reproducible in Godot Engine v4.0.stable

System information

Godot v4.2.stable.mono - Windows 10.0.19045 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 3090 Ti (NVIDIA; 31.0.15.5186) - 12th Gen Intel(R) Core(TM) i9-12900K (24 Threads)

Issue description

Certain conditions cause nodes to erroneously change size. When this happens, each time the steps are reproduced, the relevant nodes will increase in size by a multiple of the original size - i.e. the first time they will end up 2x the original, then 3x, then 4x and so on.

Steps to reproduce

The hierarchy looks like this where you have containers that structure the UI, an empty control node as a child to the container, and the another kind of node as a child of the empty control node. This last child also has an AnimationPlayer with a RESET track. This is to allow the other kind of node to be animated. Finally, set the control node and its child to use the anchor layout mode with the anchor preset set to Full Rect. I have tested this with Buttons, Labels, and LineEdits.

All of the above needs to be in 1 scene. Then while that scene is open in one tab, open a different scene in another tab and use Run Current Scene so the different scene is launched. You can immediately close that and go back to the original tab. In my example, this is what it would have started looking like and this is how it will end up. The new size of that node will be exactly 2x the starting size. If you repeat the process and launch the different scene again and come back, the node will now be 3x the starting size.

I recorded a video of this occurring, but I don't know how long it will remain available: https://streamable.com/5elh96.

Minimal reproduction project (MRP)

NodeSizeBug.zip

Simply open both the main and different scenes so there are 2 tabs open. Launch the different scene with F6, then kill it. Go back to the main tab and the button should be a multiple bigger.

@Voidraizer
Copy link
Author

I forgot to include - Deleting the RESET track from the AnimationPlayer fixes the issue and nodes will no longer grow in size.

@TokageItLab
Copy link
Member

I assume it is a bug in reset_on_save. It seems like unintended behavior is occurring in the case of saving a background scene.

@Borges-IST-2003
Copy link

Is there anyone already working to fix this?
I wanted to fix it.

@TokageItLab
Copy link
Member

TokageItLab commented Apr 1, 2024

@Borges-IST-2003 The challenge to fix it is welcome, but please work with attention to the following:

I think the easiest way to fix this is probably to insert some notifications in the editor_node.cpp, on the line immediately after the AnimationMixer reset/restore call. However, that forced process could cause values different from the key values of the reset animation may be stored in .tres, and we need to make sure that does not happen.

But before doing so, we need to investigate if there are any other Nodes that have this same bug.

If no other Node seems to have the same bug, then it is likely that the problem is specific to Button, and you may need to fix the update process of Button::_notification().

If there are other Nodes that have the same bug, we need to figure out how to handle it correctly in editor_node.cpp or AnimationMixer. In other words, the scope of the fix needs to be clear. If all Control Nodes have the same bug and Node2D does not, then only the Control Nodes need to be treated in some way; Maybe Button and Control need some processing in the NOTIFICATION_EDITOR_POST_SAVE notification as Skeleton2D does.

In any case, this is a bug that needs to be fixed, and if no one (even you) has made any progress by next week, I will get to work on. If you send a PR by about the first of next week, I will review it.

@Borges-IST-2003
Copy link

Ok, sounds good, I'll get on it.

@KoBeWi
Copy link
Member

KoBeWi commented Apr 1, 2024

Duplicate of #74047 btw.

@Borges-IST-2003
Copy link

I just found out a similar bug!
I have 3 scenes, a main with quit and start button. A "world" with a couple colision shapes, a pannel, a "go back" button and a player that I create in the third scene.
When I run the code and Im not in the world scene a duplicate of the player and a duplicate of the pannel are generated.
Could this be related to the issue?

@KoBeWi
Copy link
Member

KoBeWi commented Apr 2, 2024

No, that's #89877

@Borges-IST-2003
Copy link

Ok, I believe that the bug is specific to the button because I have tried to replicate the bug with other control nodes but couldn't.
I'm having some dificulty locating where is the problem tho, because when the button is saved the correct size is stored, the problem is when the scene gets reloaded, that seems to be when the size is wrongly adjusted.
Any adivice on how to proceed?
Thanks

@TokageItLab
Copy link
Member

TokageItLab commented Apr 4, 2024

I guess this is probably due to the fact that the automatic size adjustment is done at the next frame or at the Draw frame, since the scene in the other tab is not drawn. So we need to identify the row that do resizing and move it to a place where it will work on reload while in another tab.

@Borges-IST-2003
Copy link

At the draw frame the button has already the wrong value, but if I render it again, on NOTIFICATION_EDITOR_POST_SAVE, the button has the original values, it is somewhere between save and draw that the value gets changed it seems, but then it gets changed again back to the original value when I try to run the scene again, and then it gets the wrong value on draw.

@TokageItLab
Copy link
Member

TokageItLab commented Apr 5, 2024

Probably, this is a problem with the Control node, not just the Button.
Reset animation contains a position value, and the behavior of the bug differs depending on the Anchor mode. If you look at Control::set_position(), there are several update methods in it, but perhaps something in it is not working in the hidden tab and is causing it to update to the wrong value.

Poobslag added a commit to Poobslag/turbofat that referenced this issue Sep 30, 2024
Workaround for Godot #90079 (godotengine/godot#90079).

Godot has an exciting feature where Controls animated by an AnimationPlayer
randomly change their position or size. This only affects the editor, and
results an exciting and fun surprise for developers.

I've added a workaround to prevent controls from randomly changing their
position and size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment