Files
Ryan 698bdcba4d [C#] [Unity 6] Added logic to use either getWasmTableEntry or dynCall for C# WebGL (#4961)
# 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`)
2026-05-07 22:15:55 +00:00
..
2025-02-11 15:13:26 -05:00
2024-10-01 20:00:32 +01:00
2024-08-28 11:13:33 -07:00
2025-11-21 19:39:21 +00:00
2024-07-25 17:18:45 +01:00