[webkit-dev] Canvas performance and memory usage

Christophe Public christophe.public at gmail.com
Tue Aug 3 13:20:45 PDT 2010


Hi,

There is a performance hit when using HTML canvas when using
ImageBufferCairo:

- As soon as something is rendered in the canvas, the
HTMLCanvasElement::willDraw method is called which in turn calls clearImage
on the imageBuffer if one is already present.
- When the render tree is traversed (HTMLCanvasElement::paint gets called),
the image containing the canvas is drawn using GraphicsContext::drawImage.
Unfortunately, ImageBuffer::image() (in BufferImageCairo.cpp) allocates a
new surface, and copies the image surface into it. When very frequent
updates are done in the canvas, this double buffering causes significant
performance degradation that worsens with large canvas sizes. In addition,
the extra memory consumption can become quite expensive especially on
embedded devices.

Can anybody explain why this double buffering is necessary for ImageBuffer
specifically for the Cairo port?

We are looking at disabling the double buffering at least for the canvas
because of both performance and memory issues. It would also be nice to
disable it for images as well but we would like to understand why in the
first place it was added. Note that a code comment states "This seems silly,
but is the way the CG port works: image() is intended to be used only when
rendering is complete."

Any suggestion on how to fix this issue is welcome. If it is considered a
bug, then I will create a bug as well to keep track of it.

Regards,
Christophe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100803/c488d928/attachment.html>


More information about the webkit-dev mailing list