godotengine / godot

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

Random errors when using `ResourceLoader.load_threaded_request()` #54151

Closed kalysti closed 2 years ago

kalysti commented 2 years ago

Godot version

4.0.dev

System information

Windows 10

Issue description

Random errors occur by using load_threaded_request (mostly on larger scenes):

USER ERROR: Creating buffers with data is forbidden during creation of a draw list
   at: RenderingDeviceVulkan::vertex_buffer_create (drivers\vulkan\rendering_device_vulkan.cpp:4014) - Condition "draw_list != nullptr && p_data.size()" is true. Returning: RID() 
 USER ERROR: Creating buffers with data is forbidden during creation of a draw list
   at: RenderingDeviceVulkan::vertex_buffer_create (drivers\vulkan\rendering_device_vulkan.cpp:4014) - Condition "draw_list != nullptr && p_data.size()" is true. Returning: RID() USER ERROR: Mono: FATAL ERROR '* Assertion at ..\mono\mini\debugger-agent.c:4175, condition !tls not met (in domain , error), ABORTING! Logfile: 'C:/Users/stefa/AppData/Roaming/Godot/mono/mono_logs/2021-10-23_14.25.03_40984.log'. at: GDMonoLog::mono_log_callback (modules\mono\mono_gd\gd_mono_log.cpp:92) - Mono: FATAL ERROR '* Assertion at ..\mono\mini\debugger-agent.c:4175, condition !tls' not met
 (in domain , error)', ABORTING! Logfile: 'C:/Users/stefa/AppData/Roaming/Godot/mono/mono_logs/2021-10-23_14.25.03_40984.log'.

Steps to reproduce

Use load_threaded_request with larger 3D Meshes/scenes. As example from my download link. In my project i call load_threaded_request from a Timer Callback. Mby that can be the issue to?

Minimal reproduction project

Here is a link to the model which e.g. regularly generates errors. Format gltf.

https://we.tl/t-igAyO10JbY

kalysti commented 2 years ago

Addition: It also crashes in smaller scenes. But more irregular.

kalysti commented 2 years ago

The important line is: USER ERROR: Creating buffers with data is forbidden during creation of a draw list

kalysti commented 2 years ago

Also get sometimes this error


================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.0.dev.mono.custom_build (b2ab5cb504cef1ffe229523d63b997d5306afce3)
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] CowData<char32_t>::_ref (C:\godot4\godot\core\templates\cowdata.h:379)
[1] CowData<char32_t>::_ref (C:\godot4\godot\core\templates\cowdata.h:379)
[2] Skeleton3D::Bone::Bone
[3] CowData<Skeleton3D::Bone>::_copy_on_write (C:\godot4\godot\core\templates\cowdata.h:252)
[4] Skeleton3D::_notification (C:\godot4\godot\scene\3d\skeleton_3d.cpp:258)
[5] Skeleton3D::_notificationv (C:\godot4\godot\scene\3d\skeleton_3d.h:68)
[6] Object::notification (C:\godot4\godot\core\object\object.cpp:843)
[7] MessageQueue::flush (C:\godot4\godot\core\object\message_queue.cpp:311)
[8] SceneTree::process (C:\godot4\godot\scene\main\scene_tree.cpp:457)
[9] Main::iteration (C:\godot4\godot\main\main.cpp:2582)
[10] OS_Windows::run (C:\godot4\godot\platform\windows\os_windows.cpp:641)
[11] widechar_main (C:\godot4\godot\platform\windows\godot_windows.cpp:163)
[12] _main (C:\godot4\godot\platform\windows\godot_windows.cpp:187)
[13] main (C:\godot4\godot\platform\windows\godot_windows.cpp:199)
[14] __scrt_common_main_seh (d:\a01\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[15] BaseThreadInitThunk
-- END OF BACKTRACE --
================================================================```
kalysti commented 2 years ago

The loading are working inside the generation of the draw list. So the best way to fix it, is to check if the rendering server is currently drawing otherwise wait. -> idle time

spindlebink commented 2 years ago

Can confirm this one. The scene instantiated from a thread-loaded resource is usually missing meshes or materials, too, as you'd expect from a failed or incomplete load. It also appears that, although error spam happens every time, the incomplete loading doesn't.

Loading works fine if the threaded load is replaced by simple load.

kalysti commented 2 years ago

missing itself also appears in ResourceLoader.Load / GD.Load. but he comes very rarely. Even if I provide the method for calling GD.Load with an "Await ProcessFrame".

USER ERROR: Creating buffers with data is forbidden during creation of a draw list at: RenderingDeviceVulkan :: vertex_buffer_create (drivers \ vulkan \ rendering_device_vulkan.cpp: 4014) - Condition "draw_list! = nullptr && p_data.size ()" is true. Returning: RID ()

kalysti commented 2 years ago

Background. I'm currently writing a plug-in for asynchronous loading of complete scenes. Currently there is no way to load some PackedScene without get errors sometimes. With larger scenes, the probability of the error is higher.

akien-mga commented 2 years ago

Might have been fixed by #54890, please confirm.

AThousandShips commented 2 years ago

Testing and the loading during drawing appears to be gone along with the associated broken geometry

Calinou commented 2 years ago

Testing and the loading during drawing appears to be gone along with the associated broken geometry

Do you mean that https://github.com/godotengine/godot/pull/54890 resolves this issue, or is the issue still present?

AThousandShips commented 2 years ago

I believe #54890 solves this issue, the "Creating buffers with data is forbidden during creation of a draw list" seems to be gone and so is the lost meshes/materials that was mentioned above