From 5858c64d27f4d1491fbe4947bf9066c2c3063bab Mon Sep 17 00:00:00 2001 From: Carl Woffenden Date: Tue, 18 Feb 2025 22:40:49 +0100 Subject: [PATCH] [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. --- .circleci/config.yml | 7 +++++-- test/test_browser.py | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5038ba89917ee..cde1d2f5be0b5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -306,7 +306,6 @@ 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 @@ -314,8 +313,11 @@ commands: 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 @@ -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" diff --git a/test/test_browser.py b/test/test_browser.py index 27a4a46a83ba3..20fa6eadc142c 100644 --- a/test/test_browser.py +++ b/test/test_browser.py @@ -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') @@ -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), '.') @@ -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 @@ -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)