Bug 264966

Summary: [GTK] Slow CSS animations and dropped frames when animating `transition-property: transform, filter;` on `filter: opacity` with more than 2 large images
Product: WebKit Reporter: Jeff Fortin <nekohayo>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs-noreply, calvin.walton, cgarcia
Priority: P2 Keywords: Performance
Version: Other   
Hardware: PC   
OS: Linux   
URL: https://www.kepstin.ca/dump/loupe-crossfade-demo/stacked-webkitgtk-filter.html
See Also: https://bugs.webkit.org/show_bug.cgi?id=265048
Bug Depends on:    
Bug Blocks: 245783    
Attachments:
Description Flags
sysprof capture
none
sysprof screenshot - flame chart
none
sysprof screenshot - callgraph, part 1
none
sysprof screenshot - callgraph, part 2
none
sysprof screenshot - graphics/compositing marks
none
sysprof screenshot - flame chart none

Description Jeff Fortin 2023-11-16 10:51:52 PST
Created attachment 468621 [details]
sysprof capture

Visiting https://www.kepstin.ca/dump/loupe-crossfade-demo/ (or specifically https://www.kepstin.ca/dump/loupe-crossfade-demo/stacked.html if the parent link stops working) with Epiphany 45.0 on Fedora 39 with the Wayland GNOME session, you can see that the slide animations stop working after the second image because they are so slow that they have to drop frames. This is dependent on the amount of images on that page.

The problem does not occur with Firefox on the same machines.

Attaching a sysprof capture that I recorded with my laptop with Intel Kabylake graphics. It seems related to cairo and pixman.
Comment 1 Jeff Fortin 2023-11-16 10:53:04 PST
Created attachment 468622 [details]
sysprof screenshot - flame chart
Comment 2 Jeff Fortin 2023-11-16 10:53:43 PST
Created attachment 468623 [details]
sysprof screenshot - callgraph, part 1
Comment 3 Jeff Fortin 2023-11-16 10:53:57 PST
Created attachment 468624 [details]
sysprof screenshot - callgraph, part 2
Comment 4 Jeff Fortin 2023-11-16 10:54:18 PST
Created attachment 468625 [details]
sysprof screenshot - graphics/compositing marks
Comment 5 Jeff Fortin 2023-11-16 11:00:49 PST
Created attachment 468626 [details]
sysprof screenshot - flame chart

This one actually includes the top of the chart, whereas the previous one was hidden by scrolling
Comment 6 Calvin Walton 2023-11-16 11:38:12 PST
Hi, I'm the author of the affected page.

I figured out the particular thing that was causing the performance issue - I was using a CSS transition with `transition-property: transform, filter;` set, and then transitioning from `filter: opacity(0%);` to `filter: opacity(100%);` and vice-versa. It looks like the opacity filter is hitting a very slow software fallback.

When I changed the page to transition the `opacity` property rather than use a filter, performance improved substantially. The current version of the links posted earlier reflect this updated.

The original version of the page which exhibits this issue has a permanent link here: https://www.kepstin.ca/dump/loupe-crossfade-demo/stacked-webkitgtk-filter.html
Comment 7 Carlos Garcia Campos 2023-11-17 01:38:57 PST
The problem is the interpolation quality, we render the images with the default interpolation quality, that uses CAIRO_FILTER_GOOD, giving high quality results but it's very slow when downscaling high resolution images. There's code in WebKit to use low interpolation quality when there's a resize animation or the view is being resized, but doesn't handle this case of CSS transition filter animation. When using the opacity property, the image is rendered once using default interpolation quality and then the effect is done by the GPU, that's why it works better.