-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
When removing a TileMap node (or its parent), remove_child method sometimes causes a crash. #22589
Comments
Have you tried removing it on |
Thanks for the suggestion. If you mean doing |
Do you have an example project of the crash? Removing children shouldn't cause a crash in most cases unless other systems require it as a dependency. |
Are there any messages when it crashes? |
I'm so sorry, I have to rebuild that situation to do further checks. Will be back later with more info. Thanks! |
Okay. I don't have a project yet to share (have to separate the case from the other systems). But here is some error reports (quite new to Godot, please bear that in mind) :
... So possibly some Area2D node has problems when inside a child to be removed..? The child is a relatively complex scene (~ a small place in a 2D world). Edit: If I remove all the nested nodes individually (recursively), I do not get the Debugger's part of the error - only the "Server disconnected!" error and the crash. |
And rechecked that "idle_frame" thing. So, was like I said: the crashes happen less frequently when using ... Just thought that maybe this is related to Area2D still having an area entered inside.. ? Because an Area2D area_entered signal is the trigger for the whole process, and when the switching happens the character is still inside this area (due to game logic). ... Will try some checks related to this now. Edit: Sorry about to close/open thing and unfinished message. The browser was being funky. |
Sounds like the game is looking for a collision check with a Node that isn't there. |
Okay, thanks. Any ideas what to do about it? At this point, I'm not sure whether this is a bug or my misuse of the engine (tho queue_free works without any problems). Trying to rebuild a simplified scene, but so far no errors. |
Did some further tests:
However, in conclusion, I think this is a bug, and it's related to |
Could this be an issue with the physicsserver not updating emmediately when the node is removed from the tree? For example the Physicsserver doesn't update emmediately when setting the position of a node #20107 |
Thanks for the comment. I initially tried waiting several idle_frames (and tried a timer too), because thought it would be something like this, but made no difference. (One idle_frame makes a difference tho, see above.) Edit Sorry, misread your answer. You probably didnt' mean this. ... As far as I know, It could be that the physics server is being lazy - however, I have no idea what to do about it. More info: Also found out that the second error (that Area2D thing) is perhaps not related. After switching from queue_free to remove_child approach, I now get that error all the time (no crash). Found this q&a saying it's probably a harmless error. |
I have the same issue. It happens when a a kinematicbody2d with a collision area is overlapping another area and then I try to remove it from there scene with get_tree().current_scene.remove_child(kinematicbody2d_node). It doesn't crash my game, just prints an error. My current hack-around is to move the object inside a _physics_process so that it isn't overlapping the area and only then remove it from the scene. Its quite a hack and is quite annoying to deal with. |
Can anyone still reproduce this bug in Godot 3.2.3 rc2 or any later release? If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop. |
Closing due to lack of update. Please comment if you can still reproduce this issue in the latest stable version of Godot. |
I am running into this problems on version Godot v3.2.3. My use case is very similar my player is a kinematicbody2d and on the body_entered of my area2d pickup I am trying to remove_child which causes a crash. |
@EricWRogers Can you provide a minimal reproduction project for the issue? |
I can reprocude the error.
Also did it successfully in a minimal reproduction project: Edit: Updated Project with more debug prints. The Project consists of:
I'm unsure here if the navigation node is needed and was just rebuilding it from my project where I encounter this error. The player will The player passes the first one and the Object disappears. When hitting the last one the application crashes. Even former debug prints will be obmitted. Please tell me, if and how I can provide more detailed logs, if needed :) |
I guess it is caued by wrong usage due to area entered/exited events and using In the debugger I got this error, which lead me to #21459 and https://godotengine.org/qa/1754/how-to-change-the-parent-of-a-node-from-gdscript suggestion to use
Do I understand it correctly that it crash because my second Node is still waiting for the ground to exit again and locked ? Can't we always call Lines 1286 to 1294 in 4e52b84
Edit: Unfortunately it crashes the editor. Any idea if the concept is reasonable ? |
Bug seems to be closed in version 4e52b84 Compiled it with my system described #22589 (comment) and updated the project's script to newer version: If anyone can confirm this, I guess the bug and be closed again ? |
I've just seen this very bug with v3.4.stable.official [206ba70]
Interesting right after that I had its opposite too:
In my case it has nothing to do with collisions or physics. I'm working on game that has a generic purpose dialog scene, using Control-derived nodes only. When the errors happened, the dialog content was updated, which first clears any old content (which can be a list of custom scenes, or just a single RichTextLabel), then adds the new content (again, this can be a list of custom scenes or a RichTextLabel). |
Edit:
This comment is outdated / misleading. The core issue is TileMaps and physics processing - see below.
Issue:
I have a situation where I need to switch a node between being "active" and "inactive" - so that when inactive (or disabled) its script and processes etc. stop running. However, using
remove_child()
will (almost always) cause the whole game/engine to crash (at least on Win10) - tried usingcall_deferred
,set_process_internal(false)
and waiting some idle_frames too. Usingqueue_free()
, there will not be a crash but the node cannot be added back to the tree (because it's not in memory anymore).Workaround hacks:
Suggestion:
I think either of the below two suggestions would fix this "problem":
queue_remove_child()
or similar method - would function likequeue_free()
but only removes from the tree, not from memory.disable_node()
method, which would stop the scripts and processes etc. from running - or at least so, that remove_child could be called without crash after this. ... Or maybe acall_queued()
method..? (I know "disabling node" has been discussed - but didn't found a solution in the discussions that would work in my case.)The text was updated successfully, but these errors were encountered: