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

Editor freezes when reimporting glb if mesh has a shader material that contains an #include #94586

Closed
timoohr opened this issue Jul 21, 2024 · 3 comments · Fixed by #94910
Closed

Comments

@timoohr
Copy link

timoohr commented Jul 21, 2024

Tested versions

  • Reproducible in v4.3.beta3.official [82cedc8]
  • Reproducible in v4.3.beta1.official [a4f2ea9]
  • Not reproducible in v4.2.2.stable.official [15073af]

System information

Godot v4.3.beta3 - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 Ti (NVIDIA; 31.0.15.5244) - AMD Ryzen 7 5800X3D 8-Core Processor (16 Threads)

Issue description

Noticed than when switching from v4.2 to v4.3 that my editor would freeze when trying to re-import my mesh. It shows the "(Re)Importing Assets" dialog, but it's stuck on 0% and editor would freeze, requiring me to force close it.

image

When opening the project again the import does seem to have succeeded, though.

Not sure if it's truly the root cause, but managed to pin the issue down to a single thing: having an "#include" statement in one of my shaders. Doesn't seem to matter what the included file (or the shader for that matter) contains, even an empty file would freeze the editor. Removing the import "fixes" the issue. Didn't see any useful information in the logs/console.

Steps to reproduce

  • Create new project
  • Import some glb mesh with a material set up
  • Create inherited scene from glb
  • Create shader file
  • Create shader include file
  • Include file in shader with "#include"
  • Create material from shader
  • Assign material via material override to mesh in inherited scene
  • Try and reimport glb file
  • Editor freezes

Or in the MRP:

  • Open project
  • Open import panel for cube.glb
  • Click "reimport"
  • Editor freezes

Commenting out the #include "util.gdshaderinc" in line 3 in new_shader.gdshader will stop the editor from freezing.

Minimal reproduction project (MRP)

mrp.zip

@akien-mga
Copy link
Member

I can reproduce the freeze in the latest master branch on Linux (e25f3c0). Here's what the stack trace looks like when interrupting the frozen process with gdb:

Thread 1 "godot-git" received signal SIGINT, Interrupt.
0x00007fb8c5b0de40 in __lll_lock_wait () from /lib64/libc.so.6
(gdb) bt
#0  0x00007fb8c5b0de40 in __lll_lock_wait () from /lib64/libc.so.6
#1  0x00007fb8c5b14b01 in pthread_mutex_lock@@GLIBC_2.2.5 () from /lib64/libc.so.6
#2  0x0000000005c3176f in __gthread_mutex_lock (__mutex=0xb17a480 <ResourceLoader::thread_load_mutex>) at /usr/include/c++/14/x86_64-redhat-linux/bits/gthr-default.h:762
#3  0x0000000005c317c0 in std::mutex::lock (this=0xb17a480 <ResourceLoader::thread_load_mutex>) at /usr/include/c++/14/bits/std_mutex.h:113
#4  0x00000000062c0b19 in std::unique_lock<std::mutex>::lock (this=0x7ffc90b65d20) at /usr/include/c++/14/bits/unique_lock.h:147
#5  0x0000000006282d39 in std::unique_lock<std::mutex>::unique_lock (this=0x7ffc90b65d20, __m=...) at /usr/include/c++/14/bits/unique_lock.h:73
#6  0x000000000a75dfaa in MutexLock<SafeBinaryMutex<1> >::MutexLock (this=<optimized out>, p_mutex=...) at ./core/os/safe_binary_mutex.h:100
#7  ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_REUSE) at ./core/io/resource_loader.cpp:466
#8  0x000000000a75de7f in ResourceLoader::load (p_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_REUSE, r_error=0x0) at ./core/io/resource_loader.cpp:444
#9  0x0000000009e0975c in ShaderPreprocessor::process_include (this=0x7ffc90b664e0, p_tokenizer=0x7ffc90b66130) at ./servers/rendering/shader_preprocessor.cpp:694
#10 0x0000000009e079c6 in ShaderPreprocessor::process_directive (this=0x7ffc90b664e0, p_tokenizer=0x7ffc90b66130) at ./servers/rendering/shader_preprocessor.cpp:401
#11 0x0000000009e0c3d7 in ShaderPreprocessor::preprocess (this=0x7ffc90b664e0, p_state=0x7ffc90b66300, p_code=..., r_result=...) at ./servers/rendering/shader_preprocessor.cpp:1271
#12 0x0000000009e0c692 in ShaderPreprocessor::preprocess (this=0x7ffc90b664e0, p_code=..., p_filename=..., r_result=..., r_error_text=0x0, r_error_position=0x0, r_regions=0x0, r_includes=0x7ffc90b66490, 
    r_completion_options=0x0, r_completion_defines=0x0, p_include_completion_func=0x0) at ./servers/rendering/shader_preprocessor.cpp:1310
#13 0x00000000093545d3 in Shader::set_code (this=0x376333a0, p_code=...) at ./scene/resources/shader.cpp:90
#14 0x000000000688ae35 in call_with_variant_args_helper<__UnexistingClass, String const&, 0ul> (p_instance=0x376333a0, 
    p_method=(void (__UnexistingClass::*)(class __UnexistingClass * const, const class String &)) 0x93543ee <Shader::set_code(String const&)>, p_args=0x7ffc90b66658, r_error=...)
    at ./core/variant/binder_common.h:304
#15 0x00000000068888ac in call_with_variant_args_dv<__UnexistingClass, String const&> (p_instance=0x376333a0, 
    p_method=(void (__UnexistingClass::*)(class __UnexistingClass * const, const class String &)) 0x93543ee <Shader::set_code(String const&)>, p_args=0x7ffc90b66728, p_argcount=1, r_error=..., 
    default_values=...) at ./core/variant/binder_common.h:451
#16 0x0000000006883b5f in MethodBindT<String const&>::call (this=0x21631450, p_object=0x376333a0, p_args=0x7ffc90b66728, p_arg_count=1, r_error=...) at ./core/object/method_bind.h:345
#17 0x000000000abd29dc in ClassDB::set_property (p_object=0x376333a0, p_property=..., p_value=..., r_valid=0x0) at ./core/object/class_db.cpp:1515
#18 0x000000000abdb76a in Object::set (this=0x376333a0, p_name=..., p_value=..., r_valid=0x0) at ./core/object/object.cpp:249
--Type <RET> for more, q to quit, c to continue without paging--
#19 0x000000000a744a52 in Resource::copy_from (this=0x376333a0, p_resource=...) at ./core/io/resource.cpp:212
#20 0x000000000a75d6f5 in ResourceLoader::_thread_load_function (p_userdata=0x33f7c0b8) at ./core/io/resource_loader.cpp:354
#21 0x000000000a75e3ce in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP)
    at ./core/io/resource_loader.cpp:526
#22 0x00000000093447d5 in ResourceLoaderText::load (this=0x7ffc90b67520) at ./scene/resources/resource_format_text.cpp:472
#23 0x000000000934d6f3 in ResourceFormatLoaderText::load (this=0x211ffbd0, p_path=..., p_original_path=..., r_error=0x7ffc90b69864, p_use_sub_threads=false, r_progress=0x3b332028, 
    p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP) at ./scene/resources/resource_format_text.cpp:1392
#24 0x000000000a75ce4f in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP, r_error=0x7ffc90b69864, p_use_sub_threads=false, 
    r_progress=0x3b332028) at ./core/io/resource_loader.cpp:269
#25 0x000000000a75d4ec in ResourceLoader::_thread_load_function (p_userdata=0x3b331fe8) at ./core/io/resource_loader.cpp:323
#26 0x000000000a75e3ce in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP)
    at ./core/io/resource_loader.cpp:526
#27 0x00000000093447d5 in ResourceLoaderText::load (this=0x7ffc90b6a420) at ./scene/resources/resource_format_text.cpp:472
#28 0x000000000934d6f3 in ResourceFormatLoaderText::load (this=0x211ffbd0, p_path=..., p_original_path=..., r_error=0x7ffc90b6c764, p_use_sub_threads=false, r_progress=0x3aefeda8, 
    p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP) at ./scene/resources/resource_format_text.cpp:1392
#29 0x000000000a75ce4f in ResourceLoader::_load (p_path=..., p_original_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP, r_error=0x7ffc90b6c764, p_use_sub_threads=false, 
    r_progress=0x3aefeda8) at ./core/io/resource_loader.cpp:269
#30 0x000000000a75d4ec in ResourceLoader::_thread_load_function (p_userdata=0x3aefed68) at ./core/io/resource_loader.cpp:323
#31 0x000000000a75e3ce in ResourceLoader::_load_start (p_path=..., p_type_hint=..., p_thread_mode=ResourceLoader::LOAD_THREAD_FROM_CURRENT, p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP)
    at ./core/io/resource_loader.cpp:526
#32 0x000000000a75de7f in ResourceLoader::load (p_path=..., p_type_hint=..., p_cache_mode=ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP, r_error=0x7ffc90b6ccc4) at ./core/io/resource_loader.cpp:444
#33 0x000000000796a738 in EditorNode::reload_instances_with_path_in_edited_scenes (this=0x22072960, p_instance_path=...) at ./editor/editor_node.cpp:5998
#34 0x0000000007945d9c in EditorNode::_resources_reimported (this=0x22072960, p_resources=...) at ./editor/editor_node.cpp:1083
#35 0x0000000007b203c9 in call_with_variant_args_helper<EditorNode, Vector<String> const&, 0ul> (p_instance=0x22072960, 
--Type <RET> for more, q to quit, c to continue without paging--c
    p_method=(void (EditorNode::*)(class EditorNode * const, const class Vector<String> &)) 0x7945b7e <EditorNode::_resources_reimported(Vector<String> const&)>, p_args=0x7ffc90b6d4b0, r_error=...)
    at ./core/variant/binder_common.h:304
#36 0x0000000007b14609 in call_with_variant_args<EditorNode, Vector<String> const&> (p_instance=0x22072960, 
    p_method=(void (EditorNode::*)(class EditorNode * const, const class Vector<String> &)) 0x7945b7e <EditorNode::_resources_reimported(Vector<String> const&)>, p_args=0x7ffc90b6d4b0, p_argcount=1, 
    r_error=...) at ./core/variant/binder_common.h:418
#37 0x0000000007b07ac4 in CallableCustomMethodPointer<EditorNode, Vector<String> const&>::call (this=0x31a204d0, p_arguments=0x7ffc90b6d4b0, p_argcount=1, r_return_value=..., r_call_error=...)
    at ./core/object/callable_method_pointer.h:103
#38 0x000000000a8a3b93 in Callable::callp (this=0x7ffc90b6d280, p_arguments=0x7ffc90b6d4b0, p_argcount=1, r_return_value=..., r_call_error=...) at ./core/variant/callable.cpp:57
#39 0x000000000abdf937 in Object::emit_signalp (this=0x220de490, p_name=..., p_args=0x7ffc90b6d4b0, p_argcount=1) at ./core/object/object.cpp:1187
#40 0x00000000086e7772 in Node::emit_signalp (this=0x220de490, p_name=..., p_args=0x7ffc90b6d4b0, p_argcount=1) at ./scene/main/node.cpp:3895
#41 0x000000000782ea9c in Object::emit_signal<Vector<String> > (this=0x220de490, p_name=...) at ./core/object/object.h:936
#42 0x00000000077696fc in EditorFileSystem::reimport_file_with_custom_parameters (this=0x220de490, p_file=..., p_importer=..., p_custom_params=...) at ./editor/editor_file_system.cpp:2615
#43 0x0000000007e920d4 in SceneImportSettingsDialog::_re_import (this=0x251ef980) at ./editor/import/3d/scene_import_settings.cpp:1246
#44 0x0000000007ef53af in call_with_variant_args_helper<SceneImportSettingsDialog>(SceneImportSettingsDialog*, void (SceneImportSettingsDialog::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (
    p_instance=0x251ef980, p_method=(void (SceneImportSettingsDialog::*)(class SceneImportSettingsDialog * const)) 0x7e913d2 <SceneImportSettingsDialog::_re_import()>, p_args=0x0, r_error=...)
    at ./core/variant/binder_common.h:304
#45 0x0000000007ef49ad in call_with_variant_args<SceneImportSettingsDialog> (p_instance=0x251ef980, 
    p_method=(void (SceneImportSettingsDialog::*)(class SceneImportSettingsDialog * const)) 0x7e913d2 <SceneImportSettingsDialog::_re_import()>, p_args=0x0, p_argcount=0, r_error=...)
    at ./core/variant/binder_common.h:418
#46 0x0000000007ef3c74 in CallableCustomMethodPointer<SceneImportSettingsDialog>::call (this=0x37e30c10, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...)
    at ./core/object/callable_method_pointer.h:103
#47 0x000000000a8a3b93 in Callable::callp (this=0x7ffc90b6dcc0, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...) at ./core/variant/callable.cpp:57
#48 0x000000000abdf937 in Object::emit_signalp (this=0x251ef980, p_name=..., p_args=0x0, p_argcount=0) at ./core/object/object.cpp:1187
#49 0x00000000086e7772 in Node::emit_signalp (this=0x251ef980, p_name=..., p_args=0x0, p_argcount=0) at ./scene/main/node.cpp:3895
#50 0x00000000062990f1 in Object::emit_signal<>(StringName const&) (this=0x251ef980, p_name=...) at ./core/object/object.h:936
#51 0x00000000088b2eae in AcceptDialog::_ok_pressed (this=0x251ef980) at ./scene/gui/dialogs.cpp:137
#52 0x0000000008c83832 in call_with_variant_args_helper<AcceptDialog>(AcceptDialog*, void (AcceptDialog::*)(), Variant const**, Callable::CallError&, IndexSequence<>) (p_instance=0x251ef980, 
    p_method=(void (AcceptDialog::*)(class AcceptDialog * const)) 0x88b2e36 <AcceptDialog::_ok_pressed()>, p_args=0x0, r_error=...) at ./core/variant/binder_common.h:304
#53 0x0000000008c543b9 in call_with_variant_args<AcceptDialog> (p_instance=0x251ef980, p_method=(void (AcceptDialog::*)(class AcceptDialog * const)) 0x88b2e36 <AcceptDialog::_ok_pressed()>, p_args=0x0, 
    p_argcount=0, r_error=...) at ./core/variant/binder_common.h:418
#54 0x0000000008c1ee0e in CallableCustomMethodPointer<AcceptDialog>::call (this=0x251ff210, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...) at ./core/object/callable_method_pointer.h:103
#55 0x000000000a8a3b93 in Callable::callp (this=0x7ffc90b6e1f0, p_arguments=0x0, p_argcount=0, r_return_value=..., r_call_error=...) at ./core/variant/callable.cpp:57
#56 0x000000000abdf937 in Object::emit_signalp (this=0x251f9f00, p_name=..., p_args=0x0, p_argcount=0) at ./core/object/object.cpp:1187
#57 0x00000000086e7772 in Node::emit_signalp (this=0x251f9f00, p_name=..., p_args=0x0, p_argcount=0) at ./scene/main/node.cpp:3895
#58 0x00000000062990f1 in Object::emit_signal<>(StringName const&) (this=0x251f9f00, p_name=...) at ./core/object/object.h:936
#59 0x0000000008840118 in BaseButton::_pressed (this=0x251f9f00) at ./scene/gui/base_button.cpp:137
#60 0x00000000088404e1 in BaseButton::on_action_event (this=0x251f9f00, p_event=...) at ./scene/gui/base_button.cpp:171
#61 0x000000000883fe7d in BaseButton::gui_input (this=0x251f9f00, p_event=...) at ./scene/gui/base_button.cpp:68
#62 0x0000000008899717 in Control::_call_gui_input (this=0x251f9f00, p_event=...) at ./scene/gui/control.cpp:1830
#63 0x0000000008703dd7 in Viewport::_gui_call_input (this=0x251ef980, p_control=0x251f9f00, p_input=...) at ./scene/main/viewport.cpp:1567
#64 0x0000000008705050 in Viewport::_gui_input_event (this=0x251ef980, p_event=...) at ./scene/main/viewport.cpp:1836
#65 0x000000000870ca54 in Viewport::push_input (this=0x251ef980, p_event=..., p_local_coords=false) at ./scene/main/viewport.cpp:3258
#66 0x0000000008732717 in Window::_window_input (this=0x251ef980, p_ev=...) at ./scene/main/window.cpp:1690
#67 0x00000000088394d2 in call_with_variant_args_helper<Window, Ref<InputEvent> const&, 0ul> (p_instance=0x251ef980, 
    p_method=(void (Window::*)(class Window * const, const class Ref<InputEvent> &)) 0x87321bc <Window::_window_input(Ref<InputEvent> const&)>, p_args=0x7ffc90b714a0, r_error=...)
    at ./core/variant/binder_common.h:304
#68 0x000000000881bafc in call_with_variant_args<Window, Ref<InputEvent> const&> (p_instance=0x251ef980, 
    p_method=(void (Window::*)(class Window * const, const class Ref<InputEvent> &)) 0x87321bc <Window::_window_input(Ref<InputEvent> const&)>, p_args=0x7ffc90b714a0, p_argcount=1, r_error=...)
    at ./core/variant/binder_common.h:418
#69 0x00000000087fa4f6 in CallableCustomMethodPointer<Window, Ref<InputEvent> const&>::call (this=0x251f2d20, p_arguments=0x7ffc90b714a0, p_argcount=1, r_return_value=..., r_call_error=...)
    at ./core/object/callable_method_pointer.h:103
#70 0x000000000a8a3b93 in Callable::callp (this=0x7ffc90b71540, p_arguments=0x7ffc90b714a0, p_argcount=1, r_return_value=..., r_call_error=...) at ./core/variant/callable.cpp:57
#71 0x0000000005b7b7cb in Callable::call<Ref<InputEvent> > (this=0x7ffc90b71540) at ./core/variant/variant.h:875
#72 0x0000000005b671ad in DisplayServerX11::_dispatch_input_event (this=0x1fba6530, p_event=...) at platform/linuxbsd/x11/display_server_x11.cpp:4058
#73 0x0000000005b66f37 in DisplayServerX11::_dispatch_input_events (p_event=...) at platform/linuxbsd/x11/display_server_x11.cpp:4034
#74 0x000000000a83ff5d in Input::_parse_input_event_impl (this=0x1f69c2d0, p_event=..., p_is_emulated=false) at ./core/input/input.cpp:774
#75 0x000000000a8412a6 in Input::flush_buffered_events (this=0x1f69c2d0) at ./core/input/input.cpp:1055
#76 0x0000000005b6c088 in DisplayServerX11::process_events (this=0x1fba6530) at platform/linuxbsd/x11/display_server_x11.cpp:5177
#77 0x0000000005b43676 in OS_LinuxBSD::run (this=0x7ffc90b71f00) at platform/linuxbsd/os_linuxbsd.cpp:958
#78 0x0000000005b3beb1 in main (argc=2, argv=0x7ffc90b72568) at platform/linuxbsd/godot_linuxbsd.cpp:85

@akien-mga akien-mga moved this from Bad to Very Bad in 4.x Release Blockers Jul 22, 2024
@akien-mga
Copy link
Member

The regression seems to have been introduced in 4.3.beta1, I can't reproduce it in 4.3.dev6 or earlier, but it's present from 4.3.beta1 onwards.

Note that to reproduce the bug, the cube.tscn file must be opened in the 3D viewport.

I bisected the regression to 846bafd / #92279, CC @SaracenOne.

Note that in commits older than the merge of #92279, I see this error when reimporting the cube.glb. This error was indeed fixed by #92279.

ERROR: Attempt to disconnect a nonexistent connection from 'cube:<Node3D#1769140711361>'. Signal: 'replacing_by', callable: 'EditorNode::set_edited_scene'.
   at: _disconnect (./core/object/object.cpp:1490)

@fire
Copy link
Member

fire commented Jul 22, 2024

The ai assistant said the program is freezing due to a deadlock while trying to acquire a mutex lock. The issue seems to be related to the ResourceLoader and its interaction with the ShaderPreprocessor.

@RandomShaper Maybe you have some ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Very Bad
Development

Successfully merging a pull request may close this issue.

5 participants