Skip to content

Commit 5858c64

Browse files
authored
[CI] Enable audio tests in Chrome (#23665)
Step one of a fix for #23131 (the second part in #23695). Enabled Chrome's `FakeAudioOutputStream` for the CI machines and bypassed the need for user interaction. The Chrome tests are now enabled with `@requires_sound_hardware`. Many attempts at replicating the same functionally were tried with Firefox (details below) but audio would never run so its `EMTEST_LACKS_SOUND_HARDWARE` was left unchanged.
1 parent 22c6d55 commit 5858c64

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.circleci/config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,18 @@ commands:
306306
- run:
307307
name: run tests (<< parameters.title >>)
308308
environment:
309-
EMTEST_LACKS_SOUND_HARDWARE: "1"
310309
EMTEST_DETECT_TEMPFILE_LEAKS: "0"
311310
# --no-sandbox because we are running as root and chrome requires
312311
# this flag for now: https://crbug.com/638180
313312
CHROME_FLAGS_BASE: "--no-first-run -start-maximized --no-sandbox --use-gl=swiftshader --user-data-dir=/tmp/chrome-emscripten-profile --enable-experimental-web-platform-features"
314313
CHROME_FLAGS_HEADLESS: "--headless=new --remote-debugging-port=1234"
315314
CHROME_FLAGS_WASM: "--enable-experimental-webassembly-features --js-flags=\"--experimental-wasm-stack-switching --experimental-wasm-type-reflection\""
316315
CHROME_FLAGS_NOCACHE: "--disk-cache-dir=/dev/null --disk-cache-size=1 --media-cache-size=1 --disable-application-cache --incognito"
316+
# The runners lack sound hardware so fallback to a dummy device (and
317+
# bypass the user gesture so audio tests work without interaction)
318+
CHROME_FLAGS_AUDIO: " --use-fake-device-for-media-stream --autoplay-policy=no-user-gesture-required"
317319
command: |
318-
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE"
320+
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE $CHROME_FLAGS_AUDIO"
319321
# There are tests in the browser test suite that using libraries
320322
# that are not included by "./embuilder build ALL". For example the
321323
# PIC version of libSDL which is used by test_sdl2_misc_main_module
@@ -369,6 +371,7 @@ commands:
369371
# support in headless mode) resolves
370372
EMTEST_LACKS_GRAPHICS_HARDWARE: "1"
371373
EMTEST_LACKS_WEBGPU: "1"
374+
# TODO: replicate with FF the same as CHROME_FLAGS_AUDIO
372375
EMTEST_LACKS_SOUND_HARDWARE: "1"
373376
# OffscreenCanvas support is not yet done in Firefox.
374377
EMTEST_LACKS_OFFSCREEN_CANVAS: "1"

test/test_browser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,6 +3231,7 @@ def test_sdl2_misc_via_object(self):
32313231
'': (['-sUSE_SDL=2', '-sUSE_SDL_MIXER=2'],),
32323232
'dash_l': (['-lSDL2', '-lSDL2_mixer'],),
32333233
})
3234+
@no_wasm64('https://github.com/libsdl-org/SDL/pull/12332')
32343235
@requires_sound_hardware
32353236
def test_sdl2_mixer_wav(self, flags):
32363237
shutil.copy(test_file('sounds/the_entertainer.wav'), 'sound.wav')
@@ -3244,6 +3245,7 @@ def test_sdl2_mixer_wav(self, flags):
32443245
# TODO: need to source freepats.cfg and a midi file
32453246
# 'mod': (['mid'], 'MIX_INIT_MID', 'midi.mid'),
32463247
})
3248+
@no_wasm64('https://github.com/libsdl-org/SDL/pull/12332')
32473249
@requires_sound_hardware
32483250
def test_sdl2_mixer_music(self, formats, flags, music_name):
32493251
shutil.copy(test_file('sounds', music_name), '.')
@@ -5469,9 +5471,8 @@ def test_full_js_library_strict(self):
54695471
'es6': (['-sEXPORT_ES6'],),
54705472
'strict': (['-sSTRICT'],),
54715473
})
5474+
@requires_sound_hardware
54725475
def test_audio_worklet(self, args):
5473-
if '-sMEMORY64' in args and is_firefox():
5474-
self.skipTest('https://github.com/emscripten-core/emscripten/issues/19161')
54755476
self.btest_exit('webaudio/audioworklet.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'] + args)
54765477

54775478
# Tests that audioworklets and workers can be used at the same time
@@ -5490,6 +5491,7 @@ def test_audio_worklet_post_function(self, args):
54905491
'': ([],),
54915492
'closure': (['--closure', '1', '-Oz'],),
54925493
})
5494+
@requires_sound_hardware
54935495
def test_audio_worklet_modularize(self, args):
54945496
self.btest_exit('webaudio/audioworklet.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS', '-sMODULARIZE=1', '-sEXPORT_NAME=MyModule', '--shell-file', test_file('shell_that_launches_modularize.html')] + args)
54955497

0 commit comments

Comments
 (0)