Skip to content

Commit 4dd0167

Browse files
committed
Building with -sTEXTDECODER=2 when targeting -sAUDIO_WORKLET is not catastrophic since the user might very likely never attempt to interop any strings between JS and Wasm from the Audio Worklet thread. So leaving UTF8Decoder to be null there will be fine.
1 parent 964c4bc commit 4dd0167

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/libstrings.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
#endif
1010

1111
addToLibrary({
12+
// In -sAUDIO_WORKLET builds, TextDecoder will not exist in AudioWorkletGlobalScope,
13+
// so we cannot try to unconditionally initialize it in that build mode.
14+
#if TEXTDECODER == 2 && !AUDIO_WORKLET
1215
// TextDecoder constructor defaults to UTF-8
13-
#if TEXTDECODER == 2
1416
$UTF8Decoder: "new TextDecoder()",
17+
#elif SUPPORTS_GLOBALTHIS
18+
$UTF8Decoder: "globalThis.TextDecoder && new TextDecoder()",
1519
#else
1620
$UTF8Decoder: "typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined",
1721
#endif

src/lib/libwebaudio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#if AUDIO_WORKLET && !WASM_WORKERS
2-
#error "Building with -sAUDIO_WORKLET also requires enabling -sWASM_WORKERS!"
2+
#error "Building with -sAUDIO_WORKLET also requires enabling -sWASM_WORKERS"
33
#endif
44
#if AUDIO_WORKLET && TEXTDECODER == 2
5-
#error "-sAUDIO_WORKLET does not support -sTEXTDECODER=2 since TextDecoder is not available in AudioWorkletGlobalScope! Use e.g. -sTEXTDECODER=1 when building with -sAUDIO_WORKLET"
5+
#warning "-sAUDIO_WORKLET does not support -sTEXTDECODER=2 since TextDecoder is not available in AudioWorkletGlobalScope. Text decoding will be unavailable in Audio Worklets. If you need string marshalling in Audio Worklets, build with -sTEXTDECODER=1."
66
#endif
77
#if AUDIO_WORKLET && SINGLE_FILE
88
#error "-sAUDIO_WORKLET does not support -sSINGLE_FILE"

0 commit comments

Comments
 (0)