WebGL run fails with failed thread creation
I've built from UnityGLTF from master, added the GLTFComponentto a scene to load a remote GLTF and disabled multithreading. When I built to WebGL I get the following error. I've found that the 1.0.0 release builds and runs in webgl.
Related: #138
SystemException: Thread creation failed.
UnityLoader.js:1043 at System.Threading.Thread.StartInternal (System.Security.Principal.IPrincipal principal, System.Threading.StackCrawlMark& stackMark) [0x00000] in <00000000000000000000000000000000>:0
UnityLoader.js:1043 Rethrow as TypeInitializationException: The type initializer for 'System.Threading.Timer.Scheduler' threw an exception.
UnityLoader.js:1043
UnityLoader.js:1043 Rethrow as TypeInitializationException: The type initializer for 'System.Threading.Timer' threw an exception.
UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
UnityLoader.js:1043 --- End of stack trace from previous location where exception was thrown ---
UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
UnityLoader.js:1043 --- End of stack trace from previous location where exception was thrown ---
UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
UnityLoader.js:1043 --- End of stack trace from previous location where exception was thrown ---
UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
UnityLoader.js:1043 --- End of stack trace from previous location where exception was thrown ---
UnityLoader.js:1043 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <00000000000000000000000000000000>:0
Apologies, forgot platform information:
Unity 2018.3.1f1 OS X: 10.14.2 master @ bb189f382697317321a583b22f0aab3692414366
I've just tried and I have the same thread creation errors. Unity 2018.3.3f1 Windows 10
it says also: "(Filename: currently not available on il2cpp Line: -1)"
@kolodi that's interesting. I assumed it was because WebGL doesn't support threads. With that said, I had disabled multithreading and removed a Task.Delay that I thought might have been the cause and I still got the error.
@kolodi that's interesting. I assumed it was because WebGL doesn't support threads. With that said, I had disabled multithreading and removed a
Task.Delaythat I thought might have been the cause and I still got the error.
I think it is web client (from .net) which can also use multithreading as it is one from the .net and not the standard unitywebrequest
We have not tested with WebGL. If the Task libraries are not allowed, we will have to rework this. WebGL support is likely going to be on our roadmap very soon.
Nice to hear. I have several projects to target stand alone, mobile and WebGL platforms. For now I am forced to use asset bundles. If I could use GLB on all platforms it would be a huge benefit. I could contribute in making http handler compatible with WebGL, for example based on UnityWebRequest...
We have a slightly modified version of the app running on WebGL.
You can try this:
-
Revert
WebRequestLoader.csto this version: https://github.com/KhronosGroup/UnityGLTF/blob/83d267f2616585fc8aba5391c003c9a5538ada97/UnityGLTF/Assets/UnityGLTF/Scripts/Loader/WebRequestLoader.cs -
Alter this line https://github.com/KhronosGroup/UnityGLTF/blob/bb189f382697317321a583b22f0aab3692414366/UnityGLTF/Assets/UnityGLTF/Scripts/GLTFComponent.cs#L100 to
loader = new WebRequestLoader(directoryPath, asyncCoroutineHelper); -
And this line https://github.com/KhronosGroup/UnityGLTF/blob/ce8485e3b982d1349f1b4b086cba421faf9b11fb/UnityGLTF/Assets/UnityGLTF/Examples/MultiSceneComponent.cs#L24 to
loader = new WebRequestLoader(directoryPath, _asyncCoroutineHelper); -
Disable the
Multithreadedproperty from theGLTFComponent.
@edumlauer how as the performance been for you? I don't have any benchmarks to report, but generally I've found its very slow to load even small models.
@edumlauer how as the performance been for you? I don't have any benchmarks to report, but generally I've found its very slow to load even small models.
We use glbs with mesh data only, we dont' have textures on them.
Loading models from disk:
- 857 KB - 355 ms
- 15 MB - 2000 ms
- 82 MB - 6500 ms
I don't have anything to compare with to say wether its fast or not, but it has been good enough for us.
@edumlauer how as the performance been for you? I don't have any benchmarks to report, but generally I've found its very slow to load even small models.
We use glbs with mesh data only, we dont' have textures on them.
Loading models from disk:
- 857 KB - 355 ms
- 15 MB - 2000 ms
- 82 MB - 6500 ms
I don't have anything to compare with to say wether its fast or not, but it has been good enough for us.
I realize now that this tests were made in the editor, so I'm not sure how they compare to a webgl build. But as I said earlier results in general have been great, the thing that contributes to slower load times are download speeds that vary for each user.
We have a slightly modified version of the app running on WebGL.
It seems to download now, but I have another exception:
ShaderNotFoundException: GLTF/PbrMetallicRoughness not found. Did you forget to add it to the build?
I have a GLB file to download with PBR materials. It works fine in the editor, but the shader is not included then in the build. How can I be sure to include all the necessary shaders for every possible model?
So I have included 2 shaders in the graphics settings
- PbrMetallicRoughness
- PbrSpecularGlossiness
Then I was waiting for like 3 hours for building, then I realize that it repeats "compiling shader variants" infinitely:

We have a slightly modified version of the app running on WebGL.
You can try this:
Revert
WebRequestLoader.csto this version: https://github.com/KhronosGroup/UnityGLTF/blob/83d267f2616585fc8aba5391c003c9a5538ada97/UnityGLTF/Assets/UnityGLTF/Scripts/Loader/WebRequestLoader.csAlter this line
[UnityGLTF/UnityGLTF/Assets/UnityGLTF/Scripts/GLTFComponent.cs](https://github.com/KhronosGroup/UnityGLTF/blob/bb189f382697317321a583b22f0aab3692414366/UnityGLTF/Assets/UnityGLTF/Scripts/GLTFComponent.cs#L100) Line 100 in [bb189f3](/KhronosGroup/UnityGLTF/commit/bb189f382697317321a583b22f0aab3692414366) loader = new WebRequestLoader(directoryPath);to
loader = new WebRequestLoader(directoryPath, asyncCoroutineHelper);And this line
[UnityGLTF/UnityGLTF/Assets/UnityGLTF/Examples/MultiSceneComponent.cs](https://github.com/KhronosGroup/UnityGLTF/blob/ce8485e3b982d1349f1b4b086cba421faf9b11fb/UnityGLTF/Assets/UnityGLTF/Examples/MultiSceneComponent.cs#L24) Line 24 in [ce8485e](/KhronosGroup/UnityGLTF/commit/ce8485e3b982d1349f1b4b086cba421faf9b11fb) _loader = new WebRequestLoader(directoryPath);to
loader = new WebRequestLoader(directoryPath, _asyncCoroutineHelper);Disable the
Multithreadedproperty from theGLTFComponent.
@edumlauer Can we merge this to the master wrapping the solution for the WebGL with #if UNITY_WEBGL so everyone can use it and close this issue?
Yeah, it would be great if you could send out a PR. We could get it merged quickly :)
Yeah, it would be great if you could send out a PR. We could get it merged quickly :)
Ok, I'm gonna work on it
So I have included 2 shaders in the graphics settings
- PbrMetallicRoughness
- PbrSpecularGlossiness Then I was waiting for like 3 hours for building, then I realize that it repeats "compiling shader variants" infinitely:
Why is that build process so miserable?
So I have included 2 shaders in the graphics settings
- PbrMetallicRoughness
- PbrSpecularGlossiness Then I was waiting for like 3 hours for building, then I realize that it repeats "compiling shader variants" infinitely:
Why is that build process so miserable?
The Scene Loader for some reason wants to use always those 2 shaders for every loaded 3d model even if the model was made using simple unity default shaders. That is really strange. And you should include those 2 shaders in the graphics settings in order to have them in the build. Now building takes ages to compile thousands of shader variants.
Yeah, it would be great if you could send out a PR. We could get it merged quickly :)
I have made necessary changes to solve the issue, but I can't publish the new branch with the fix to be able to make a PR.
You should be able to fork the repo and create a branch that will allow you to submit a PR (see https://guides.github.com/activities/forking/)
You should be able to fork the repo and create a branch that will allow you to submit a PR (see https://guides.github.com/activities/forking/)
Ok, please review my PR