Skip to content

Commit 43decfa

Browse files
authored
Fix manual triggering in test_audioworklet_emscripten_locks (emscripten-core#24212)
At least under chrome it seems that the main thread doesn't run at all until the first few frames have been produced. This fixes the test failures I've been seeing while working on emscripten-core#24190
1 parent 306d918 commit 43decfa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/webaudio/audioworklet_emscripten_locks.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ double startTime = 0;
4646

4747
bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) {
4848
assert(emscripten_current_thread_is_audio_worklet());
49+
50+
// Produce at few empty frames of audio before we start trying to interact
51+
// with the with main thread.
52+
// On chrome at least it appears the main thread completely blocks until
53+
// a few frames have been produced. This means it may not be safe to interact
54+
// with the main thread during initial frames?
55+
// In my experiments it seems like 5 was the magic number that I needed to
56+
// produce before the main thread could continue to run.
57+
// See https://github.com/emscripten-core/emscripten/issues/24213
58+
static int count = 0;
59+
if (count++ < 5) return true;
60+
4961
int result = 0;
5062
switch (whichTest) {
5163
case TEST_HAS_WAIT:

0 commit comments

Comments
 (0)