NEW 292972
[css-anchor-position-1] animation + anchor-positioned element as popover cause anchor-positioned element to be repainted every style resolution
https://bugs.webkit.org/show_bug.cgi?id=292972
Summary [css-anchor-position-1] animation + anchor-positioned element as popover caus...
Kiet Ho
Reported 2025-05-13 23:39:11 PDT
Created attachment 475222 [details] Test case See test case. Test case has a scroll driven animation, a button that triggers a popover element that's anchor-positioned to the button. When the popover is shown, it keeps getting painted over and over again, about 1 per frame. Enable "Show layer borders" to see the paint counter going up and up. Root cause: AnchorPositionEvaluator::updateAnchorPositioningStatesAfterInterleavedLayout() calls setNeedsLayout() once on each anchor-positioned element. setNeedsLayout() repaints the entire layer if the element is in a layer: inline void RenderObject::setNeedsLayout(MarkingBehavior markParents) { [...] if (hasLayer()) setLayerNeedsFullRepaint(); } Since anchor-positioned element is a popover, it's placed in the top layer. Hence it has a layer and the layer is forced to repaint. Because AnchorPositionEvaluator::updateAnchorPositioningStatesAfterInterleavedLayout() is called at least once during style/layout interleaving, this guarantees the layer is repainted at least once per style resolution. When there's an animation, the style is resolved every frame, so the effect is that the layer is repainted every frame. Ideally, we don't setNeedsLayout() on each anchor-positioned element every style resolution. It should only be called when the anchor the element depends on changes (in size or position) to re-layout the anchor-positioned element. This should be done in Style::Scope::invalidateForAnchorDependencies.
Attachments
Test case (975 bytes, text/html)
2025-05-13 23:39 PDT, Kiet Ho
no flags
Radar WebKit Bug Importer
Comment 1 2025-05-13 23:39:19 PDT
Note You need to log in before you can comment on or make changes to this bug.