RESOLVED FIXED 57269
REGRESSION (r82151): Every WKView paint now makes an extra copy of the painted bits
https://bugs.webkit.org/show_bug.cgi?id=57269
Summary REGRESSION (r82151): Every WKView paint now makes an extra copy of the painte...
Adam Roben (:aroben)
Reported 2011-03-28 14:37:48 PDT
r82151 changed ShareableBitmap::paint to use CGBitmapContextCreateImage in its implementation, rather than creating an image using a custom data provider. On Mac, CGBitmapContextCreateImage uses a copy-on-write implementation, but on Windows it just copies the data. This means that we're now making an extra copy of every pixel that we paint into a WKView. This is likely a performance regression, though that has not been confirmed.
Attachments
Patch for performance testing (5.91 KB, patch)
2011-04-07 08:31 PDT, Adam Roben (:aroben)
no flags
Make ShareableBitmap::makeCGImageCopy use a copy-on-write copy on Windows when possible (11.15 KB, patch)
2011-05-04 09:51 PDT, Adam Roben (:aroben)
andersca: review+
Adam Roben (:aroben)
Comment 1 2011-03-28 14:38:28 PDT
Adam Roben (:aroben)
Comment 2 2011-04-07 07:45:24 PDT
It has now been confirmed that r82151 is a performance regression. Once upon a time we had a policy of rolling out performance regressions. I guess that's no longer the policy.
Adam Roben (:aroben)
Comment 3 2011-04-07 08:31:13 PDT
Created attachment 88643 [details] Patch for performance testing Here's a patch that should get rid of the extra copy. I haven't performance tested it, though.
Steve Falkenburg
Comment 4 2011-04-07 10:20:53 PDT
This patch is a 5% speed-up on iBench HTML cached.
Adam Roben (:aroben)
Comment 5 2011-04-07 14:52:08 PDT
Comment on attachment 88643 [details] Patch for performance testing I don't think this patch is safe. If someone modifies the ShareableBitmap after the CGImageRef has been made but before the newMapping has been written into, the newMapping will see the modifications. This is exactly what we're trying to avoid. (And since newMapping should never be written into, we're basically never safe.) This is just how copy-on-write views work in Windows. If I have two views of the same mapping, A and B, and A has FILE_MAP_WRITE and B has FILE_MAP_COPY, B will see writes to A until B is written into. From then on B will be operating on its own copy that is insulated from A.
Adam Roben (:aroben)
Comment 6 2011-05-02 14:27:46 PDT
(In reply to comment #5) > (From update of attachment 88643 [details]) > I don't think this patch is safe. If someone modifies the ShareableBitmap after the CGImageRef has been made but before the newMapping has been written into, the newMapping will see the modifications. This is exactly what we're trying to avoid. (And since newMapping should never be written into, we're basically never safe.) > > This is just how copy-on-write views work in Windows. If I have two views of the same mapping, A and B, and A has FILE_MAP_WRITE and B has FILE_MAP_COPY, B will see writes to A until B is written into. From then on B will be operating on its own copy that is insulated from A. I guess we could use A for the CGImageRef and use B for the ShareableBitmap from then on. The CGImageRef can't be written to, so that should work.
Adam Roben (:aroben)
Comment 7 2011-05-04 08:43:10 PDT
(In reply to comment #6) > (In reply to comment #5) > > (From update of attachment 88643 [details] [details]) > > I don't think this patch is safe. If someone modifies the ShareableBitmap after the CGImageRef has been made but before the newMapping has been written into, the newMapping will see the modifications. This is exactly what we're trying to avoid. (And since newMapping should never be written into, we're basically never safe.) > > > > This is just how copy-on-write views work in Windows. If I have two views of the same mapping, A and B, and A has FILE_MAP_WRITE and B has FILE_MAP_COPY, B will see writes to A until B is written into. From then on B will be operating on its own copy that is insulated from A. > > I guess we could use A for the CGImageRef and use B for the ShareableBitmap from then on. The CGImageRef can't be written to, so that should work. Trying this out now.
Adam Roben (:aroben)
Comment 8 2011-05-04 09:51:28 PDT
Created attachment 92261 [details] Make ShareableBitmap::makeCGImageCopy use a copy-on-write copy on Windows when possible
Adam Roben (:aroben)
Comment 9 2011-05-04 09:58:45 PDT
Note You need to log in before you can comment on or make changes to this bug.