Search Issue Tracker

Fixed in 2021.1.X

Fixed in 2019.4.X, 2020.2.X

Votes

6

Found in

2019.1.10

Issue ID

1174367

Regression

No

[WebGL] Build crashes if metadata is too large

WebGL

-

WebGL build fails to start with the following error messages:

exception thrown: abort({}) at jsStackTrace@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:942:12
stackTrace@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:956:11
onAbort@http://localhost/htdocs/Build/UnityLoader.js:1139:50
abort@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:29036:10
___syscall192@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:8582:67
___mmap@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e line 1379 > WebAssembly.instantiate:wasm-function[177106]:0x31a401b
__ZN6il2cpp2os16MemoryMappedFile4ViewEPNS0_10FileHandleEPxxNS0_22MemoryMappedFileAccessES4_PNS0_21MemoryMappedFileErrorE [il2cpp::os::MemoryMappedFile::View(il2cpp::os::FileHandle, long long, long long, il2cpp::os::MemoryMappedFileAccess, long long, il2cpp::os::MemoryMappedFileError)]@blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e line 1379 > WebAssembly.instantiate:wasm-function[174667]:0x314c36a
...

TypeError: "attempting to access detached ArrayBuffer"
mmap blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:4914
mmap blob:http://localhost/067d1180-5ec5-445e-81dd-59c458c82b5e:6692
...

The problem is in the system libraries of the Emscripten compiler that is used to target WebAssembly. A fix to the compiler has been posted and landed at https://github.com/emscripten-core/emscripten/pull/9012 .

The fix will eventually find its way to an upcoming Unity release when we update the Emscripten compiler to a new version, but there is, unfortunately, no release ETA for that, since compiler change affects all components of Unity, and needs a complete testing process.

If you want, you can locally patch your Emscripten compiler to carry the fix, by changing the two lines as shown by diff https://github.com/emscripten-core/emscripten/pull/9012/commits/89a380770902eb1221874765a11023e24133ca52 in file library_memfs.js inside Unity installation tree.

Another workaround can be to use a Unity editor script to assign "PlayerSettings.WebGL.memorySize = 256;" or similar so that the deployed build has a large enough heap at startup to avoid the issue.

Comments (3)

  1. robertirribarren

    Apr 17, 2020 01:08

    Had this issue on 2019.3 release version as well.

  2. Twyker_gp

    Feb 04, 2020 16:55

    Had this issue on 2019.3 release version. Only replacing the code as mention above did the trick.

Add comment

Log in to post comment