From 4532cbe006059c90b2787ce0d18c7c8809fe65ea Mon Sep 17 00:00:00 2001 From: Edgar J San Martin <29460583+ej-sanmartin@users.noreply.github.com> Date: Sun, 28 Dec 2025 01:11:15 -0500 Subject: [PATCH 1/3] Disable threaded imports when WorkerThreadPool has insufficient threads. --- editor/file_system/editor_file_system.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp index a286f0956f..94d64c29c9 100644 --- a/editor/file_system/editor_file_system.cpp +++ b/editor/file_system/editor_file_system.cpp @@ -3287,6 +3287,15 @@ void EditorFileSystem::reimport_files(const Vector &p_files) { #ifdef THREADS_ENABLED bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads"); +#ifdef WEB_ENABLED + // The Web platform may have threading compiled in, but with only 1 available thread (the main thread). + // Using threaded imports with a single thread causes a deadlock as the main thread waits in a busy-loop + // while the import tasks can't execute. Disable threaded imports when insufficient threads are available. + // See GH-112072 for details. + if (WorkerThreadPool::get_singleton()->get_thread_count() <= 1) { + use_multiple_threads = false; + } +#endif #else bool use_multiple_threads = false; #endif From 7278190c71159026142438beee40bec9c7d75e69 Mon Sep 17 00:00:00 2001 From: Edgar <29460583+ej-sanmartin@users.noreply.github.com> Date: Sun, 28 Dec 2025 21:29:16 -0500 Subject: [PATCH 2/3] Disable threaded scanning and importing on Web platform. --- editor/file_system/editor_file_system.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp index 94d64c29c9..17c92d1b23 100644 --- a/editor/file_system/editor_file_system.cpp +++ b/editor/file_system/editor_file_system.cpp @@ -3285,17 +3285,13 @@ void EditorFileSystem::reimport_files(const Vector &p_files) { // Emit the resource_reimporting signal for the single file before the actual importation. emit_signal(SNAME("resources_reimporting"), reloads); -#ifdef THREADS_ENABLED - bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads"); #ifdef WEB_ENABLED - // The Web platform may have threading compiled in, but with only 1 available thread (the main thread). - // Using threaded imports with a single thread causes a deadlock as the main thread waits in a busy-loop - // while the import tasks can't execute. Disable threaded imports when insufficient threads are available. + // On web, busy-wait loops on the main thread block the JavaScript event loop, + // causing the browser tab to appear frozen. Disable threaded imports entirely. // See GH-112072 for details. - if (WorkerThreadPool::get_singleton()->get_thread_count() <= 1) { - use_multiple_threads = false; - } -#endif + bool use_multiple_threads = false; +#elif defined(THREADS_ENABLED) + bool use_multiple_threads = GLOBAL_GET("editor/import/use_multiple_threads"); #else bool use_multiple_threads = false; #endif @@ -3759,7 +3755,7 @@ void EditorFileSystem::remove_import_format_support_query(Ref Date: Sun, 28 Dec 2025 21:35:21 -0500 Subject: [PATCH 3/3] Add clarifying comment explaining threads block file system scanning on web. --- editor/file_system/editor_file_system.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/editor/file_system/editor_file_system.cpp b/editor/file_system/editor_file_system.cpp index 17c92d1b23..cdfb403f2f 100644 --- a/editor/file_system/editor_file_system.cpp +++ b/editor/file_system/editor_file_system.cpp @@ -3756,6 +3756,8 @@ void EditorFileSystem::remove_import_format_support_query(Ref