mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-09 17:19:45 -04:00
698bdcba4d
# Description of Changes This is a fix for #4959. Unity 6 upgraded to a newer Emscripten version that removed the `dynCall()` library function. The SpacetimeDB C# SDK's [WebSocket.jslib](cci:7://file:///D:/Projects/ClockworkLabs/SpacetimeDB/sdks/csharp/src/Plugins/WebSocket.jslib:0:0-0:0) plugin used `dynCall()` in 6 places to invoke C# callbacks from JavaScript WebSocket events. This PR adds a `$WebSocketDynCall` helper function that detects which API is available at runtime: - On Unity 6+: uses `getWasmTableEntry(ptr).apply(null, args)` (direct WASM function table access) - On Unity 2022 and earlier: uses the legacy `dynCall(sig, ptr, args)` All `dynCall` call sites in `WebSocket.jslib` now route through this helper, ensuring we maintain backward-compatiblity. # API and ABI breaking changes No breaking changes. This is a backward-compatible fix that works on both older and newer Unity versions. # Expected complexity level and risk 1. Very low risk. The change is isolated to the WebGL `jslib` plugin and uses runtime feature detection to choose the appropriate calling mechanism. Both code paths are well-tested: - Unity 2022.3.62f2: uses legacy `dynCall` path - Unity 6000.4.5f1: uses `getWasmTableEntry` path # Testing - [x] Create test server module with reducers and tables - [x] Unity 2022.3.62f2 Editor: Connect and subscribe works - [x] Unity 2022.3.62f2 WebGL Build: Connect and subscribe works - [x] Unity 6000.4.5f1 Editor: Connect and subscribe works - [x] Unity 6000.4.5f1 WebGL Build: Connect and subscribe works (was previously failing with `dynCall is not defined`)