[webkit-dev] parallel rendering in WebKit

Stephan Assmus superstippi at gmx.de
Fri Feb 19 15:08:15 PST 2010


Hi,

On 2010-02-19 at 23:46:11 [+0100], Benbuck Nason <bnason at netflix.com> wrote:
> To me it seems like the biggest gain would be to have two threads: one
> for update/layout, and another for rendering. This would probably
> require double-buffering the render state though.

it's not really my place to jump into discussions about WebKit internals, 
since I am very new to the project, but I have some experience with this 
problem. By double-buffering the render state, do you mean to have the 
document tree in two copies? Or do you mean double buffering the graphics? 
The first is what needs to happen, since you want to render the document at 
a consistent point in time. Once this separation is done, you can even use 
as many rendering threads as you want, i.e. split the output bitmap into 
areas and use one thread per area. Other ways of splitting are possible 
too, like rendering independent compositing layers in different threads. 
But one needs a point in time to take a "snapshot" of the current document 
tree, kick of the rendering of this snapshot, while the main document is 
allowed to evolve.

I can't really say if such a design makes sense for WebKit. Depending on 
the architecture of a port, rendering may already take place in another 
thread. for example, when drawing commands are dispatched to the GPU. Or in 
the Haiku port, drawing commands are dispatched to a system service, which 
does the actual work. Synchronization happens when the contents are blitted 
to the screen.

What would be nice is if each page could run it's own layout thread. But 
AFAICT, a lot of work would need to be done for this. When I started to 
pick up work on the Haiku port, I had to redesign the threading, and make 
sure I call into WebCore code only on the "main thread". There are tons of 
assertions to make sure of this (nice for porting). But even nicer would be 
a concept of threading and locking critical sections, instead of asserting 
a specific thread. Maybe this doesn't make so much sense for WebKit and I 
am just showing off my newbie status. :-)

Best regards,
-Stephan


More information about the webkit-dev mailing list