Skip to content

Commit

Permalink
[CI] Enable audio tests in Chrome (emscripten-core#23665)
Browse files Browse the repository at this point in the history
Step one of a fix for emscripten-core#23131 (the second part in emscripten-core#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.
  • Loading branch information
cwoffenden authored Feb 18, 2025
1 parent 22c6d55 commit 5858c64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,18 @@ commands:
- run:
name: run tests (<< parameters.title >>)
environment:
EMTEST_LACKS_SOUND_HARDWARE: "1"
EMTEST_DETECT_TEMPFILE_LEAKS: "0"
# --no-sandbox because we are running as root and chrome requires
# this flag for now: https://crbug.com/638180
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"
CHROME_FLAGS_HEADLESS: "--headless=new --remote-debugging-port=1234"
CHROME_FLAGS_WASM: "--enable-experimental-webassembly-features --js-flags=\"--experimental-wasm-stack-switching --experimental-wasm-type-reflection\""
CHROME_FLAGS_NOCACHE: "--disk-cache-dir=/dev/null --disk-cache-size=1 --media-cache-size=1 --disable-application-cache --incognito"
# The runners lack sound hardware so fallback to a dummy device (and
# bypass the user gesture so audio tests work without interaction)
CHROME_FLAGS_AUDIO: " --use-fake-device-for-media-stream --autoplay-policy=no-user-gesture-required"
command: |
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE"
export EMTEST_BROWSER="/usr/bin/google-chrome $CHROME_FLAGS_BASE $CHROME_FLAGS_HEADLESS $CHROME_FLAGS_WASM $CHROME_FLAGS_NOCACHE $CHROME_FLAGS_AUDIO"
# There are tests in the browser test suite that using libraries
# that are not included by "./embuilder build ALL". For example the
# PIC version of libSDL which is used by test_sdl2_misc_main_module
Expand Down Expand Up @@ -369,6 +371,7 @@ commands:
# support in headless mode) resolves
EMTEST_LACKS_GRAPHICS_HARDWARE: "1"
EMTEST_LACKS_WEBGPU: "1"
# TODO: replicate with FF the same as CHROME_FLAGS_AUDIO
EMTEST_LACKS_SOUND_HARDWARE: "1"
# OffscreenCanvas support is not yet done in Firefox.
EMTEST_LACKS_OFFSCREEN_CANVAS: "1"
Expand Down
6 changes: 4 additions & 2 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,7 @@ def test_sdl2_misc_via_object(self):
'': (['-sUSE_SDL=2', '-sUSE_SDL_MIXER=2'],),
'dash_l': (['-lSDL2', '-lSDL2_mixer'],),
})
@no_wasm64('https://github.com/libsdl-org/SDL/pull/12332')
@requires_sound_hardware
def test_sdl2_mixer_wav(self, flags):
shutil.copy(test_file('sounds/the_entertainer.wav'), 'sound.wav')
Expand All @@ -3244,6 +3245,7 @@ def test_sdl2_mixer_wav(self, flags):
# TODO: need to source freepats.cfg and a midi file
# 'mod': (['mid'], 'MIX_INIT_MID', 'midi.mid'),
})
@no_wasm64('https://github.com/libsdl-org/SDL/pull/12332')
@requires_sound_hardware
def test_sdl2_mixer_music(self, formats, flags, music_name):
shutil.copy(test_file('sounds', music_name), '.')
Expand Down Expand Up @@ -5469,9 +5471,8 @@ def test_full_js_library_strict(self):
'es6': (['-sEXPORT_ES6'],),
'strict': (['-sSTRICT'],),
})
@requires_sound_hardware
def test_audio_worklet(self, args):
if '-sMEMORY64' in args and is_firefox():
self.skipTest('https://github.com/emscripten-core/emscripten/issues/19161')
self.btest_exit('webaudio/audioworklet.c', args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'] + args)

# Tests that audioworklets and workers can be used at the same time
Expand All @@ -5490,6 +5491,7 @@ def test_audio_worklet_post_function(self, args):
'': ([],),
'closure': (['--closure', '1', '-Oz'],),
})
@requires_sound_hardware
def test_audio_worklet_modularize(self, args):
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)

Expand Down

0 comments on commit 5858c64

Please sign in to comment.