mikerochip / unity-websocket

Easy-to-use WebSocket MonoBehaviour for Unity. NativeWebSocket alternative.
Other
36 stars 5 forks source link

WebGL: dynCall is not a function #13

Closed glebov21 closed 5 months ago

glebov21 commented 5 months ago

Unity 2023 Hello. I have error "dynCall is not a function" in this place: https://github.com/mikerochip/unity-websocket/blob/93dfe30a155decec0a747c80fa361d0155112853/Runtime/Internal/WebSocket.jslib#L102

Publish settings: use WebAssembly.Table = true;

I think, this and similar lines must be replaced by this: {{{ makeDynCall('vi', 'webSocketState.onOpen') }}}(instanceId);

https://docs.unity3d.com/2023.2/Documentation/Manual/web-interacting-browser-example.html

mikerochip commented 5 months ago

It's not that simple, unfortunately, but thank you for bringing this to my attention

It looks like this was a change first introduced in emscripten 2.0.3 which should have been included since Unity 2022.2 according to this table.

OK, looking into this further, it seems that this issue is specific to WebAssembly.Table. Links for posterity:

Anyway, Unity 2019 support would break if I made the change you're suggesting, so I'll probably have to figure out how to either maintain 2 separate copies of this lib, do a runtime check, or start doing proper version pinning. Or maybe all 3.

mikerochip commented 5 months ago

@glebov21 Took a couple tries, but I managed to do some gymnastics to get the latest commit of this package working with all versions from 2019.4 through 2023.2+ with WebAssembly.Table enabled.

No changes required by users of this package, except updating to the latest package commit or using the 1.1.0 tag, whichever you like.

glebov21 commented 5 months ago

Thank you very match!

mikerochip commented 5 months ago

No, thank YOU for finding this! I think this is now the only Web-compatible WebSocket library for Unity that supports this + has backwards compatibility.