Bug 169586 - Subpixel rendering causes repainting compositing layers moved by CSS animation
Summary: Subpixel rendering causes repainting compositing layers moved by CSS animation
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-13 21:58 PDT by Fujii Hironori
Modified: 2017-03-14 20:11 PDT (History)
3 users (show)

See Also:


Attachments
test case of moving compositing layers by CSS animation (571 bytes, text/html)
2017-03-13 21:58 PDT, Fujii Hironori
no flags Details
screenshot of GTK+ port MiniBrowser (11.39 KB, image/png)
2017-03-13 22:00 PDT, Fujii Hironori
no flags Details
screenshot of Mac port (24.57 KB, image/png)
2017-03-14 00:47 PDT, Fujii Hironori
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2017-03-13 21:58:28 PDT
Created attachment 304349 [details]
test case of moving compositing layers by CSS animation

Subpixel rendering causes repainting compositing layers moved by CSS animation.
This seems the intended effect of subpixel rendering.
But, this degrades CSS animation performance.
I think WebKit needs a solution, for example disabling subpixel rendering.
Comment 1 Fujii Hironori 2017-03-13 22:00:17 PDT
Created attachment 304350 [details]
screenshot of GTK+ port MiniBrowser
Comment 2 Fujii Hironori 2017-03-13 22:02:11 PDT
Here are a simple patch to disable subpixel rendering:

> diff --git a/Source/WebCore/rendering/RenderLayerBacking.cpp b/Source/WebCore/rendering/RenderLayerBacking.cpp
> index 46c9ecd..4c72640 100644
> --- a/Source/WebCore/rendering/RenderLayerBacking.cpp
> +++ b/Source/WebCore/rendering/RenderLayerBacking.cpp
> @@ -889,8 +889,7 @@ private:
>  LayoutRect RenderLayerBacking::computePrimaryGraphicsLayerRect(const LayoutRect& parentGraphicsLayerRect) const
>  {
>      ComputedOffsets compositedBoundsOffset(m_owningLayer, compositedBounds(), parentGraphicsLayerRect, LayoutRect());
> -    return LayoutRect(encloseRectToDevicePixels(LayoutRect(toLayoutPoint(compositedBoundsOffset.fromParentGraphicsLayer()), compositedBounds().size()),
> -        deviceScaleFactor()));
> +    return LayoutRect(toLayoutPoint(compositedBoundsOffset.fromParentGraphicsLayer()), compositedBounds().size());
>  }
>  
>  LayoutRect RenderLayerBacking::computeParentGraphicsLayerRect(RenderLayer* compositedAncestor, LayoutSize& ancestorClippingLayerOffset) const
Comment 3 Simon Fraser (smfr) 2017-03-13 22:18:47 PDT
Pretty sure we'd repaint even without the subpixel rendering.
Comment 4 Fujii Hironori 2017-03-13 22:54:37 PDT
What do you mean?
The repainting counter won't be raised if I disable subpixel rendering with the patch (comment 2).
And, CSS animation performance was good before subpixel rendering has been landed.
Comment 5 Fujii Hironori 2017-03-14 00:47:22 PDT
Created attachment 304364 [details]
screenshot of Mac port

Mac port also has this issue.
Comment 6 Fujii Hironori 2017-03-14 07:46:35 PDT
One idea is coming into my mind. Disabling subpixel rendering only for moving layers.
Comment 7 zalan 2017-03-14 08:33:21 PDT
(In reply to comment #3)
> Pretty sure we'd repaint even without the subpixel rendering.
Simon, do you know why we are calling RenderLayerBacking::updateGeometry on each frame?

computePrimaryGraphicsLayerRect
RenderLayerBacking::updateGeometry
1   0x104bf8e54 WebCore::RenderLayerCompositor::layerStyleChanged(WebCore::StyleDifference, WebCore::RenderLayer&, WebCore::RenderStyle const*)
2   0x104be5a6c WebCore::RenderLayer::styleChanged(WebCore::StyleDifference, WebCore::RenderStyle const*)
3   0x104c020ae WebCore::RenderLayerModelObject::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
4   0x104b585d4 WebCore::RenderBox::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
5   0x104b240eb WebCore::RenderBlock::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
6   0x104b4411c WebCore::RenderBlockFlow::styleDidChange(WebCore::StyleDifference, WebCore::RenderStyle const*)
7   0x104b8cd9e WebCore::RenderElement::setStyle(WebCore::RenderStyle&&, WebCore::StyleDifference)
8   0x104cc68f9 WebCore::RenderTreeUpdater::updateElementRenderer(WebCore::Element&, WebCore::Style::ElementUpdate const&)
9   0x104cc5ca0 WebCore::RenderTreeUpdater::updateRenderTree(WebCore::ContainerNode&)
10  0x104cc59eb WebCore::RenderTreeUpdater::commit(std::__1::unique_ptr<WebCore::Style::Update const, std::__1::default_delete<WebCore::Style::Update const> >)
11  0x10410b049 WebCore::Document::resolveStyle(WebCore::Document::ResolveStyleType)
12  0x103ff5b96 WebCore::CSSAnimationControllerPrivate::updateAnimations(WebCore::SetChanged)
13  0x103ff5cde WebCore::CSSAnimationControllerPrivate::updateAnimationTimer(WebCore::SetChanged)
14  0x103ff4e7c WebCore::CSSAnimationControllerPrivate::animationTimerFired()
15  0x104f8d6b0 WebCore::ThreadTimers::sharedTimerFiredInternal()
16  0x1049b912f WebCore::timerFired(__CFRunLoopTimer*, void*)
Comment 8 Simon Fraser (smfr) 2017-03-14 08:43:23 PDT
This is a non-hardware animation, so we just update style and layout every frame.
Comment 9 Fujii Hironori 2017-03-14 19:24:48 PDT
So, you mean web developers should use 'transform' property instread of 'top' property for animation.
I got the idea. Thank you. Closed as INVALID.
Comment 10 zalan 2017-03-14 20:11:05 PDT
Reopening. We should find a way to address this set of extra repaintings.