WebGL Build Won't Load

Hi all,

I read that Netcode for GameObjects can work with a community WebGL transport, but if I just so much as create an empty project and install com.unity.netcode.gameobjects and [https://github.com/Unity-Technologies/multiplayer-community-contributions.git?path=/Transports/com.community.netcode.transport.](https://github.com/Unity-Technologies/multiplayer-community-contributions.git?path=/Transports/com.community.netcode.transport.enet)websocket and create a WebGL build, when I load the page I get the following errors in the console:

webgltestweb.loader.js:70 exception thrown: RuntimeError: null function or function signature mismatch,RuntimeError: null function or function signature mismatch
    at il2cpp::vm::MetadataCache::ExecuteModuleInitializers() (http://localhost:8080/Build/webgltestweb.wasm:wasm-function[1538]:0x95ac9)
    at dynCall_v (http://localhost:8080/Build/webgltestweb.wasm:wasm-function[63100]:0x151f793)
    at http://localhost:8080/Build/webgltestweb.framework.js:1035:20
    at invoke_v (http://localhost:8080/Build/webgltestweb.framework.js:14214:3)
    at main (http://localhost:8080/Build/webgltestweb.wasm:wasm-function[59363]:0x135822d)
    at http://localhost:8080/Build/webgltestweb.framework.js:1035:20
    at callMain (http://localhost:8080/Build/webgltestweb.framework.js:17645:13)
    at doRun (http://localhost:8080/Build/webgltestweb.framework.js:17688:21)
    at run (http://localhost:8080/Build/webgltestweb.framework.js:17700:3)
    at runCaller (http://localhost:8080/Build/webgltestweb.framework.js:17628:18)
    at Object.removeRunDependency (http://localhost:8080/Build/webgltestweb.framework.js:990:4)
    at http://localhost:8080/Build/webgltestweb.framework.js:60:12
    at doCallback (http://localhost:8080/Build/webgltestweb.framework.js:4558:11)
    at done (http://localhost:8080/Build/webgltestweb.framework.js:4569:5)
    at IDBTransaction.transaction.oncomplete (http://localhost:8080/Build/webgltestweb.framework.js:3925:5)
printErr @ webgltestweb.loader.js:70
webgltestweb.framework.js:181 Uncaught RuntimeError: null function or function signature mismatch
    at il2cpp::vm::MetadataCache::ExecuteModuleInitializers() (:8080/Build/webgltestweb.wasm)
    at dynCall_v (:8080/Build/webgltestweb.wasm)
    at :8080/Build/webgltestweb.framework.js:1035:20
    at invoke_v (:8080/Build/webgltestweb.framework.js:14214:3)
    at main (:8080/Build/webgltestweb.wasm)
    at :8080/Build/webgltestweb.framework.js:1035:20
    at callMain (:8080/Build/webgltestweb.framework.js:17645:13)
    at doRun (:8080/Build/webgltestweb.framework.js:17688:21)
    at run (:8080/Build/webgltestweb.framework.js:17700:3)
    at runCaller (:8080/Build/webgltestweb.framework.js:17628:18)
    at Object.removeRunDependency (:8080/Build/webgltestweb.framework.js:990:4)
    at :8080/Build/webgltestweb.framework.js:60:12
    at doCallback (:8080/Build/webgltestweb.framework.js:4558:11)
    at done (:8080/Build/webgltestweb.framework.js:4569:5)
    at IDBTransaction.transaction.oncomplete (:8080/Build/webgltestweb.framework.js:3925:5)
$il2cpp::vm::MetadataCache::ExecuteModuleInitializers() @ webgltestweb.wasm:0x95ac9
$dynCall_v @ webgltestweb.wasm:0x151f793
(anonymous) @ webgltestweb.framework.js:1035
invoke_v @ webgltestweb.framework.js:14214
$main @ webgltestweb.wasm:0x135822d
(anonymous) @ webgltestweb.framework.js:1035
callMain @ webgltestweb.framework.js:17645
doRun @ webgltestweb.framework.js:17688
run @ webgltestweb.framework.js:17700
runCaller @ webgltestweb.framework.js:17628
removeRunDependency @ webgltestweb.framework.js:990
(anonymous) @ webgltestweb.framework.js:60
doCallback @ webgltestweb.framework.js:4558
done @ webgltestweb.framework.js:4569
transaction.oncomplete @ webgltestweb.framework.js:3925
webgltestweb.wasm:0x1464e31 Uncaught RuntimeError: memory access out of bounds
    at OrientationChangeHandler(int, int, int) (webgltestweb.wasm:0x1464e31)
    at dynCall_viii (webgltestweb.wasm:0x151f7e1)
    at webgltestweb.framework.js:1035:20
    at JS_ScreenOrientation_eventHandler (webgltestweb.framework.js:1882:37)
$OrientationChangeHandler(int, int, int) @ webgltestweb.wasm:0x1464e31
$dynCall_viii @ webgltestweb.wasm:0x151f7e1
(anonymous) @ webgltestweb.framework.js:1035
JS_ScreenOrientation_eventHandler @ webgltestweb.framework.js:1882
setTimeout (async)
_JS_ScreenOrientation_Init @ webgltestweb.framework.js:1900
$main @ webgltestweb.wasm:0x1350129
(anonymous) @ webgltestweb.framework.js:1035
callMain @ webgltestweb.framework.js:17645
doRun @ webgltestweb.framework.js:17688
run @ webgltestweb.framework.js:17700
runCaller @ webgltestweb.framework.js:17628
removeRunDependency @ webgltestweb.framework.js:990
(anonymous) @ webgltestweb.framework.js:60
doCallback @ webgltestweb.framework.js:4558
done @ webgltestweb.framework.js:4569
transaction.oncomplete @ webgltestweb.framework.js:3925
webgltestweb.wasm:0x1464e31 Uncaught RuntimeError: memory access out of bounds
    at OrientationChangeHandler(int, int, int) (webgltestweb.wasm:0x1464e31)
    at dynCall_viii (webgltestweb.wasm:0x151f7e1)
    at webgltestweb.framework.js:1035:20
    at JS_ScreenOrientation_eventHandler (webgltestweb.framework.js:1882:37)

I've tried this with both 2021 and 2020 and can't get it to work, any ideas?

1 Like

This looks very much like the known issue Unity Issue Tracker - WebGL Player freezes on startup when calling GetMonoManagerPtr. We have corrected it, and the fix should be available soon.

2 Likes

Great, thanks Josh!

Is there any known workaround or ETA?
I’m encountering this as well and am curious about the timeline for the fix.

Happening still as of 2021.2.14f1

Hello Josh, is there any way to find out what in the project can cause a similar error? It is not possible to switch to the alpha version of the editor

Yes, you can reflect the assemblies used in the project and look for module initializers. I’d recommend a tool like ILSpy for this. Those module initializers trigger this issue.

You can find out more about module initializers here: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-9.0/module-initializers

It looks like this fix should have already been back ported, but it got stuck in the release process somewhere. I’m trying to track that down now, so hopefully it will move forward soon.

Big thanks! Can you tell me when there will be information about the version of the editor in which this fix will be, please?

Yes, watch this link for those details: https://issuetracker.unity3d.com/is…zes-on-startup-when-calling-getmonomanagerptr

@JoshPeterson Do you know if theres any update on this? I see it was fixed in the 2022.2.x release but the backports are pending.

We are running 2021.3.X and are running into this issue when trying to add netcode to our existing game so I am hoping you have a fix soon.

I don’t have an ETA on a release for 2021.3, sorry. I do know that the fix in in a release branch, so I expect it will happen within the next few weeks.

Thanks greatly appreciate the response - so whats weird is this doesn’t happen on all projects for me. I have a webgl version running netcode and it works fine but then I tried to add this to another project and it breaks.

Do we have a root cause on it? Maybe theres something I could change in my project to make it work in the meantime.

Yes, the original problem was a bug in the way IL2CPP handled module initializers (see the link above in this thread for details about them). The netcode code uses them, so I’m surprised that this works sometimes, because I think that it should always fail if the module initializers are used.