From 5df4473a007fed1b49538ce6e7950ae60b4864a6 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Fri, 17 Jun 2022 10:30:12 -0700 Subject: [PATCH] Fix for timer scheduling happening on the incorrect thread when wasm threading is enabled (#70863) --- src/mono/mono/mini/mini-wasm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-wasm.c b/src/mono/mono/mini/mini-wasm.c index 1647bea603da0..67a282256c95b 100644 --- a/src/mono/mono/mini/mini-wasm.c +++ b/src/mono/mono/mini/mini-wasm.c @@ -11,6 +11,12 @@ #include #include +#ifdef HOST_BROWSER +#ifndef DISABLE_THREADS +#include +#endif +#endif + static int mono_wasm_debug_level = 0; #ifndef DISABLE_JIT @@ -617,7 +623,13 @@ void mono_wasm_set_timeout (int timeout) { #ifdef HOST_BROWSER - mono_set_timeout (timeout); +#ifndef DISABLE_THREADS + if (!mono_threads_wasm_is_browser_thread ()) { + mono_threads_wasm_async_run_in_main_thread_vi ((void (*)(gpointer))mono_wasm_set_timeout, GINT_TO_POINTER(timeout)); + return; + } +#endif + mono_set_timeout (timeout); #endif }