RESOLVED FIXED 190615
Tiling CSS gradients is slow
https://bugs.webkit.org/show_bug.cgi?id=190615
Summary Tiling CSS gradients is slow
Antti Koivisto
Reported 2018-10-16 06:46:12 PDT
Painting blocks the main thread on CG rendering queue to make copy of the backing store: kevent_id _dispatch_event_loop_wait_for_ownership __DISPATCH_WAIT_FOR_QUEUE__ _dispatch_sync_f_slow CA::CG::IOSurfaceDrawable::copy_cgimage() WebCore::IOSurface::createImage() WebCore::ImageBuffer::copyNativeImage(WebCore::BackingStoreCopy) const WebCore::ImageBuffer::copyImage(WebCore::BackingStoreCopy, WebCore::PreserveResolution) const WebCore::ImageBuffer::drawPattern(WebCore::GraphicsContext&, WebCore::FloatRect const&, WebCore::FloatRect const&, WebCore::AffineTransform const&, WebCore::FloatPoint const&, WebCore::FloatSize const&, WebCore::CompositeOperator, WebCore::BlendMode) WebCore::GradientImage::drawPattern(WebCore::GraphicsContext&, WebCore::FloatRect const&, WebCore::FloatRect const&, WebCore::AffineTransform const&, WebCore::FloatPoint const&, WebCore::FloatSize const&, WebCore::CompositeOperator, WebCore::BlendMode) WebCore::Image::drawTiled(WebCore::GraphicsContext&, WebCore::FloatRect const&, WebCore::FloatPoint const&, WebCore::FloatSize const&, WebCore::FloatSize const&, WebCore::CompositeOperator, WebCore::BlendMode, WebCore::DecodingMode)
Attachments
patch (14.83 KB, patch)
2018-10-16 07:00 PDT, Antti Koivisto
no flags
simpler patch (3.76 KB, patch)
2018-10-17 05:15 PDT, Antti Koivisto
no flags
simpler patch (4.54 KB, patch)
2018-10-17 05:57 PDT, Antti Koivisto
no flags
simpler patch (4.58 KB, patch)
2018-10-17 06:11 PDT, Antti Koivisto
no flags
Antti Koivisto
Comment 1 2018-10-16 07:00:39 PDT
Tim Horton
Comment 2 2018-10-16 10:55:12 PDT
Comment on attachment 352448 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=352448&action=review > Source/WebCore/platform/graphics/cocoa/IOSurface.h:111 > + WEBCORE_EXPORT RetainPtr<CGImageRef> imageReference(); I don't love it, the sinkIntoImage approach made it much harder to do The Wrong Thing. But I guess you need to keep the surface around?
Antti Koivisto
Comment 3 2018-10-16 11:14:05 PDT
> I don't love it, the sinkIntoImage approach made it much harder to do The > Wrong Thing. But I guess you need to keep the surface around? I could throw away the IOSurface but presumably drawing IOSurface backed CGImage to an accelerated context is faster?
Antti Koivisto
Comment 4 2018-10-16 11:32:32 PDT
Hmm, maybe we can just sink it.
Simon Fraser (smfr)
Comment 5 2018-10-16 14:13:58 PDT
Comment on attachment 352448 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=352448&action=review > Source/WebCore/platform/graphics/ImageBuffer.h:84 > + void makeImmutable() { m_isImmutable = true; } Would be nice to have the corresponding const getter.
Antti Koivisto
Comment 6 2018-10-17 05:15:35 PDT
Created attachment 352561 [details] simpler patch This ditches the "immutable ImageBuffer" concept and simply sinks the gradient ImageBuffer into an Image and uses that for caching instead.
Antti Koivisto
Comment 7 2018-10-17 05:57:43 PDT
Created attachment 352563 [details] simpler patch
EWS Watchlist
Comment 8 2018-10-17 06:00:15 PDT
Attachment 352563 [details] did not pass style-queue: ERROR: Source/WebCore/ChangeLog:10: Need whitespace between colon and description [changelog/filechangedescriptionwhitespace] [5] Total errors found: 1 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
Antti Koivisto
Comment 9 2018-10-17 06:11:34 PDT
Created attachment 352564 [details] simpler patch
Tim Horton
Comment 10 2018-10-17 10:06:16 PDT
Comment on attachment 352564 [details] simpler patch Nice! Thank you, that makes me much happier. Is it still a PLT win (I assume?)?
Antti Koivisto
Comment 11 2018-10-17 11:35:23 PDT
> Nice! Thank you, that makes me much happier. Is it still a PLT win (I > assume?)? Hope so. Bots will tell.
WebKit Commit Bot
Comment 12 2018-10-17 12:00:11 PDT
Comment on attachment 352564 [details] simpler patch Clearing flags on attachment: 352564 Committed r237230: <https://trac.webkit.org/changeset/237230>
WebKit Commit Bot
Comment 13 2018-10-17 12:00:13 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 14 2018-10-17 12:01:47 PDT
Antti Koivisto
Comment 15 2018-10-21 02:55:29 PDT
Bots indicate that this was >1% progression https://perf-safari.apple.com/v3/#/charts?paneList=((886-1158))&since=1539416881058 Most PLT pages don't have gradients, the ones that were affected got 5-6% faster.
Note You need to log in before you can comment on or make changes to this bug.