Skip to content

Commit

Permalink
Merge pull request godotengine#94789 from Faless/web/fix_thread_cc_wi…
Browse files Browse the repository at this point in the history
…th_workaround

[Web] Fix closure compiler builds, enable it in CI.
  • Loading branch information
akien-mga committed Jul 26, 2024
2 parents c98a706 + 96feb92 commit 607b230
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/web_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no
SCONSFLAGS: verbose=yes warnings=extra werror=yes debug_symbols=no use_closure_compiler=yes
EM_VERSION: 3.1.59
EM_CACHE_FOLDER: "emsdk-cache"

Expand Down
5 changes: 5 additions & 0 deletions platform/web/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ def configure(env: "SConsEnvironment"):
env.Append(LINKFLAGS=["-sDEFAULT_PTHREAD_STACK_SIZE=%sKB" % env["default_pthread_stack_size"]])
env.Append(LINKFLAGS=["-sPTHREAD_POOL_SIZE=8"])
env.Append(LINKFLAGS=["-sWASM_MEM_MAX=2048MB"])
if not env["dlink_enabled"]:
# Workaround https://github.com/emscripten-core/emscripten/issues/21844#issuecomment-2116936414.
# Not needed (and potentially dangerous) when dlink_enabled=yes, since we set EXPORT_ALL=1 in that case.
env.Append(LINKFLAGS=["-sEXPORTED_FUNCTIONS=['__emscripten_thread_crashed','_main']"])

elif env["proxy_to_pthread"]:
print_warning('"threads=no" support requires "proxy_to_pthread=no", disabling proxy to pthread.')
env["proxy_to_pthread"] = False
Expand Down
21 changes: 8 additions & 13 deletions platform/web/js/libs/library_godot_audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Sample {
* Creates a `Sample` based on the params. Will register it to the
* `GodotAudio.samples` registry.
* @param {SampleParams} params Base params
* @param {SampleOptions} [options={}] Optional params
* @param {SampleOptions} [options={{}}] Optional params
* @returns {Sample}
*/
static create(params, options = {}) {
Expand All @@ -98,8 +98,7 @@ class Sample {
/**
* `Sample` constructor.
* @param {SampleParams} params Base params
* @param {SampleOptions} [options={}] Optional params
* @constructor
* @param {SampleOptions} [options={{}}] Optional params
*/
constructor(params, options = {}) {
/** @type {string} */
Expand Down Expand Up @@ -154,7 +153,7 @@ class Sample {
if (this._audioBuffer == null) {
throw new Error('couldn\'t duplicate a null audioBuffer');
}
/** @type {Float32Array[]} */
/** @type {Array<Float32Array>} */
const channels = new Array(this._audioBuffer.numberOfChannels);
for (let i = 0; i < this._audioBuffer.numberOfChannels; i++) {
const channel = new Float32Array(this._audioBuffer.getChannelData(i));
Expand Down Expand Up @@ -189,7 +188,6 @@ class SampleNodeBus {
/**
* `SampleNodeBus` constructor.
* @param {Bus} bus The bus related to the new `SampleNodeBus`.
* @constructor
*/
constructor(bus) {
const NUMBER_OF_WEB_CHANNELS = 6;
Expand Down Expand Up @@ -413,8 +411,7 @@ class SampleNode {

/**
* @param {SampleNodeParams} params Base params
* @param {SampleNodeOptions} [options={}] Optional params
* @constructor
* @param {SampleNodeOptions} [options={{}}] Optional params
*/
constructor(params, options = {}) {
/** @type {string} */
Expand All @@ -441,7 +438,7 @@ class SampleNode {
this._sampleNodeBuses = new Map();
/** @type {AudioBufferSourceNode | null} */
this._source = GodotAudio.ctx.createBufferSource();
/** @type {AudioBufferSourceNode["onended"]} */

this._onended = null;

this.setPlaybackRate(options.playbackRate ?? 44100);
Expand Down Expand Up @@ -558,7 +555,7 @@ class SampleNode {

/**
* Sets the volumes of the `SampleNode` for each buses passed in parameters.
* @param {Bus[]} buses
* @param {Array<Bus>} buses
* @param {Float32Array} volumes
*/
setVolumes(buses, volumes) {
Expand Down Expand Up @@ -818,7 +815,6 @@ class Bus {

/**
* `Bus` constructor.
* @constructor
*/
constructor() {
/** @type {Set<SampleNode>} */
Expand Down Expand Up @@ -985,7 +981,6 @@ class Bus {
GodotAudio.buses = GodotAudio.buses.filter((v) => v !== this);
}

/** @type {Bus["prototype"]["_syncSampleNodes"]} */
_syncSampleNodes() {
const sampleNodes = Array.from(this._sampleNodes);
for (let i = 0; i < sampleNodes.length; i++) {
Expand Down Expand Up @@ -1086,7 +1081,7 @@ const _GodotAudio = {
// `Bus` class
/**
* Registry of `Bus`es.
* @type {Bus[]}
* @type {Array<Bus>}
*/
buses: null,
/**
Expand Down Expand Up @@ -1309,7 +1304,7 @@ const _GodotAudio = {
/**
* Triggered when a sample node volumes need to be updated.
* @param {string} playbackObjectId Id of the sample playback
* @param {number[]} busIndexes Indexes of the buses that need to be updated
* @param {Array<number>} busIndexes Indexes of the buses that need to be updated
* @param {Float32Array} volumes Array of the volumes
* @returns {void}
*/
Expand Down

0 comments on commit 607b230

Please sign in to comment.