Skip to content

Commit 6501d40

Browse files
committed
Move Web export threads options out of variant
1 parent 03bd8ba commit 6501d40

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

editor/export/editor_export_platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ class EditorExportPlatform : public RefCounted {
343343
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) {}
344344
virtual String get_debug_protocol() const { return "tcp://"; }
345345
virtual HashMap<String, Variant> get_custom_project_settings(const Ref<EditorExportPreset> &p_preset) const { return HashMap<String, Variant>(); }
346+
347+
virtual void export_option_set(const String &p_edited_property) {}
346348
};
347349

348350
VARIANT_ENUM_CAST(EditorExportPlatform::ExportMessageType)

editor/export/project_export.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,9 @@ void ProjectExportDialog::_tab_changed(int) {
483483
}
484484

485485
void ProjectExportDialog::_update_parameters(const String &p_edited_property) {
486+
Ref<EditorExportPreset> current = get_current_preset();
487+
current->get_platform()->export_option_set(p_edited_property);
488+
486489
_update_current_preset();
487490
}
488491

platform/web/doc_classes/EditorExportPlatformWeb.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@
7979
- [b]Landscape:[/b] Forces a horizontal layout (wider than it is taller).
8080
- [b]Portrait:[/b] Forces a vertical layout (taller than it is wider).
8181
</member>
82-
<member name="variant/emscripten_pool_size" type="int" setter="" getter="">
82+
<member name="threads/emscripten_pool_size" type="int" setter="" getter="">
8383
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.
8484
[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.
8585
</member>
86+
<member name="threads/godot_pool_size" type="int" setter="" getter="">
87+
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.
88+
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].
89+
</member>
8690
<member name="variant/extensions_support" type="bool" setter="" getter="">
8791
If [code]true[/code] enables [GDExtension] support for this web build.
8892
</member>
89-
<member name="variant/godot_pool_size" type="int" setter="" getter="">
90-
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.
91-
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].
92-
</member>
9393
<member name="variant/thread_support" type="bool" setter="" getter="">
9494
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).
9595
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.

platform/web/export/export_plugin.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ void EditorExportPlatformWeb::_fix_html(Vector<uint8_t> &p_html, const Ref<Edito
143143
config["canvasResizePolicy"] = p_preset->get("html/canvas_resize_policy");
144144
config["experimentalVK"] = p_preset->get("html/experimental_virtual_keyboard");
145145
config["focusCanvas"] = p_preset->get("html/focus_canvas_on_start");
146-
config["godotPoolSize"] = p_preset->get("variant/godot_pool_size");
147146
config["gdextensionLibs"] = libs;
148147
config["executable"] = p_name;
149148
config["args"] = args;
150149
config["fileSizes"] = p_file_sizes;
151150
config["ensureCrossOriginIsolationHeaders"] = (bool)p_preset->get("progressive_web_app/ensure_cross_origin_isolation_headers");
152-
config["emscriptenPoolSize"] = p_preset->get("variant/emscripten_pool_size");
151+
config["godotPoolSize"] = p_preset->get("threads/godot_pool_size");
152+
config["emscriptenPoolSize"] = p_preset->get("threads/emscripten_pool_size");
153153

154154
String head_include;
155155
if (p_preset->get("html/export_icon")) {
@@ -362,8 +362,7 @@ void EditorExportPlatformWeb::get_export_options(List<ExportOption> *r_options)
362362

363363
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "variant/extensions_support"), false)); // GDExtension support.
364364
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "variant/thread_support"), false)); // Thread support (i.e. run with or without COEP/COOP headers).
365-
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/emscripten_pool_size"), 8));
366-
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "variant/godot_pool_size"), 4));
365+
367366
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_desktop"), true)); // S3TC
368367
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "vram_texture_compression/for_mobile"), false)); // ETC or ETC2, depending on renderer
369368

@@ -373,6 +372,7 @@ void EditorExportPlatformWeb::get_export_options(List<ExportOption> *r_options)
373372
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "html/canvas_resize_policy", PROPERTY_HINT_ENUM, "None,Project,Adaptive"), 2));
374373
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/focus_canvas_on_start"), true));
375374
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "html/experimental_virtual_keyboard"), false));
375+
376376
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "progressive_web_app/enabled"), false));
377377
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "progressive_web_app/ensure_cross_origin_isolation_headers"), true));
378378
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/offline_page", PROPERTY_HINT_FILE, "*.html"), ""));
@@ -382,6 +382,9 @@ void EditorExportPlatformWeb::get_export_options(List<ExportOption> *r_options)
382382
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/icon_180x180", PROPERTY_HINT_FILE, "*.png,*.webp,*.svg"), ""));
383383
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "progressive_web_app/icon_512x512", PROPERTY_HINT_FILE, "*.png,*.webp,*.svg"), ""));
384384
r_options->push_back(ExportOption(PropertyInfo(Variant::COLOR, "progressive_web_app/background_color", PROPERTY_HINT_COLOR_NO_ALPHA), Color()));
385+
386+
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "threads/emscripten_pool_size"), 8));
387+
r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "threads/godot_pool_size"), 4));
385388
}
386389

387390
bool EditorExportPlatformWeb::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
@@ -390,6 +393,9 @@ bool EditorExportPlatformWeb::get_export_option_visibility(const EditorExportPre
390393
p_option == "custom_template/release") {
391394
return advanced_options_enabled;
392395
}
396+
if (p_option == "threads/godot_pool_size" || p_option == "threads/emscripten_pool_size") {
397+
return p_preset->get("variant/thread_support").operator bool();
398+
}
393399

394400
return true;
395401
}

platform/web/export/export_plugin.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
5959

6060
Ref<EditorHTTPServer> server;
6161

62+
bool _should_update_export_options = false;
63+
6264
String _get_template_name(bool p_extension, bool p_thread_support, bool p_debug) const {
6365
String name = "web";
6466
if (p_extension) {
@@ -115,10 +117,19 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
115117
Error _start_server(const String &p_bind_host, uint16_t p_bind_port, bool p_use_tls);
116118
Error _stop_server();
117119

120+
bool _get_preset_threads_enabled(const Ref<EditorExportPreset> &p_preset) const;
121+
118122
public:
119123
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) const override;
120124

121125
virtual void get_export_options(List<ExportOption> *r_options) const override;
126+
virtual bool should_update_export_options() override {
127+
if (!_should_update_export_options) {
128+
return false;
129+
}
130+
_should_update_export_options = false;
131+
return true;
132+
}
122133
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override;
123134

124135
virtual String get_name() const override;
@@ -146,6 +157,10 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
146157
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, HashSet<String> &p_features) override {
147158
}
148159

160+
virtual void export_option_set(const String &p_edited_property) override {
161+
_should_update_export_options = p_edited_property == "variant/thread_support";
162+
}
163+
149164
String get_debug_protocol() const override { return "ws://"; }
150165

151166
EditorExportPlatformWeb();

0 commit comments

Comments
 (0)