Unity 2021.2.0f1 webgl build failures - emscripten

Hello! I’ve migrated a project up to the unity 2021.2.0f1 that was working fine before in version 2021.1, and having issues building. I’ve exported the files to a fresh project and receive the same errors. I think it’s related to the fact that wasm builds are using Emscripten 2.0.19 now in the 2021.2 version according to this Unity release post:
UnityBlog

I’m wondering if there is a way for me to get around this, or if I should rollback the project to the previous version to workaround this? Thanks for everything!
Kevin

Here is the build error I’m getting:
Building Library\Bee\artifacts\WebGL\build\debug_WebGL_wasm\build.js failed with output:
wasm-ld: error: Assets/Plugins/FMOD/lib/html5/libfmodstudiounityplugin.bc: machine type must be wasm32 or wasm64
emcc2: error: ‘“C:/Program Files/Unity/Hub/Editor/2021.2.0f1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/llvm\wasm-ld.exe” @C:\Users\blanc\AppData\Local\Temp\emscripten_bcfxrfdn.rsp’ failed (1)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Thank you for letting us know, I have reproduced your issue in the latest Unity Editor version. The last two FMOD releases are built against emscripten 2.0.20 so I don’t think it’s a version issue, in any case I have passed this issue along to our dev team to look into.
In the meantime I think rolling back to your old Unity version is a good idea!

Thanks a lot for the information Jeff. I’ve rolled back currently. Just wondering, when this is updated will there be a new unity FMOD version rolled out that I can download in the store? This is the first time I’ve ran into something like this. Take care!

Kevin

There will be a new version rolled out to the Unity asset store- usually it’s every 2nd release, you will be able to download it from our Download page if you don’t want to wait for it to come to the asset store.

Awesome, thanks a lot Jeff for the help!

Hello! Apologies for resurrecting a dead thread–I just wanted to let you know that I’ve run into this error, not running the Unity WebGL build process on a local machine, but in the cloud via github actions.

Edit, 2:53pm Jan 16: As of Unity 2021.2.0 emscripten version is 2.0.19; as far as I can tell this is still true in Unity 2021.2.8.

I can successfully build a WebGL project from my M1 Mac laptop, but can’t from an ubuntu-latest runner on github. Both are targeting a Unity 2021.2.8f1 project.

Here is a link to my failed github actions run:

And here is the specific error from the logs:

##### CommandLine
"/opt/unity/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/emscripten/emcc" @"Library/Bee/artifacts/rsp/8995565923215908413.rsp"

.......

##### Custom Environment Variables
EM_CONFIG=/opt/unity/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/.emscripten
EMSDK_PYTHON=python3
EMCC_SKIP_SANITY_CHECK=1
EM_FROZEN_CACHE=1
##### ExitCode
1
##### Output
wasm-ld: error: Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc: machine type must be wasm32 or wasm64
emcc2: error: '/opt/unity/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/llvm/wasm-ld -o Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.wasm /tmp/tmpoe6ehm_sGameAssembly..a  [..... truncated, see link for full ]

........

*** Tundra build failed (389.10 seconds - 0:06:29), 259 items updated, 486 evaluated
Building Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.js failed with output:
wasm-ld: error: Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc: machine type must be wasm32 or wasm64
emcc2: error: '/opt/unity/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/llvm/wasm-ld -o Library/Bee/artifacts/WebGL/build/debug_WebGL_wasm/build.wasm /tmp/tmpoe6ehm_sGameAssembly..a  [... truncated]

.........

(Filename: /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs Line: 439)

BuildFailedException: Incremental Player build failed!
  at UnityEditor.Modules.BeeBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args) [0x00165] in /home/bokken/buildslave/unity/build/Editor/Mono/Modules/BeeBuildPostprocessor.cs:556 

Any thoughts? Thank you! --Alex

I haven’t been able to reproduce this error on Linux with the latest version (2.02.05) and with Unity 2021.2.8f1. What version of FMOD are you using?

Hi there! Thanks for the response :slight_smile:

Just to reiterate–the problem doesn’t replicate on local hardware for me; it only shows up in linux cloud build. If you see the previous post there’s a link to the github workflow where the cloud build is configured (Github runner hosted in Azure cloud using ubuntu 20.04LTS.)

I’ve tried with both 2.02.04 and 2.02.05, only on 2021.2.8f1.

The unity cloud build images in general haven’t proven to be super reliable–for instance the MacOS target fails not because of FMOD but because of a misnamed dependency filepath.

I do think this has something to do with emscripten version mismatch but it’s likely on Unity’s end, not yours. Emscripten is directly bundled into Unity’s build image, and they probably haven’t updated the pinned version. (I’ve submitted a bug report with Unity, too, but haven’t heard anything.)

Have a good week! -Alex

I agree it has all the symptoms of the original version mismatch issue- which has been fixed in local builds since 2.02.04. I have created a task to investigate this using github actions and see if we run into the same issues on remote builds.
Have a good week too!

1 Like

Hi! Any update on the situation ? I’m running into the exact same problem, except with Unity 2021.3.0f1. Local WebGL build works just fine, but GitHub actions build doesn’t.

@jeff_fmod forgot to tag you! Sorry for the necro thread

We did some preliminary investigation into various automated Linux builds which were working fine, but didn’t get as far as setting up GitHub actions as it was turning into a rabbit hole.
Have you setup GitHub actions yourself or are you using existing actions such as Unity Builder?

Thanks for the quick reply!
I’m using Unity Builder from game-ci, with specificaly the Ubuntu 2021.3 WebGL image for the WebGL build. I’m using the default Linux image for my Standalone Windows build and it works perfectly fine with the FMOD plugin. For the WebGL build,
I’m getting the error line
wasm-ld: error: Assets/Plugins/FMOD/platforms/html5/lib/libfmodstudiounityplugin.bc: machine type must be wasm32 or wasm64.
Do you think it’s possible that the problem comes from the Unity Builder Linux WebGL image ? Something like their emscripten version isn’t the same as the version for the windows build ?
Thanks again for your support!

Thanks for the extra info, I think the emscripten versions are fine. It looks like the FMOD integration is returning a .bc file instead of a .a file. If you take a look at “Plugins/FMOD/platforms/hrml5/src/PlatformWebGL.cs”, the GetBinaryPath() method is supposed to return the path to a .a file if the UNITY_2021_2_OR_NEWER preprocessor directive is defined, or the .bc if it isn’t. Somehow, UNITY_2021_2_OR_NEWER doesn’t seem to be defined.
You might be able to get a successful compile by forcing this method to return the path to the .a binary:

public override string GetPluginPath(string pluginName)
{
    #if UNITY_2021_2_OR_NEWER || true // Force wasm
    return string.Format("{0}/{1}.a", GetPluginBasePath(), pluginName);
    #else
    return string.Format("{0}/{1}.bc", GetPluginBasePath(), pluginName);
    #endif
}

I got it to compile!
The fix mentionned above did not succeed per se, but the logic of it worked.
Even with the || true override, it didn’t seem to return the proper .a file. It would always pick the .bc file.
So I just took the .a file and copied its contents into the .bc file, erasing the .bc file’s original content.
It’s a really hacky fix but it worked for me.
Thank you so much for your help!

I still have errors when I try to run the built game in my browser, errors that do not appear when I build it locally but I’m not sure they’re related to FMOD. Will keep the thread updated if they are.

Super hacky, thanks for testing and confirming. PlatformWebGL.GetBinaryFiles also has a check on UNITY_2021_2_OR_NEWER, it might be worth forcing that check to evaluate to true as well. If the issue really is that UNITY_2021_2_OR_NEWER is not defined then I imagine you would be getting issues with scene management and probably some deprecation warnings as well. Let me know if there are any FMOD related errors and I will investigate further

Hi! Im having the same issue, @charlesmurphy could you share your code? That would be a huge help. Thanks so much!

Hi!
The errors I now have seem to be related to gameci’s ubuntu 2021.3 images and not FMOD.
Concerning the FMOD problem, I really didn’t use any specific code, I just replaced the .a file’s contents with the .bc’s :slight_smile:

1 Like