godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.36k stars 21.25k forks source link

3D scenes crash when running, intermittently #97847

Open JetPoweredGaming opened 1 month ago

JetPoweredGaming commented 1 month ago

Tested versions

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

anvilfolk commented 1 month ago

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!

TokageItLab commented 1 month ago

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.

GustJc commented 1 month ago

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.

JetPoweredGaming commented 1 month ago

@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.