From db7ac820f9c95dd75c7b71e6d37231534b6c13c5 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 16 May 2026 14:21:31 -0700 Subject: [PATCH] emscripten: Fix crash on Safari when probing gamepad rumble support Safari's older Gamepad API exposes `vibrationActuator` with `playEffect` and `reset` but no `effects` enumeration array. The probe added in 651136ac7 dereferences `vibrationActuator['effects']['includes']` unconditionally, throwing `TypeError: undefined is not an object` on every Safari client that opens a connected gamepad. Add the missing `['effects']` null check so the probe returns false on Safari instead of aborting. --- src/joystick/emscripten/SDL_sysjoystick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index adf471a199..627a329594 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -506,7 +506,7 @@ static bool EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) item->rumble_available = MAIN_THREAD_EM_ASM_INT({ let gamepad = navigator['getGamepads']()[$0]; - return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects']['includes']('dual-rumble'); + return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('dual-rumble'); }, item->index); if (item->rumble_available) { @@ -515,7 +515,7 @@ static bool EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) item->trigger_rumble_available = MAIN_THREAD_EM_ASM_INT({ let gamepad = navigator['getGamepads']()[$0]; - return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble'); + return gamepad && gamepad['vibrationActuator'] && gamepad['vibrationActuator']['effects'] && gamepad['vibrationActuator']['effects']['includes']('trigger-rumble'); }, item->index); if (item->trigger_rumble_available) {