Unity WebGL with Speckle

Hi Speckle team,

I am a Unity dev at Arup and I’m trying to make a build of the project in WebGL format. I saw another post from 2021 where you mentioned that WebGL is not possible. Have there been any changes since then? I got a bunch of errors on the build so was wondering where the product stands in this regard. Thanks for your time! :slight_smile:

1 Like

Hi @armanayra, Welcome to the forums.

WebGL building is not something that we support. There have been previous attempts to get this working, but unsuccessful due to a few reasons.

  1. Unity WebGL doesn’t support the System.Threading namespace, which we use throughout core, and the Unity Connector.

  2. Our Sharp Core has managed dependencies (sqlite)

    • I’m unsure how Unity handles managed DLLs for WebGL building, It may not be possible.
  3. Not a hard blocker, but WebGL has no disk access, so we can’t load accounts, or cache objects the same way as normal. But there are workarounds, see this thread.

Taking a look at our main branch, building for WebGL fails with some dependency conflicts.

This is because several of the managed dlls are being included for WebGL builds, which causes some conflicts.
I was able to get a build working, by simply disabling all but the win-x64 managed assemblies. (see this branch) However, trying to run this yielded the common “stuck at 90% progress” problem.
This maybe because of System.Threading, or SQLite…

You are welcome to experiment more,
However, I fear you may run-into the same blockers I did. WebGL building may simply not be possible without some serious restructuring of our core.

Perhaps you have some deeper insights to workaround Unity WebGL’s limitations. It’s not something I’m intimately familiar with developing for.
I’d be happy to discuss this further, and see what progress we can make. But I can make no promises from our end.

Hi Jedd and thanks for the detailed reply,

I believe that I received that exact error as well when trying to make a Unity WebGL build with the Speckle plugin.

Plugin 'libe_sqlite3.so' is used from several locations:
Packages/systems.speckle.speckle-unity/Runtime/Core/linux-x64/native/libe_sqlite3.so would be copied to <PluginPath>/libe_sqlite3.so
Packages/systems.speckle.speckle-unity/Runtime/Core/linux-arm/native/libe_sqlite3.so would be copied to <PluginPath>/libe_sqlite3.so
Packages/systems.speckle.speckle-unity/Runtime/Core/linux-arm64/native/libe_sqlite3.so would be copied to <PluginPath>/libe_sqlite3.so
Plugin 'e_sqlite3.dll' is used from several locations:
Packages/systems.speckle.speckle-unity/Runtime/Core/win-x86/native/e_sqlite3.dll would be copied to <PluginPath>/e_sqlite3.dll
Packages/systems.speckle.speckle-unity/Runtime/Core/win-x64/native/e_sqlite3.dll would be copied to <PluginPath>/e_sqlite3.dll
Please fix plugin settings and try again.

I see that this is a limitation on JavaScript’s ability to perform multithreading as you have linked and described. Our inspection web/web-mobile app uses React, so I suppose we would need to try something different. Thanks again!