godot icon indicating copy to clipboard operation
godot copied to clipboard

3D scenes crash when running, intermittently

Open JetPoweredGaming opened this issue 1 year ago • 4 comments

Tested versions

  • Reproducible in v4.3.stable.official.77dcf97d8 and v4.4.dev3.mono.official.f4af8201b

System information

Godot v4.4.dev3.mono - Windows 10.0.19045 - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.6094) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 threads)

Issue description

When running or loading into 3D Scenes, the game crashes sometimes. if I run in a custom build with debug symbols I get this. Seems like it's possibly an issue with an animation tree? I have no idea how to diagnose or fix this issue.

 ================================================================
 CrashHandlerException: Program crashed
 Engine version: Godot Engine v4.3.1.rc.custom_build
 Dumping the backtrace. Please include this when reporting the bug to the project developer.
 [0] <couldn't map PC to fn name>
 [1] _CxxThrowException (D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\throw.cpp:82)
 [2] __RTDynamicCast (D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\rtti.cpp:291)
 [3] Ref<AnimationNode>::Ref<AnimationNode><AnimationRootNode> (C:\godot\godot-4.3\core\object\ref_counted.h:178)
 [4] AnimationNodeBlendSpace2D::_process (C:\godot\godot-4.3\scene\animation\animation_blend_space_2d.cpp:575)
 [5] AnimationNode::process (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:366)
 [6] AnimationNode::_pre_process (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:131)
 [7] AnimationNode::_blend_node (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:300)
 [8] AnimationNode::blend_node (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:183)
 [9] AnimationNodeStateMachinePlayback::_transition_to_next_recursive (C:\godot\godot-4.3\scene\animation\animation_node_state_machine.cpp:979)
 [10] AnimationNodeStateMachinePlayback::_process (C:\godot\godot-4.3\scene\animation\animation_node_state_machine.cpp:807)
 [11] AnimationNodeStateMachine::_process (C:\godot\godot-4.3\scene\animation\animation_node_state_machine.cpp:1622)
 [12] AnimationNode::process (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:366)
 [13] AnimationNode::_pre_process (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:131)
 [14] AnimationTree::_blend_pre_process (C:\godot\godot-4.3\scene\animation\animation_tree.cpp:642)
 [15] AnimationMixer::_process_animation (C:\godot\godot-4.3\scene\animation\animation_mixer.cpp:939)
 [16] AnimationMixer::_notification (C:\godot\godot-4.3\scene\animation\animation_mixer.cpp:2217)
 [17] AnimationMixer::_notificationv (C:\godot\godot-4.3\scene\animation\animation_mixer.h:43)
 [18] AnimationTree::_notificationv (C:\godot\godot-4.3\scene\animation\animation_tree.h:230)
 [19] Object::notification (C:\godot\godot-4.3\core\object\object.cpp:876)
 [20] SceneTree::_process_group (C:\godot\godot-4.3\scene\main\scene_tree.cpp:961)
 [21] SceneTree::_process (C:\godot\godot-4.3\scene\main\scene_tree.cpp:1034)
 [22] SceneTree::process (C:\godot\godot-4.3\scene\main\scene_tree.cpp:528)
 [23] Main::iteration (C:\godot\godot-4.3\main\main.cpp:4157)
 [24] OS_Windows::run (C:\godot\godot-4.3\platform\windows\os_windows.cpp:1658)
 [25] widechar_main (C:\godot\godot-4.3\platform\windows\godot_windows.cpp:181)
 [26] _main (C:\godot\godot-4.3\platform\windows\godot_windows.cpp:208)
 [27] main (C:\godot\godot-4.3\platform\windows\godot_windows.cpp:220)
 [28] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
 [29] <couldn't map PC to fn name>
 -- END OF BACKTRACE --
 ================================================================

Steps to reproduce

Run any 3D scene with NPC CharacterBody3D's in my project

Minimal reproduction project (MRP)

Link to my project here: https://drive.google.com/file/d/1XEsY0DzpiZ0vT8pcSUoZQ8mpA1NuxzFH/view?usp=sharing

JetPoweredGaming avatar Oct 05 '24 15:10 JetPoweredGaming

The relevant line throws the following warning for me:

image

File last modified by @TokageItLab 4 months ago, this particular line last year, also by same dev.

Can you get an MRP as opposed to a whole project? Thanks!

anvilfolk avatar Oct 05 '24 18:10 anvilfolk

The part pointed out in the comment above is indeed suspect, but I am not certain that is the cause of the problem. The attached project is too large and cannot be debugged easily, so please resend a minimally configured project that can reproduce the problem.

However, if the crashes were as frequent as description, there should be many more of the same issue reported, but not so currently. So I expect that it is a problem in special cases, such as dynamic creation of BlendSpace points, old BlendSpace information in tscn/tres, or problems with loading/instantiate timings.

TokageItLab avatar Oct 05 '24 20:10 TokageItLab

I've tested the provided project and there is something strange happening with the enemy animation tree that might be related to the crashes, its difficult to confirm.

This line animation_tree.set("parameters/Move/blend_position", Vector2((velocity.x/velocity.x), (velocity.z/velocity.z))) called on _physics_process causes 2 errors for each enemy there is in the scene. E 0:00:01:0003 blend_node: Condition "p_node.is_null()" is true. Returning: NodeTimeInfo() <C++ Source> scene/animation/animation_tree.cpp:181 @ blend_node()

My best guess is that it is something to do with a delayed initialization of animation_tree. If you add await get_tree().create_timer(0.001).timeout before calling it, the errors goes away. I've also made a counter that removes the error

# On _physics_frame
if skip > 7:
	animation_tree.set("parameters/Move/blend_position", Vector2((velocity.x/velocity.x), (velocity.z/velocity.z)))
skip += 1

Trying to update the animations in the first 6 physics frames causes the error. So its probably something to do with time, and not priority order of initialization.


I haven't had it crash on me since I've added the skip to avoid the errors, but as the crashes only happened a few times, I can't confirm if that fix was the reason or not.

---- Also, @JetPoweredGaming You should consider deleting your '.godot' folder to regenerate it. There is 250 imported music cached there which are not in the project that makes it 1GB+ in size. recreating the '.godot' folder will make its size go from 1.1GB to 93MB and can make the editor run better.

Also, in your opening_area scene, you have mistakenly made the music and ambient audio streams locals. This makes your opening scene 32MB and that is the reason it takes a couple of seconds to save/load the scene. Removing the local resourced audio files will make the opening scene size go to 0.6 MB and save/load instantly.

GustJc avatar Oct 05 '24 22:10 GustJc

@GustJc Seems like adding the delay when initializing the animation_tree is working for now. I'm going to do some more testing to see if it fixed all issues. I'm super amateur at this stuff so the helpful tips are greatly appreciated. I was wondering why my project was so bulky when I deleted all the assets I wasn't using. Thank you all! I will add on later if I'm still having the crashes, but my best guess is that fixed it.

JetPoweredGaming avatar Oct 05 '24 23:10 JetPoweredGaming

Please provide an MRP to make this easier to test and fix:

  • A small Godot project which reproduces the issue, with no unnecessary files included. Be sure to not include the .godot folder in the archive (but keep project.godot).
  • Having an MRP is very important for contributors to be able to reproduce the bug in the same way that you are experiencing it. When testing a potential fix for the issue, contributors will use the MRP to validate that the fix is working as intended.
  • Drag and drop a ZIP archive to upload it (max 10 MB). Do not select another field until the project is done uploading.
  • Note for C# users: If your issue is not C#-specific, please upload a minimal reproduction project written in GDScript. This will make it easier for contributors to reproduce the issue locally as not everyone has a .NET setup available.

AThousandShips avatar Apr 21 '25 12:04 AThousandShips

I've manage to find the game sent as the MRP still here and scrapped it to a real MRP. MRP: MRP_animation_tree_crash.zip In doing that, I have more info on the issue.

This is a really strange and very specific bug. This originally happen because the OP was passing Vector2(velocity.x/velocity.x, velocity.z/velocity.z) as a parameter. And it was getting a Vector2(nan,nan), which causes the blend_tree to either crash(without an error) or spit tons of those p_null() errors. Not sure why one or the other happens, it seems a bit random.

The strange part is that if we wait 8 frames, the crash doesn't happen anymore even if the parameter received is Vector2(nan, nan).

GustJc avatar Apr 21 '25 19:04 GustJc