Build fails for WebGL on Unity 2022.2 (new Emscripten)
See original GitHub issueAfter upgrading to unity 2022.2 my project build fails with the following error:
Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js: undefined symbol: _ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5_ (referenced by top-level compiled C/C++ code)
I’m thinking this is caused by the new Emscripten version
After searching files for the symbol name it seems to originate from the WebGL Plugin “libdracodec_unity.a” ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC1ERKS5
\Library\PackageCache\com.atteneder.draco@4.0.2\Runtime\Plugins\WebGL\libdracodec_unity.a (5 hits) Line 6456 Line 12534 Line 13293 Line 14564 Line 15409
Looking for advice on how to fix this. We want to use the new features of this unity version
Unity forum link: https://forum.unity.com/threads/builds-failing-after-upgrading-to-2022-2.1385088/
Issue Analytics
- State:
- Created 8 months ago
- Comments:11 (3 by maintainers)
Hi folks,
TL;DR: I can give you an immediate workaround right now and we’re working on a convenient long-term solution.
Problem
Native Draco libraries are compiled into WebAssembly via Emscripten. Different versions of Unity use different versions of Emscripten. Not all of them are compatible, so one has to compile the libs with the exact version Unity uses. The lack of Unity version settings on native libraries makes it impossible to provide one package that works across a large range of Unity versions.
What I did so far
In the past I just bumped the major release number, so we ended up with:
I could make 5.x support 2022 and 6.x the upcoming 2023.2, but that has downsides:
Solution
As said, unfortunately Unity does not offer a solution here. What we’ll do is split the WebAssembly binaries into sub-packages. One for each Emscripten version. The main package will contain code, that automatically configures your project, so that you’ll end up with a working built with one click.
This is in the making, but releasing a package properly involves some work and multiple parties. Your patience is appreciated.
Workaround for Unity 2022 and newer
WebGL/2022/*.a
over into the package subfolderRuntime/Plugins/WebGL
Again, sorry for the delay and thanks for your patience.
@atteneder Can confirm your solution works.
The issues I encountered were not caused by DracoUnity, but just manifested there. I was finally able to pin down a threading issue that we reported to Unity.