RESOLVED FIXED42852
REGRESSION: box shadows on WebGL canvas elements repainted every frame
https://bugs.webkit.org/show_bug.cgi?id=42852
Summary REGRESSION: box shadows on WebGL canvas elements repainted every frame
James Robinson
Reported 2010-07-22 15:03:52 PDT
Try adding a large box shadow to the WebGL spinning box example. The framerate drops because the shadow is re-drawn every frame. Only the WebGL's contents should be invalidated, not anything on the canvas itself.
Attachments
Patch (1.98 KB, patch)
2010-07-22 15:38 PDT, James Robinson
no flags
Patch (2.11 KB, patch)
2010-07-22 16:10 PDT, James Robinson
no flags
Patch (2.36 KB, patch)
2010-07-22 16:56 PDT, James Robinson
no flags
Simon Fraser (smfr)
Comment 1 2010-07-22 15:06:49 PDT
Regression from bug 34719.
Simon Fraser (smfr)
Comment 2 2010-07-22 15:07:44 PDT
The HTMLCanvasElement::willDraw() call from WebGLRenderingContext::markContextChanged() is causing the canvas's renderer to get redrawn whenever the WebGL does stuff, which is very bad for performance.
Simon Fraser (smfr)
Comment 3 2010-07-22 15:12:19 PDT
I don't understand the need for willDraw(), and the "Make sure the canvas's image buffer is allocated." comment. The canvas image buffer should only be created on demand.
James Robinson
Comment 4 2010-07-22 15:38:34 PDT
James Robinson
Comment 5 2010-07-22 15:40:03 PDT
This patch appears to fix the regression and still passes fast/canvas/webgl/canvas-test.html. I'm not sure why we have to call willDraw() at all before doing the paintRenderResultsToCanvas() though so I haven't marked the patch review?.
Chris Marrin
Comment 6 2010-07-22 15:58:12 PDT
The code in WebGLRenderingContext::markContextChanged() looks wrong. In the accelerated compositing case the image buffer should never be allocated and the canvas should not be marked dirty (in the willDraw() call). This could be as simple as adding a #else clause to the HW_COMP test to do this only when not hardware accelerated.
James Robinson
Comment 7 2010-07-22 16:10:16 PDT
James Robinson
Comment 8 2010-07-22 16:56:06 PDT
James Robinson
Comment 9 2010-07-22 17:02:46 PDT
This patch reverts WebGLRenderingContext::markContextChanged() mostly to its previous behavior. The changes relative to the pre-r63502 version are: - unconditionally mark m_markedCanvasDirty so if we later need to do a readback we'll know the canvas is dirty - remove the unnecessary call to HTMLCanvasElement::buffer() and incorrect comment The call to ::willDraw() is still needed for the software rendering path. The other change is to add a call to ImageBuffer::clearImage right before calling GraphicsContext3D::paintRenderingResultsToCanvas in the readback path. I don't think this should be needed, but without this change canvas-test.html fails. I think it's better to leave this change in with a FIXME for now and try to figure out what is really going on. I've verified that this passes fast/canvas/webgl/* and renders WebGL content correctly in Safari and Chrome on a Snow Leopard machine.
Kenneth Russell
Comment 10 2010-07-22 17:04:55 PDT
Comment on attachment 62361 [details] Patch Looks good to me. Thanks for fixing this.
James Robinson
Comment 11 2010-07-22 17:19:21 PDT
Comment on attachment 62361 [details] Patch Clearing flags on attachment: 62361 Committed r63923: <http://trac.webkit.org/changeset/63923>
James Robinson
Comment 12 2010-07-22 17:19:26 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.