From d0042851f8b6a35432e85ee653ff78027a604384 Mon Sep 17 00:00:00 2001 From: Adam Scott Date: Tue, 1 Jul 2025 15:42:58 -0400 Subject: [PATCH] Move Web export threads options out of variant mk2 --- .../doc_classes/EditorExportPlatformWeb.xml | 10 +++++----- platform/web/export/export_plugin.cpp | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/platform/web/doc_classes/EditorExportPlatformWeb.xml b/platform/web/doc_classes/EditorExportPlatformWeb.xml index c9944657416..1cc2280f683 100644 --- a/platform/web/doc_classes/EditorExportPlatformWeb.xml +++ b/platform/web/doc_classes/EditorExportPlatformWeb.xml @@ -79,17 +79,17 @@ - [b]Landscape:[/b] Forces a horizontal layout (wider than it is taller). - [b]Portrait:[/b] Forces a vertical layout (taller than it is wider). - + The number of threads that emscripten will allocate at startup. A smaller value will allocate fewer threads and consume fewer system resources, but you may run the risk of running out of threads in the pool and needing to allocate more threads at run time which may cause a deadlock. [b]Note:[/b] Some browsers have a hard cap on the number of threads that can be allocated, so it is best to be cautious and keep this number low. + + Override for the default size of the [WorkerThreadPool]. This setting is used when [member ProjectSettings.threading/worker_pool/max_threads] size is set to -1 (which it is by default). This size must be smaller than [member threads/emscripten_pool_size] otherwise deadlocks may occur. + When using threads this size needs to be large enough to accommodate features that rely on having a dedicated thread like [member ProjectSettings.physics/2d/run_on_separate_thread] or [member ProjectSettings.rendering/driver/threads/thread_model]. In general, it is best to ensure that this is at least 4 and is at least 2 or 3 less than [member threads/emscripten_pool_size]. + If [code]true[/code] enables [GDExtension] support for this web build. - - Override for the default size of the [WorkerThreadPool]. This setting is used when [member ProjectSettings.threading/worker_pool/max_threads] size is set to -1 (which it is by default). This size must be smaller than [member variant/emscripten_pool_size] otherwise deadlocks may occur. - When using threads this size needs to be large enough to accommodate features that rely on having a dedicated thread like [member ProjectSettings.physics/2d/run_on_separate_thread] or [member ProjectSettings.rendering/driver/threads/thread_model]. In general, it is best to ensure that this is at least 4 and is at least 2 or 3 less than [member variant/emscripten_pool_size]. - If [code]true[/code], the exported game will support threads. It requires [url=https://web.dev/articles/coop-coep]a "cross-origin isolated" website[/url], which may be difficult to set up and is limited for security reasons (such as not being able to communicate with third-party websites). If [code]false[/code], the exported game will not support threads. As a result, it is more prone to performance and audio issues, but will only require to be run on an HTTPS website. diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 4575c3b51e1..570e1f94a2d 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -143,13 +143,14 @@ void EditorExportPlatformWeb::_fix_html(Vector &p_html, const Refget("html/canvas_resize_policy"); config["experimentalVK"] = p_preset->get("html/experimental_virtual_keyboard"); config["focusCanvas"] = p_preset->get("html/focus_canvas_on_start"); - config["godotPoolSize"] = p_preset->get("variant/godot_pool_size"); config["gdextensionLibs"] = libs; config["executable"] = p_name; config["args"] = args; config["fileSizes"] = p_file_sizes; config["ensureCrossOriginIsolationHeaders"] = (bool)p_preset->get("progressive_web_app/ensure_cross_origin_isolation_headers"); - config["emscriptenPoolSize"] = p_preset->get("variant/emscripten_pool_size"); + + config["godotPoolSize"] = p_preset->get("threads/godot_pool_size"); + config["emscriptenPoolSize"] = p_preset->get("threads/emscripten_pool_size"); String head_include; if (p_preset->get("html/export_icon")) { @@ -366,9 +367,7 @@ void EditorExportPlatformWeb::get_export_options(List *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "*.zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "variant/extensions_support"), false)); // GDExtension support. - r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "variant/thread_support"), false)); // Thread support (i.e. run with or without COEP/COOP headers). - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/emscripten_pool_size"), 8)); - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/godot_pool_size"), 4)); + r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "variant/thread_support"), false, true)); // Thread support (i.e. run with or without COEP/COOP headers). r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer @@ -387,15 +386,21 @@ void EditorExportPlatformWeb::get_export_options(List *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/icon_180x180", PROPERTY_HINT_FILE, "*.png,*.webp,*.svg"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/icon_512x512", PROPERTY_HINT_FILE, "*.png,*.webp,*.svg"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "progressive_web_app/background_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color())); + + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "threads/emscripten_pool_size"), 8)); + r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "threads/godot_pool_size"), 4)); } bool EditorExportPlatformWeb::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const { bool advanced_options_enabled = p_preset->are_advanced_options_enabled(); - if (p_option == "custom_template/debug" || - p_option == "custom_template/release") { + if (p_option == "custom_template/debug" || p_option == "custom_template/release") { return advanced_options_enabled; } + if (p_option == "threads/godot_pool_size" || p_option == "threads/emscripten_pool_size") { + return p_preset->get("variant/thread_support").operator bool(); + } + return true; }