-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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
Prevent infinite recursion in first _draw
#97328
Conversation
What seems to be happening here is that:
If you remove the |
Unsure if this can be triggered in 4.2 but adding a cherry pick for it as the fix is limited in scope Unsure if there's any weird behavior triggered by this same code in 3.x (it was added back before Godot was open source) but can make a dedicated fix for it if desired to eliminate any potential issues there too (don't have a 3.x setup to test myself right now) |
The simplicity of this fix has me wonder if doing it this way has any unforeseen consequences. |
I've dug through and tested various cases, the |
What is current status of this PR ? |
It's awaiting review, it works well but needs some decision from the core team |
4131cfa
to
b6ece7f
Compare
The PR itself makes sense to me. But I am a little skeptical seeing as the behaviour changed between 4.2 and 4.3, but the code this PR changes hasn't been touched in many years. I suspect that it would be best to solve this bug in the spot that introduced the regression otherwise we will be risking breaking other untested code paths in subtle ways |
I agree, will look at pinpointing what changed and see if any changes to this fix are needed |
I have an alternative solution and will push momentarily, will keep the current fix for a potential follow-up fix if we can confirm the changes are safe to future proof this code |
b6ece7f
to
d7aae88
Compare
d7aae88
to
ff6eea5
Compare
Re-confirming this still fixes the linked bugs but this should be a conservative fix still resolving the problem Edit: Confirmed, they all now work correctly |
Great work tracking that down! This indeed seems like a much safer change to make. Pinging @YeldhamDev to confirm that the translation stuff still looks good |
Thanks! |
Thank you! |
Caused by size changes fired in some cases, mainly by auto-translation, and due to that
_redraw_callback
is called from a flush causing any queued methods to be fired immediately.Addedpending_update = false;
to the_exit_canvas
method to ensure things behave reasonably in some edge cases like changing theworld_2d
or reparentingself
during_draw
which would otherwise never fire a redraw. This is not really reasonable use but I feel it's good to not introduce weird behavior in these cases.The underlying cause here seems to be that when entering the tree a bunch of different calls are made including several that unconditionally resize the node. These are likely inefficient and could be improved but this offers a fix that ensures things behave reasonably in these cases.So I'd say this is a functional fix, we can look at reducing unnecessary calls toqueue_redraw
and resizing calls on entering the tree etc. (it happens in things likeNOTIFY_TRANSLATION_CHANGED
and a bunch of others) but this should ensure things run smoothly.New fix, this fix avoids complex changes by deferring the translation notification, need confirmation that this won't break translation but in my testing it works with localization, and doesn't break.
MRP for testing:
recursive_draw.zip
_draw()
function an infinite number of times #95709