question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Build fails for WebGL on Unity 2022.2 (new Emscripten)

See original GitHub issue

After 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:open
  • Created 8 months ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
attenedercommented, Jun 2, 2023

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:

  • DracoUnity 3.x, which works for Unity (2019-) 2020
  • DracoUnity 4.x, which works for Unity 2021

I could make 5.x support 2022 and 6.x the upcoming 2023.2, but that has downsides:

  • Supporting 4 releases in parallel is much more work
  • Breaks the concept of semantic versioning. Imagine there’s a new API breaking feature. How do you bump versions now?

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

  1. Download a copy of the most recent DracoUnity 4.1.0 and unzip it.
  2. Download the Draco binaries 1.1.0 I’ve built via GitHub Actions and unzip it.
  3. Copy the library files in WebGL/2022/*.a over into the package subfolder Runtime/Plugins/WebGL
  4. Open your project with Unity 2022 or newer and install DracoUnity from the local copy you just altered
  5. Try to make a WebGL build

Again, sorry for the delay and thanks for your patience.

1reaction
PTC-sradlwimmercommented, Jul 10, 2023

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug - Builds failing after upgrading to 2022.2
I tried newly released 2022.2.1f1 but (clean) builds are now failing in the "Linking build.js (wasm)" phase with an unclear error message.
Read more >
WebGL build times have regressed - Unity Issue Tracker
I upgrade my project from 2021.3.21f1c1 to 2022.2.12f1c1, the problem remains. 10 minutes later, the wasm-Id.exe is occupied 3G memory space.
Read more >
WebGL build fails when building with a native library if ...
This error is generated because the project contains a package which includes a pre-compiled plugin for Web built with the Emscripten toolchain.
Read more >
Unity WebGL: Issues with TextBox. Noesis 3.1.7 Unity 2022.2
Version of emscripten used by Noesis must be aligned with the version used by Unity. If the major versions are not aligned, it...
Read more >
Emscripten Error when building to WebGL
Some time ago I believe I had the same issue. Turned out to be because I had a separate install of Python 2.7...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found