diff --git a/src/shell_minimal.js b/src/shell_minimal.js index 8d42af0057312..dbbe278f144aa 100644 --- a/src/shell_minimal.js +++ b/src/shell_minimal.js @@ -58,22 +58,23 @@ if (ENVIRONMENT_IS_NODE) { } #endif -#if WASM_WORKERS +#if AUDIO_WORKLET +var ENVIRONMENT_IS_AUDIO_WORKLET = !!globalThis.AudioWorkletGlobalScope; +#endif + +#if AUDIO_WORKLET && WASM_WORKERS +var ENVIRONMENT_IS_WASM_WORKER = globalThis.name == 'em-ww' || ENVIRONMENT_IS_AUDIO_WORKLET; +#elif WASM_WORKERS var ENVIRONMENT_IS_WASM_WORKER = globalThis.name == 'em-ww'; +#endif -#if ENVIRONMENT_MAY_BE_NODE +#if WASM_WORKERS && ENVIRONMENT_MAY_BE_NODE if (ENVIRONMENT_IS_NODE) { // The way we signal to a worker that it is hosting a pthread is to construct // it with a specific name. ENVIRONMENT_IS_WASM_WORKER = worker_threads['workerData'] == 'em-ww' } #endif -#endif - -#if AUDIO_WORKLET -var ENVIRONMENT_IS_AUDIO_WORKLET = !!globalThis.AudioWorkletGlobalScope; -if (ENVIRONMENT_IS_AUDIO_WORKLET) ENVIRONMENT_IS_WASM_WORKER = true; -#endif #if ASSERTIONS && ENVIRONMENT_MAY_BE_NODE && ENVIRONMENT_MAY_BE_SHELL if (ENVIRONMENT_IS_NODE && ENVIRONMENT_IS_SHELL) { diff --git a/test/codesize/audio_worklet_wasm.expected.js b/test/codesize/audio_worklet_wasm.expected.js index 33bde806d7fae..c9cb7d9562844 100644 --- a/test/codesize/audio_worklet_wasm.expected.js +++ b/test/codesize/audio_worklet_wasm.expected.js @@ -1,6 +1,4 @@ -var m = globalThis.Module || "undefined" != typeof Module ? Module : {}, q = "em-ww" == globalThis.name, r = !!globalThis.AudioWorkletGlobalScope, t, z, J, K, H, E, v, X, F, D, C, Y, A, Z; - -r && (q = !0); +var m = globalThis.Module || "undefined" != typeof Module ? Module : {}, q = !!globalThis.AudioWorkletGlobalScope, r = "em-ww" == globalThis.name || q, t, z, J, K, H, E, v, X, F, D, C, Y, A, Z; function u(a) { t = a; @@ -12,12 +10,12 @@ function u(a) { a.G = a.M = 0; } -q && !r && (onmessage = a => { +r && !q && (onmessage = a => { onmessage = null; u(a.data); }); -if (r) { +if (q) { function a(e) { class d extends AudioWorkletProcessor { constructor(c) { @@ -98,7 +96,7 @@ function w() { E = new Float32Array(a); } -q || (v = m.mem || new WebAssembly.Memory({ +r || (v = m.mem || new WebAssembly.Memory({ initial: 256, maximum: 256, shared: !0 @@ -236,9 +234,9 @@ function y() { C = a.n; Y = a.o; A = a.k; - q ? (Y(t.J, t.F), r || (removeEventListener("message", N), L = L.forEach(M), addEventListener("message", M))) : a.i(); - q || X(); + r ? (Y(t.J, t.F), q || (removeEventListener("message", N), L = L.forEach(M), addEventListener("message", M))) : a.i(); + r || X(); })); } -q || y(); \ No newline at end of file +r || y(); \ No newline at end of file diff --git a/test/codesize/test_minimal_runtime_code_size_audio_worklet.json b/test/codesize/test_minimal_runtime_code_size_audio_worklet.json index 224ac1a413150..3b300a7165dfc 100644 --- a/test/codesize/test_minimal_runtime_code_size_audio_worklet.json +++ b/test/codesize/test_minimal_runtime_code_size_audio_worklet.json @@ -1,10 +1,10 @@ { "a.html": 519, "a.html.gz": 357, - "a.js": 3866, - "a.js.gz": 2041, + "a.js": 3859, + "a.js.gz": 2037, "a.wasm": 1308, "a.wasm.gz": 876, - "total": 5693, - "total_gz": 3274 + "total": 5686, + "total_gz": 3270 }