7

I have some javascript/webgl code. I want to have some idea of whether it will work for someone with a different browser/machine/gpu.

This is difficult, because there's so much diversity in support for features. For example, on my machines, I can pass GL.FLOAT to readPixels, but I know that really I should only use GL.UNSIGNED_BYTE. Another example is that, when webgl compiles a fragment shader at runtime, one of my machines will accept vec4(1, 0, 0, 0) while the other will complain that implicit casts from int to float aren't allowed. I even have some code that works on my phone in chrome, but not on my phone in firefox, for no discernible reason.

How can I test if my webgl code conforms to the standard? How can I estimate how many users it will work for in practice?

Maybe there exist interpreters with minimal feature sets that run the code, and if it works in the interpreter you can be sure it will work for most users? Or maybe there are services that run your code on many machines? Maybe a particular old phone is a good 'minimal support' candidate for testing?

(I tried using SauceLabs to run it on a variety of machines, but they don't support webgl so that's a bust. Also there's always the fallback of just waiting for people to complain...)

1 Answers1

1

A combination of benchmarks for each class of device is necessary:

Create a set of benchmarking tools by selecting a benchmark in each domain to get to a comprehensive view of platform performance.

Data collection based on community effort is a necessity:

WebGL Stats

As well as defining criteria for determining benchmark quality:

Intel believes that good benchmarks should meet both of these two basic criteria:

  1. The benchmark uses real applications or benchmark applications executing real workloads, and be based on real-world scenarios and workflows

  2. The benchmark was designed with industry stakeholder input baked into the development process, guided by industry best practices and transparency

Some WebGL implementations support the failIfMajorPerformanceCaveat API:

var canvas = document.getElementById('renderCanvas');
var context = canvas.getContext('webgl', 
    { 
     failIfMajorPerformanceCaveat: true 
    }
);

When a context is requested on a computer with a block-listed driver, the failIfMajorPerformanceCaveat flag prevents IE from returning a software context, and instead returns no context.

To use it you just have to add it as an option to the getContext function:

Using this attribute, you can know that the current device isn't powerful or secure enough to run hardware accelerated 3D rendering. Then you can decide to use the software renderer, or if you prefer, let the user know their computer or graphics card aren't supported.

References