Open Bug 843224 Opened 9 years ago Updated 9 years ago

Use CopyOnWrite for async 2D Canvas swap


(Core :: Graphics: Layers, defect)

Not set




(Reporter: BenWa, Unassigned)



We currently do this for tiling and it works well. When we need to send an update to the compositor we mark it as read only and send it asynchronously. The compositor will then release the read lock after it's uploaded the image. If in the mean time content needs to use that surface it check the read lock and does a copy if required.

We could do something similar for canvas. We can even check if the first call is a fillRect and avoid the copy entirely and allocate a blank surface. In the average case we might skip a lot of copies even if the context doesn't fillRect because the compositor might upload it before it's needed by content.
As request by brad here's are example of this issued in the code base:

line 573 we paint into the tiles.
line 574 we lock the tiles are read only.
line 585 we send the tiles to the compositor

on the compositor we when we're done with the tiles we unlock then here:

meanwhile the main thread will race towards updating the tile in the next paint:

If the tile has been unlocked first then the tile is reused. If the tile is still locked then it is copied first and a new tile is used for drawing.
You need to log in before you can comment on or make changes to this bug.