We are having an issue with GPU instanced materials in WebGL. We have our Shader and ShaderVariantCollection bundled together along with materials in a single AssetBundle… after we have our assets loaded, we call WarmUp() on the shader variant collection… it works ‘ok’ in Chrome - takes about 10 seconds to warm up the Shader variants. However in Firefox, it takes about 3 minutes. Anyone have any ideas?
As a side note… warming up a single shader variant in FireFox takes ~20 seconds to compile, but when Instantiating the GameObject that uses the shader variant, it takes less than ~1 second to compile the shader variant.
1 Like
This could likely be due to this bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1072132
While that issue is in the Chromium tracker, Firefox also uses ANGLE, where the slowdown resides. (although it is odd that performance is better in Chromium, I wonder if they have a newer version of ANGLE and ANGLE might have improved here)
Try using Firefox Profiler (https://profiler.firefox.com/) to capture a profiler vs Chrome, to see if there are any lopsided performance characteristics that would show up.
So it looks like I was mistaken, it is affecting Chrome. Chrome takes about ~1.2 mins executing the shader warmup call on a freshly launched version of Chrome… about ~5 seconds on subsequent loads.
FireFox takes about ~2.5 mins.
Chrome:
FireFox:
Ok, yeah, this is then very likely the bug https://bugs.chromium.org/p/chromium/issues/detail?id=1072132 - ANGLE team has mentioned that they would have an idea how to speed things up.
What might help is if you can throw a comment there “I believe our Unity project is affected by this issue too. Here is a link to the page to test: ”, if the project is something that you can share on the Google bug tracker.
Oh, “the slow first time vs fast subsequent times” behavior is due to Chrome’s shader compilation cache, where they store precompiled shaders on disk for subsequent runs.
The Chromium bug is not fixed yet and it’s unknown when it will be fixed but it causes a lot of problems because we have to choose between hiccups in the middle of the game (if we choose not to warm up shaders) and very long loading times (moreover, Firefox doesn’t cache shaders, so the game doesn’t load quickly in subsequent runs.)
ShaderVariantCollection.WarmUp() is not async, so we cannot have an animated loading screen. I found there is a ShaderWarmup.WarmupShaderFromCollection method which in theory can allow us having a loading screen. However, there is no information about the ShaderWarmupSetup struct. @jukka_j , what can we put there to simulate the same behaviour as ShaderVariantCollection.WarmUp()? Will WarmupShaderFromCollection be significantly slower than warming up all shaders at once?
1 Like
@jukka_j The bug was opened over a year ago, and it’s not resolved yet. The conversation stopped when they asked if Unity can provide shader sources. Could you answer them to push the issue to some resolution?
1 Like