Hi Guys,
Just to preface where I'm coming from, my name is Alan Wolfe and I am a professional game developer with 15 years of professional experience. I'm currently a senior graphics and engine programmer working at Blizzard on starcraft 2 and Heroes of the storm. But, of course, this message is me speaking to my own thoughts and opinions and is not the opinion of my employer (yadda yadda) (:
Anyhow, I wanted to talk about shader compiles in webgl and see if the problems I want to point out are being worked on or not.
The core problem is that there is no way to know when a shader is finished being compiled.
The common pattern for dealing with shader compiles is to compile the shader and then check it's status for errors right away. That has the known issue that it will block until the shader is finished compiling if it's not yet finished.
If that blocking time is too long, browsers will "time out" and say that webgl has crashed, when it hasn't, but is just doing a long compile. You can't blame the browsers for doing this, as they are essentially faced with the halting problem :P
Using that solution, you can do some other work, and then later check the shader compile status for errors, at which point, hopefully the shader you are working with is finished compiling, else it will block until it's finished.
That helps the problem, but unfortunately not in any meaningful way for serious applications.
The issue is that we can do "other work" or even delay checking the status of the shader compile / using the shader, but we don't know how long we need to wait until we can do that!
That means there is no way to eliminate these false positive "webgl has crashed" issues. You could put in extra delays before rendering, but then you are just making longer loading times than necessary for people with faster machines, while still not eliminating the problem for lower end machines. This isn't just perceived instability, but ACTUAL instability, as users cannot use the programs if the shader compiles take too long.
Under these circumstances, any serious application using webgl really can't be made, other than by sticking to only very simple graphics and having a very low number of shaders.
What we really need is some callback mechanism to know when a shader is done being processed. This would let me kick off my 50 shader compiles or whatever, and show a progress bar that increments 1/50th of the way whenever a shader is reported as finished.
At the end of the progress bar, assuming there were no errors, I would then know it's safe to use any of the shaders I compiled without possibly hitting a "webgl crashing" browser stall.
Is this something already planned to be "fixed" or addressed in some way?
Me and my colleagues would *LOVE* to use our professional gamedev experience to make some real webgl games and hopefully help grow the platform, but in it's current state it really isn't even useable for any serious applications, due to this one very minor, and seemingly easily fixed problem. A lot of people are also very interested in web vr, but unfortunately, it has this same issue so is a non starter.
Please also let me know if there's somewhere else I ought to bring this up!
Thanks for your time,
Alan