diff options
Diffstat (limited to 'platform/web')
-rw-r--r-- | platform/web/SCsub | 1 | ||||
-rw-r--r-- | platform/web/detect.py | 29 | ||||
-rw-r--r-- | platform/web/export/export_plugin.cpp | 8 | ||||
-rw-r--r-- | platform/web/js/libs/library_godot_audio.js | 38 |
4 files changed, 48 insertions, 28 deletions
diff --git a/platform/web/SCsub b/platform/web/SCsub index e81f2ec516..b30bf20f26 100644 --- a/platform/web/SCsub +++ b/platform/web/SCsub @@ -1,4 +1,5 @@ #!/usr/bin/env python +from misc.utility.scons_hints import * from methods import print_error diff --git a/platform/web/detect.py b/platform/web/detect.py index bf75c2f9fc..735e2eaf4f 100644 --- a/platform/web/detect.py +++ b/platform/web/detect.py @@ -199,6 +199,11 @@ def configure(env: "SConsEnvironment"): cc_version = get_compiler_version(env) cc_semver = (cc_version["major"], cc_version["minor"], cc_version["patch"]) + # Minimum emscripten requirements. + if cc_semver < (3, 1, 62): + print_error("The minimum emscripten version to build Godot is 3.1.62, detected: %s.%s.%s" % cc_semver) + sys.exit(255) + env.Prepend(CPPPATH=["#platform/web"]) env.Append(CPPDEFINES=["WEB_ENABLED", "UNIX_ENABLED"]) @@ -210,14 +215,12 @@ def configure(env: "SConsEnvironment"): env.Append(LINKFLAGS=["-sOFFSCREEN_FRAMEBUFFER=1"]) # Disables the use of *glGetProcAddress() which is inefficient. # See https://emscripten.org/docs/tools_reference/settings_reference.html#gl-enable-get-proc-address - if cc_semver >= (3, 1, 51): - env.Append(LINKFLAGS=["-sGL_ENABLE_GET_PROC_ADDRESS=0"]) + env.Append(LINKFLAGS=["-sGL_ENABLE_GET_PROC_ADDRESS=0"]) if env["javascript_eval"]: env.Append(CPPDEFINES=["JAVASCRIPT_EVAL_ENABLED"]) - stack_size_opt = "STACK_SIZE" if cc_semver >= (3, 1, 25) else "TOTAL_STACK" - env.Append(LINKFLAGS=["-s%s=%sKB" % (stack_size_opt, env["stack_size"])]) + env.Append(LINKFLAGS=["-s%s=%sKB" % ("STACK_SIZE", env["stack_size"])]) if env["threads"]: # Thread support (via SharedArrayBuffer). @@ -237,30 +240,21 @@ def configure(env: "SConsEnvironment"): env["proxy_to_pthread"] = False if env["lto"] != "none": - # Workaround https://github.com/emscripten-core/emscripten/issues/19781. - if cc_semver >= (3, 1, 42) and cc_semver < (3, 1, 46): - env.Append(LINKFLAGS=["-Wl,-u,scalbnf"]) # Workaround https://github.com/emscripten-core/emscripten/issues/16836. - if cc_semver >= (3, 1, 47): - env.Append(LINKFLAGS=["-Wl,-u,_emscripten_run_callback_on_thread"]) + env.Append(LINKFLAGS=["-Wl,-u,_emscripten_run_callback_on_thread"]) if env["dlink_enabled"]: if env["proxy_to_pthread"]: print_warning("GDExtension support requires proxy_to_pthread=no, disabling proxy to pthread.") env["proxy_to_pthread"] = False - if cc_semver < (3, 1, 14): - print_error("GDExtension support requires emscripten >= 3.1.14, detected: %s.%s.%s" % cc_semver) - sys.exit(255) - env.Append(CCFLAGS=["-sSIDE_MODULE=2"]) env.Append(LINKFLAGS=["-sSIDE_MODULE=2"]) env.Append(CCFLAGS=["-fvisibility=hidden"]) env.Append(LINKFLAGS=["-fvisibility=hidden"]) env.extra_suffix = ".dlink" + env.extra_suffix - # WASM_BIGINT is needed since emscripten ≥ 3.1.41 - needs_wasm_bigint = cc_semver >= (3, 1, 41) + env.Append(LINKFLAGS=["-sWASM_BIGINT"]) # Run the main application in a web worker if env["proxy_to_pthread"]: @@ -269,11 +263,6 @@ def configure(env: "SConsEnvironment"): env.Append(LINKFLAGS=["-sEXPORTED_RUNTIME_METHODS=['_emscripten_proxy_main']"]) # https://github.com/emscripten-core/emscripten/issues/18034#issuecomment-1277561925 env.Append(LINKFLAGS=["-sTEXTDECODER=0"]) - # BigInt support to pass object pointers between contexts - needs_wasm_bigint = True - - if needs_wasm_bigint: - env.Append(LINKFLAGS=["-sWASM_BIGINT"]) # Reduce code size by generating less support code (e.g. skip NodeJS support). env.Append(LINKFLAGS=["-sENVIRONMENT=web,worker"]) diff --git a/platform/web/export/export_plugin.cpp b/platform/web/export/export_plugin.cpp index 5faab74d7b..efe3c95496 100644 --- a/platform/web/export/export_plugin.cpp +++ b/platform/web/export/export_plugin.cpp @@ -214,6 +214,9 @@ Error EditorExportPlatformWeb::_add_manifest_icon(const String &p_path, const St } Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_preset, const String p_path, const Vector<SharedObject> &p_shared_objects) { + List<String> preset_features; + get_preset_features(p_preset, &preset_features); + String proj_name = GLOBAL_GET("application/config/name"); if (proj_name.is_empty()) { proj_name = "Godot Game"; @@ -239,7 +242,10 @@ Error EditorExportPlatformWeb::_build_pwa(const Ref<EditorExportPreset> &p_prese cache_files.push_back(name + ".icon.png"); cache_files.push_back(name + ".apple-touch-icon.png"); } - cache_files.push_back(name + ".worker.js"); + + if (preset_features.find("threads")) { + cache_files.push_back(name + ".worker.js"); + } cache_files.push_back(name + ".audio.worklet.js"); cache_files.push_back(name + ".audio.position.worklet.js"); replaces["___GODOT_CACHE___"] = Variant(cache_files).to_json_string(); diff --git a/platform/web/js/libs/library_godot_audio.js b/platform/web/js/libs/library_godot_audio.js index 40fb0c356c..aaf986b966 100644 --- a/platform/web/js/libs/library_godot_audio.js +++ b/platform/web/js/libs/library_godot_audio.js @@ -868,7 +868,10 @@ class Bus { * @returns {void} */ static move(fromIndex, toIndex) { - const movedBus = GodotAudio.Bus.getBus(fromIndex); + const movedBus = GodotAudio.Bus.getBusOrNull(fromIndex); + if (movedBus == null) { + return; + } const buses = GodotAudio.buses.filter((_, i) => i !== fromIndex); // Inserts at index. buses.splice(toIndex - 1, 0, movedBus); @@ -1424,7 +1427,10 @@ const _GodotAudio = { * @returns {void} */ remove_sample_bus: function (index) { - const bus = GodotAudio.Bus.getBus(index); + const bus = GodotAudio.Bus.getBusOrNull(index); + if (bus == null) { + return; + } bus.clear(); }, @@ -1454,8 +1460,17 @@ const _GodotAudio = { * @returns {void} */ set_sample_bus_send: function (busIndex, sendIndex) { - const bus = GodotAudio.Bus.getBus(busIndex); - bus.setSend(GodotAudio.Bus.getBus(sendIndex)); + const bus = GodotAudio.Bus.getBusOrNull(busIndex); + if (bus == null) { + // Cannot send from an invalid bus. + return; + } + let targetBus = GodotAudio.Bus.getBusOrNull(sendIndex); + if (targetBus == null) { + // Send to master. + targetBus = GodotAudio.Bus.getBus(0); + } + bus.setSend(targetBus); }, /** @@ -1465,7 +1480,10 @@ const _GodotAudio = { * @returns {void} */ set_sample_bus_volume_db: function (busIndex, volumeDb) { - const bus = GodotAudio.Bus.getBus(busIndex); + const bus = GodotAudio.Bus.getBusOrNull(busIndex); + if (bus == null) { + return; + } bus.setVolumeDb(volumeDb); }, @@ -1476,7 +1494,10 @@ const _GodotAudio = { * @returns {void} */ set_sample_bus_solo: function (busIndex, enable) { - const bus = GodotAudio.Bus.getBus(busIndex); + const bus = GodotAudio.Bus.getBusOrNull(busIndex); + if (bus == null) { + return; + } bus.solo(enable); }, @@ -1487,7 +1508,10 @@ const _GodotAudio = { * @returns {void} */ set_sample_bus_mute: function (busIndex, enable) { - const bus = GodotAudio.Bus.getBus(busIndex); + const bus = GodotAudio.Bus.getBusOrNull(busIndex); + if (bus == null) { + return; + } bus.mute(enable); }, }, |