Unity-Technologies / multiplayer-community-contributions

Community contributions to Unity Multiplayer Networking products and services.
MIT License
429 stars 161 forks source link

Netcode for GameObjects Web Socket WebGL build error #136

Open Ripper53 opened 2 years ago

Ripper53 commented 2 years ago

I am using Netcode for GameObjects, but everytime I try to build it to WebGL, it gives a "RuntimeError: null function or function signature mismatch,RuntimeError: null function or function signature mismatch" error.

I started using the web socket transport, and I was wondering how I would be able to set up clients for WebGL. I want a linux server and have WebGL clients connect to it. For testing purposes, I want to host using a Windows machine and use WebGL to connect clients to it. However, the error persists.

Is there more setup I need to do before I can build for WebGL? Why does the error persistent even though I am using a web socket transport for my WebGL build?

Screenshot Screenshot2

Ripper53 commented 2 years ago

I'm wondering if there's any package that is incompatible with WebGL builds, unrelated to the Netcode package, that I have in my Unity project:


  "dependencies": {
    "com.unity.collab-proxy": "1.15.4",
    "com.unity.feature.2d": "1.0.0",
    "com.unity.ide.rider": "3.0.7",
    "com.unity.ide.visualstudio": "2.0.12",
    "com.unity.ide.vscode": "1.2.4",
    "com.unity.inputsystem": "1.2.0",
    "com.unity.netcode.gameobjects": "1.0.0-pre.3",
    "com.unity.render-pipelines.universal": "12.1.2",
    "com.unity.test-framework": "1.1.29",
    "com.unity.textmeshpro": "3.0.6",
    "com.unity.timeline": "1.6.3",
    "com.unity.ugui": "1.0.0",
    "com.unity.visualscripting": "1.7.6",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
  }
}
Esquilofrenik0 commented 2 years ago

I have the same error. Please help!

Ripper53 commented 2 years ago

Here's the error I get for more context: image image image I believe a dll file may be missing, because none of the dll imports seem to work.

Ripper53 commented 2 years ago

I've been looking through the JSWebSocketClient.jslib file and nothing seems to be wrong with it. I thought maybe it was because it was not under a Plugins folder, but I put it under one and that does not fix the issue. I changed Pointer_stringify to UTF8ToString, because the former is obsolete but still the issue persists.

Any help on this would be greatly appreciated! I need to get this working as soon as possible.

Ripper53 commented 2 years ago

Update: this seems to be a problem with netcode, not the websocket transport layer. I created another project, built it, it worked fine. Then, I added netcode for gameobjects, built it, worked fine. Then, I added the NetworkManager component to a game object, built it, it failed. Then I removed the NetworkManager, built it, and it failed again. Seems to keep failing now. I'm assuming this is a problem with the netcode for gameobjects and not the websocket transport layer.

uacaman commented 2 years ago

Same problem here. Will WebGL suported with Netcode for GameObjects? It'd be a lot cooler it did.

rohanrhu commented 2 years ago

Can you explain that isn't WebSocket transport supported for WebGL export?

When I choose WebSocket transport for my NetworkManager, my web export is stucking at 90%.

Please Unity, fix this.

theomonnom commented 2 years ago

Has anyone been able to solve the problem ?

GloamingCat commented 2 years ago

Same problem, I've tried everything I could think of. Does anyone know any workarounds or alternatives? I just wanted my client to work on browser too

BunZaga-CA commented 2 years ago

It's this package that makes this happen: "com.unity.netcode.gameobjects": "1.0.0-pre.7" I went step by step, adding each package and exporting to webGL. This is the only package that causes this bug. When will there be a fix?

ElwoodHogan commented 2 years ago

Getting the same error, my project does not contain netcode

brian-kryptomon commented 2 years ago

Has anyone gotten this to work on webgl? I am getting the same EntryPointNotFoundException.

@Ripper53 did you ever get past this?

brian-kryptomon commented 2 years ago

When I run it as a WebGL build it tries to connect and I see it connect on the server but then I get this error:

Invoking error handler due to ReferenceError: Runtime is not defined unityFramework/__Connect/state.ws.onclose@http://localhost:52557/Build/builds.framework.js.gz:3:72053 EventHandlerNonNull*__Connect@http://localhost:52557/Build/builds.framework.js.gz:3:71946 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[100802]:0x16748c3 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[594]:0x949c2 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[100744]:0x1671020 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[45282]:0xb08959 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[66522]:0x107146e @http://localhost:52557/Build/builds.wasm.gz:wasm-function[53713]:0xe67775 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[11114]:0x2f5a38 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[106076]:0x1779d19 invoke_iiii@http://localhost:52557/Build/builds.framework.js.gz:3:398473

nicholas-maltbie commented 1 year ago

When I run it as a WebGL build it tries to connect and I see it connect on the server but then I get this error:

Invoking error handler due to ReferenceError: Runtime is not defined unityFramework/__Connect/state.ws.onclose@http://localhost:52557/Build/builds.framework.js.gz:3:72053 EventHandlerNonNull*__Connect@http://localhost:52557/Build/builds.framework.js.gz:3:71946 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[100802]:0x16748c3 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[594]:0x949c2 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[100744]:0x1671020 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[45282]:0xb08959 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[66522]:0x107146e @http://localhost:52557/Build/builds.wasm.gz:wasm-function[53713]:0xe67775 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[11114]:0x2f5a38 @http://localhost:52557/Build/builds.wasm.gz:wasm-function[106076]:0x1779d19 invoke_iiii@http://localhost:52557/Build/builds.framework.js.gz:3:398473

I hobbled together a somewhat hotfix version to get client reconnect working and have it work in the editor to support reconnect as well based on an existing PR https://github.com/Unity-Technologies/multiplayer-community-contributions/pull/174 (also wrote a comment there).

https://github.com/nicholas-maltbie/multiplayer-community-contributions/tree/webgl-patch

I have a working example I've tested locally and via the browser here https://github.com/nicholas-maltbie/NetworkStateMachineUnity

Imported via this path - git+https://github.com/nicholas-maltbie/multiplayer-community-contributions?path=/Transports/com.community.netcode.transport.websocket#webgl-patch Hopefully it works as a hotfix until they can merge this change into the official version :)

I've verified that it works with version 1.1.0 of the netcode project as well.