W3C home > Mailing lists > Public > public-fx@w3.org > January to March 2012

CSS shaders DoSing the browser?

From: (wrong string) 勤 <gman@google.com>
Date: Wed, 29 Feb 2012 18:56:04 -0800
Message-ID: <CAKZ+BNre-pXgK9-WS-96R5t3a6xh5W+Ei0h4VD8s3GPXxXZxGw@mail.gmail.com>
To: "public-fx@w3.org" <public-fx@w3.org>
Cc: Chris Marrin <cmarrin@apple.com>, Vincent Hardy <vhardy@adobe.com>, Dean Jackson <dino@apple.com>
As you're probably aware, it's possible to effectively lock up certain
machines by giving the GPU something that takes a long time to do.

Windows gets around this problem by resetting the GPU after a couple of
seconds if it becomes unresponsive.
Newer Linux GL drivers support the GL_ARB_robustness extension that
provides a similar feature to Windows.
In the future GPUs will be preemptive.

In particular though, XP machines, OSX, iOS and Android as far as I know
all basically freeze under these conditions. I've kind of assumed that's
why Apple has not shipped WebGL in Safari or nor enabled it for regular
pages on iOS yet. (Yes, I know I'm assuming that's the reason though I have
no actual word from Apple)

Anyway, CSS shaders have this same problem and I'm not sure if people are
aware of the issue.

I think most people believe you need complex shaders to DoS the GPU. In
fact you need no shaders. You can DoS even a fixed function GPU just by
giving it lots of very large polygons to draw.

As an example here's a sample that demonstrates the issue


The sample draws one subdivided plane. This is analogous to using the
vertexMesh attribute in CSS shaders. The vertex shader then, knowing the
resolution of the mesh, expands each sub-quad to the full size of rendering
surface. The fragment shader is minimal effectively the same that would be
used for CSS shaders with no extra effects applied.

In this particular case I set the subdivision to 1000 which is equivalent
to vertexMesh: 1000, 1000 but I believe even a setting of 100x100 would be
enough to DoS many slower GPUs.

There may be work arounds, you can limit each draw call to only 100
polygons for example and that might solve the problem. On the other hand
that might be fairly limiting in terms of speed for more interesting
effects. For example if you used a monospace font you should be able to do
something like this with CSS shaders


But that only runs smoothly if it's 1 draw call. Splitting it into one draw
call for every 100 sub-quads on the off chance that the shader might draw
every quad really large would likely kill perf for shaders that don't.

Has this been considered?
Received on Thursday, 1 March 2012 02:56:33 UTC

This archive was generated by hypermail 2.3.1 : Monday, 22 June 2015 03:33:46 UTC