Receiving this error in Unity 5.6.0f3 with a WebAssembly build: exception thrown: RuntimeError: index out of bounds,wasm-function[944] This happens after onRuntimeInitialized is called on the WebGL module but before the first debug is printed from the game client itself. Build Settings: Data caching is ON, and Enable Exceptions are Explicitly thrown. Any thoughts? Thanks.
Which browser? Could you try a different one? (perhaps you get a better error) Any problem in asm.js (wasm disabled)?
Marco, The error above is from FireFox 53. I get this in Chrome 57.0.2987.133: exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds at (<WASM>[944]+28) at (<WASM>[42281]+249) at (<WASM>[42201]+458) at (<WASM>[42196]+45) at (<WASM>[42195]+1) at (<WASM>[30326]+67) at (<WASM>[30321]+148) at Object.UnityLoader.69624c7248aa625792505cdcc3bef985.Module._main (blob:...) at Object.callMain When built without WebAssembly, the build runs fine. BTW, is there a way to disable WebAssembly even after it is built? Just removing the WASM URLs from the JSON file? Thanks.
add Code (csharp): UnityLoader.SystemInfo.hasWasm = false; to the generated html, right before calling UnityLoader.instantiate()
So I may have figured out the issue. Somehow the Standard Shader got included in the build (via Graphics Settings->Always Include Shaders) which blew up the data file size to >20MB. When this is removed, the data file size is significantly smaller (1.6MB in our case) and the build seems to run fine (so far)...
Welp, that didn't last long: UnityLoader.js?_=1493989526999:1 Invoking error handler due to Script error. wasm-03b8803e-27828:7 Uncaught RuntimeError: memory access out of bounds at (<WASM>[27828]+12) at (<WASM>[27826]+145) at (<WASM>[30239]+25) at UnityLoader.47c5673658101c1a5e0e999eb44b3e52.Module._SendMessage So it seems to happen on some SendMessage calls from javascript into Unity.
To be honest, I don't quite recall. It may have been that we were trying to override the TOTAL_MEMORY value in the Unity loader module which isn't allowed in WebAssembly (which is what I think Marco was getting at).
Hi @Marco-Trivellato , @sirrus, @Gaurav-Gulati I'm also facing my problem when build and run Unity WebGL on 2 browsers and get difference results: --- Firefox: index out of bounds. --- Chrome: memory access out of bounds. WebGLMemorySize: default 256. Can you help me resolve my problem? Thank you so much
Commented in the other thread https://forum.unity.com/threads/webgl-failed-to-build-my-project.632122/#post-5015351 . When you see an error like index out of bounds, try doing a Development build and get the callstack of where the error occurs from there. That can give a clue as to whether it is a Unity bug or a browser bug, or something else.
Unity WebGL exports are not currently tailored for mobile use, but nothing is really stopping you from doing so. If you edit the UnityLoader.js script inside Unity installation tree, you can remove the mobile WebGL unsupported notification dialog. Check out other threads in this forum for tips and recommendations on how to optimize for mobile use.