From 7cc9955ae1324e6090e05acd868d73e11417b0b1 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 20 Feb 2026 10:23:45 -0500
Subject: [PATCH] emscripten: Move some `EM_ASM` blocks to
`MAIN_THREAD_EM_ASM`.
These blocks reference the `navigator` global, which is not available in
background threads.
(cherry picked from commit c728e2f044ef53dba0b0981e54ee68c7348b9f1b)
---
src/joystick/emscripten/SDL_sysjoystick.c | 4 ++--
src/locale/emscripten/SDL_syslocale.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c
index 7474fa74a1e14..42f12b033d426 100644
--- a/src/joystick/emscripten/SDL_sysjoystick.c
+++ b/src/joystick/emscripten/SDL_sysjoystick.c
@@ -449,7 +449,7 @@ static bool EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index)
joystick->nbuttons = item->nbuttons;
joystick->naxes = item->naxes;
- rumble_available = EM_ASM_INT({
+ rumble_available = MAIN_THREAD_EM_ASM_INT({
let gamepads = navigator['getGamepads']();
if (!gamepads) {
return 0;
@@ -570,7 +570,7 @@ static bool EMSCRIPTEN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequen
SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata;
// clang-format off
- bool result = EM_ASM_INT({
+ bool result = MAIN_THREAD_EM_ASM_INT({
let gamepads = navigator['getGamepads']();
if (!gamepads) {
return 0;
diff --git a/src/locale/emscripten/SDL_syslocale.c b/src/locale/emscripten/SDL_syslocale.c
index c24b7f5417552..0dd86a362af13 100644
--- a/src/locale/emscripten/SDL_syslocale.c
+++ b/src/locale/emscripten/SDL_syslocale.c
@@ -27,7 +27,7 @@
bool SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
{
/* *INDENT-OFF* */ // clang-format off
- EM_ASM({
+ MAIN_THREAD_EM_ASM({
var buf = $0;
var buflen = $1;
var list = undefined;