Skip to content

[Wasm64] Changes to make AUDIO_WORKLET work with MEMORY64 #18972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ def create_wasm64_wrappers(metadata):
'_emscripten_dlsync_self_async': '_p',
'_emscripten_proxy_dlsync_async': '_pp',
'_wasmfs_rmdir': '_p',
'_wasmfs_unlink': '_p'
'_wasmfs_unlink': '_p',
'emscripten_wasm_worker_initialize': '_p_',
}

wasm64_wrappers = '''
Expand Down
3 changes: 3 additions & 0 deletions src/library_sigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ sigs = {
emscripten_console_log__sig: 'vp',
emscripten_console_warn__sig: 'vp',
emscripten_create_audio_context__sig: 'ip',
emscripten_create_wasm_audio_worklet_node__sig: 'iipppp',
emscripten_create_wasm_audio_worklet_processor_async__sig: 'vippp',
emscripten_create_worker__sig: 'ip',
emscripten_current_thread_is_audio_worklet__sig: 'i',
emscripten_date_now__sig: 'd',
Expand Down Expand Up @@ -621,6 +623,7 @@ sigs = {
emscripten_stack_snapshot__sig: 'p',
emscripten_stack_unwind_buffer__sig: 'ippi',
emscripten_start_fetch__sig: 'vp',
emscripten_start_wasm_audio_worklet_thread_async__sig: 'vipipp',
emscripten_supports_offscreencanvas__sig: 'i',
emscripten_throw_number__sig: 'vd',
emscripten_throw_string__sig: 'vp',
Expand Down
5 changes: 1 addition & 4 deletions src/library_webaudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ let LibraryWebAudio = {
'wasm_workers_id',
'$_EmAudioDispatchProcessorCallback'],
emscripten_start_wasm_audio_worklet_thread_async: function(contextHandle, stackLowestAddress, stackSize, callback, userData) {
#if !AUDIO_WORKLET
abort('emscripten_create_wasm_audio_worklet() requires building with -s AUDIO_WORKLET=1 enabled!');
#endif

#if ASSERTIONS
assert(contextHandle, `Called emscripten_start_wasm_audio_worklet_thread_async() with a null Web Audio Context handle!`);
Expand Down Expand Up @@ -156,7 +153,7 @@ let LibraryWebAudio = {
#if WEBAUDIO_DEBUG
console.error(`emscripten_start_wasm_audio_worklet_thread_async() addModule() failed!`);
#endif
{{{ makeDynCall('viii', 'callback') }}}(contextHandle, 0/*EM_FALSE*/, userData);
{{{ makeDynCall('viip', 'callback') }}}(contextHandle, 0/*EM_FALSE*/, userData);
};

// Does browser not support AudioWorklets?
Expand Down
9 changes: 6 additions & 3 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def make_main_two_files(path1, path2, nonexistingpath):

# Tests that user .html shell files can manually download .data files created with --preload-file cmdline.
@parameterized({
'default': ([],),
'': ([],),
'pthreads': (['-pthread', '-sPROXY_TO_PTHREAD', '-sEXIT_RUNTIME'],),
})
@requires_threads
Expand Down Expand Up @@ -5502,7 +5502,8 @@ def test_full_js_library_strict(self):

# Tests the AudioWorklet demo
@parameterized({
'default': ([],),
'': ([],),
'memory64': (['-sMEMORY64', '-Wno-experimental'],),
'with_fs': (['--preload-file', test_file('hello_world.c') + '@/'],),
'closure': (['--closure', '1', '-Oz'],),
'asyncify': (['-sASYNCIFY'],),
Expand All @@ -5512,11 +5513,13 @@ def test_full_js_library_strict(self):
'minimal_runtime_pthreads_and_closure': (['-sMINIMAL_RUNTIME', '-pthread', '--closure', '1', '-Oz'],),
})
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(test_file('webaudio/audioworklet.c'), args=['-sAUDIO_WORKLET', '-sWASM_WORKERS'] + args)

# Tests that posting functions between the main thread and the audioworklet thread works
@parameterized({
'default': ([],),
'': ([],),
'closure': (['--closure', '1', '-Oz'],),
})
def test_audio_worklet_post_function(self, args):
Expand Down
4 changes: 4 additions & 0 deletions tools/gen_sig_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,17 @@ def extract_sigs(symbols, obj_file):
def extract_sig_info(sig_info, extra_settings=None, extra_cflags=None):
tempfiles = shared.get_temp_files()
settings = {
# Enable as many settings as we can here to ensure the maximum number
# of JS symbols are included.
'STACK_OVERFLOW_CHECK': 1,
'MAX_WEBGL_VERSION': 2,
'FULL_ES3': 1,
'USE_SDL': 1,
'FETCH': 1,
'PTHREADS': 1,
'SHARED_MEMORY': 1,
'AUDIO_WORKLET': 1,
'WASM_WORKERS': 1,
# Currently GLFW symbols have different sigs for the same symbol because the
# signatures changed between v2 and v3, so for now we continue to maintain
# them by hand.
Expand Down