[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Public WebGL] Possibility of not writing gl_Position is not addressed by WebGL spec
As long as we are discussing this, I feel it's worth mentioning an issue I had previously blamed myself, not the spec, for.
My WebGL framework includes a modularized shader pre-compiler that is smart enough to generate one shader from many distinct sources, in an attempt to improve code reuse across shaders. (The idea is not unlike the WebGL linker, except that with my approach, you can have more than one main() and the pre-compiler will figure out what to do with them all; and each module can run in isolation if the dev wishes to do so.) The unit tests for this part of my framework frequently involved compiling shaders which did not write to gl_Position. Many of them also did not write gl_FragColor. (There was no particular reason _not_ to write to these values -- it's just, writing them was not necessary in order to pass the unit tests in question, so it did not occur to me to write them.)
Most of the time this was fine, but I ran into intermittent crashes that had system-wide effects. As the test suite grew into the hundreds, this became more and more frequent. This was a year or two ago and I don't remember many specifics, but I do remember having to reboot my machine; it was in an unstable state even after shutting down all browsers. I tested primarily on Chrome and Firefox, with a Mac.
My solution was to enforce that the shader builder will always write a default value to gl_FragColor and gl_Position at the beginning of the shader's main(), to be overwritten by the modules as they executed. This resolved the issue, and since my use case seems pretty obscure, I did not see it as worth mentioning.
However, in hindsight I can see this might be an attack vector or at least a major issue if the crashing is not isolated to just my hardware. If it is reproducible in the latest browsers and is a widespread result, it may need to be addressed.