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

Deadlock on startup with gl_compatibility #88576

Closed
Malcolmnixon opened this issue Feb 20, 2024 · 2 comments · Fixed by #88589
Closed

Deadlock on startup with gl_compatibility #88576

Malcolmnixon opened this issue Feb 20, 2024 · 2 comments · Fixed by #88589

Comments

@Malcolmnixon
Copy link
Contributor

Tested versions

4.3.dev [fb10e67]

System information

Windows 11, gl_compatibility, NVidia RTX 3070 TI

Issue description

A deadlock situation arises at startup with the following call-stack:

Not Flagged	>	48588	0	Main Thread	Main Thread	[Inline Frame] godot.windows.editor.dev.x86_64.exe!Concurrency::details::stl_condition_variable_win7::wait_for
    [External Code]
    godot.windows.editor.dev.x86_64.exe!Semaphore::wait() Line 80
    godot.windows.editor.dev.x86_64.exe!EditorMaterialPreviewPlugin::generate(const Ref<Resource> & p_from, const Vector2 & p_size, Dictionary & p_metadata) Line 321
    godot.windows.editor.dev.x86_64.exe!EditorResourcePreviewGenerator::generate_from_path(const String & p_path, const Vector2 & p_size, Dictionary & p_metadata) Line 72
    godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_generate_preview(Ref<ImageTexture> & r_texture, Ref<ImageTexture> & r_small_texture, const EditorResourcePreview::QueueItem & p_item, const String & cache_base, Dictionary & p_metadata) Line 165
    godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_iterate() Line 323
    godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_idle_callback() Line 363
    godot.windows.editor.dev.x86_64.exe!SceneTree::_call_idle_callbacks() Line 1681
    godot.windows.editor.dev.x86_64.exe!SceneTree::process(double p_time) Line 532
    godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 3972
    godot.windows.editor.dev.x86_64.exe!OS_Windows::run() Line 1476
    godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 182
    godot.windows.editor.dev.x86_64.exe!_main() Line 204
    godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 218
    godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 232
    [External Code]

Specifically the EditorMaterialPreviewPlugin::generate is blocked on the wait of the following code:

RS::get_singleton()->connect(SNAME("frame_pre_draw"), callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_generate_frame_started), Object::CONNECT_ONE_SHOT);
preview_done.wait();

It's waiting for the frame_pre_draw signal from the RenderServer to call its _generate_frame_started method, which would post to the preview_done signal unblocking the wait.

The problem is the frame_pre_draw signal is generated when the RenderServer performs a draw, and the draw is performed by Main::iteration(); however this is the main thread being blocked so no draws occur - hence deadlock.

Steps to reproduce

I suspect this may have been introduced by #87229 which according to the title "Run resource previewer on the main thread if using GL compatibility" would seem to align with the root cause of this problem.

Minimal reproduction project (MRP)

TODO - will update shortly.

@BastiaanOlij
Copy link
Contributor

cc @RandomShaper

@Malcolmnixon
Copy link
Contributor Author

I can confirm that reverting #87229 resolves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants