Changeset 183710 in webkit


Ignore:
Timestamp:
May 1, 2015, 7:32:29 PM (11 years ago)
Author:
Simon Fraser
Message:

Avoid compositing updates after style recalcs which have no compositing implications
https://bugs.webkit.org/show_bug.cgi?id=144502

Reviewed by Darin Adler.

Source/WebCore:

After r183461, we have reliable information about whether a style change with zero
diff can be reliably ignored. Use that information to track whether a given
recalcStyle() does anything which should force a compositing update.

This eliminates up to 40% of the post-recalcStyle compositing updates on some pages.

Add Internals API to test.

Test: compositing/updates/no-style-change-updates.html

  • dom/Document.cpp:

(WebCore::Document::recalcStyle): Tell the FrameView we're going to recalc style.

  • page/FrameView.cpp:

(WebCore::FrameView::willRecalcStyle): Pass it on to the compositor.
(WebCore::FrameView::updateCompositingLayersAfterStyleChange): Move the code
that was here into RenderLayerCompositor::didRecalcStyleWithNoPendingLayout().

  • page/FrameView.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::willRecalcStyle): Reset the m_layerNeedsCompositingUpdate flag.
(WebCore::RenderLayerCompositor::didRecalcStyleWithNoPendingLayout): Bail on the update if
no layers changed.
(WebCore::RenderLayerCompositor::updateCompositingLayers): Logging. Increment m_compositingUpdateCount,
which is used for testing.
(WebCore::RenderLayerCompositor::layerStyleChanged): Set the m_layerNeedsCompositingUpdate flag.
(WebCore::RenderLayerCompositor::startTrackingCompositingUpdates): Reset the counter.
(WebCore::RenderLayerCompositor::compositingUpdateCount):

  • rendering/RenderLayerCompositor.h:
  • testing/Internals.cpp:

(WebCore::Internals::startTrackingCompositingUpdates):
(WebCore::Internals::compositingUpdateCount):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Use internals.compositingUpdateCount() to see if various document mutations
cause a compositing update. Doesn't actually detect any behavior change
from this patch, but seems useful in general.

  • compositing/updates/no-style-change-updates-expected.txt: Added.
  • compositing/updates/no-style-change-updates.html: Added.
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r183709 r183710  
     12015-05-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid compositing updates after style recalcs which have no compositing implications
     4        https://bugs.webkit.org/show_bug.cgi?id=144502
     5
     6        Reviewed by Darin Adler.
     7       
     8        Use internals.compositingUpdateCount() to see if various document mutations
     9        cause a compositing update. Doesn't actually detect any behavior change
     10        from this patch, but seems useful in general.
     11
     12        * compositing/updates/no-style-change-updates-expected.txt: Added.
     13        * compositing/updates/no-style-change-updates.html: Added.
     14
    1152015-05-01  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r183706 r183710  
     12015-05-01  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Avoid compositing updates after style recalcs which have no compositing implications
     4        https://bugs.webkit.org/show_bug.cgi?id=144502
     5
     6        Reviewed by Darin Adler.
     7       
     8        After r183461, we have reliable information about whether a style change with zero
     9        diff can be reliably ignored. Use that information to track whether a given
     10        recalcStyle() does anything which should force a compositing update.
     11       
     12        This eliminates up to 40% of the post-recalcStyle compositing updates on some pages.
     13       
     14        Add Internals API to test.
     15
     16        Test: compositing/updates/no-style-change-updates.html
     17
     18        * dom/Document.cpp:
     19        (WebCore::Document::recalcStyle): Tell the FrameView we're going to recalc style.
     20        * page/FrameView.cpp:
     21        (WebCore::FrameView::willRecalcStyle): Pass it on to the compositor.
     22        (WebCore::FrameView::updateCompositingLayersAfterStyleChange): Move the code
     23        that was here into RenderLayerCompositor::didRecalcStyleWithNoPendingLayout().
     24        * page/FrameView.h:
     25        * rendering/RenderLayerCompositor.cpp:
     26        (WebCore::RenderLayerCompositor::willRecalcStyle): Reset the m_layerNeedsCompositingUpdate flag.
     27        (WebCore::RenderLayerCompositor::didRecalcStyleWithNoPendingLayout): Bail on the update if
     28        no layers changed.
     29        (WebCore::RenderLayerCompositor::updateCompositingLayers): Logging. Increment m_compositingUpdateCount,
     30        which is used for testing.
     31        (WebCore::RenderLayerCompositor::layerStyleChanged): Set the m_layerNeedsCompositingUpdate flag.
     32        (WebCore::RenderLayerCompositor::startTrackingCompositingUpdates): Reset the counter.
     33        (WebCore::RenderLayerCompositor::compositingUpdateCount):
     34        * rendering/RenderLayerCompositor.h:
     35        * testing/Internals.cpp:
     36        (WebCore::Internals::startTrackingCompositingUpdates):
     37        (WebCore::Internals::compositingUpdateCount):
     38        * testing/Internals.h:
     39        * testing/Internals.idl:
     40
    1412015-05-01  Andreas Kling  <akling@apple.com>
    242
  • trunk/Source/WebCore/dom/Document.cpp

    r183682 r183710  
    17491749    m_styleSheetCollection.flushPendingUpdates();
    17501750
     1751    frameView.willRecalcStyle();
     1752
    17511753    InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(*this);
    17521754
  • trunk/Source/WebCore/page/FrameView.cpp

    r183595 r183710  
    729729}
    730730
    731 void FrameView::updateCompositingLayersAfterStyleChange()
     731void FrameView::willRecalcStyle()
    732732{
    733733    RenderView* renderView = this->renderView();
     
    735735        return;
    736736
     737    renderView->compositor().willRecalcStyle();
     738}
     739
     740void FrameView::updateCompositingLayersAfterStyleChange()
     741{
     742    RenderView* renderView = this->renderView();
     743    if (!renderView)
     744        return;
     745
    737746    // If we expect to update compositing after an incipient layout, don't do so here.
    738747    if (inPreLayoutStyleUpdate() || layoutPending() || renderView->needsLayout())
    739748        return;
    740749
    741     RenderLayerCompositor& compositor = renderView->compositor();
    742     // This call will make sure the cached hasAcceleratedCompositing is updated from the pref
    743     compositor.cacheAcceleratedCompositingFlags();
    744     compositor.updateCompositingLayers(CompositingUpdateAfterStyleChange);
     750    renderView->compositor().didRecalcStyleWithNoPendingLayout();
    745751}
    746752
  • trunk/Source/WebCore/page/FrameView.h

    r183597 r183710  
    148148#endif
    149149
     150    void willRecalcStyle();
    150151    void updateCompositingLayersAfterStyleChange();
    151152    void updateCompositingLayersAfterLayout();
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r183697 r183710  
    385385}
    386386
     387void RenderLayerCompositor::willRecalcStyle()
     388{
     389    m_layerNeedsCompositingUpdate = false;
     390}
     391
     392void RenderLayerCompositor::didRecalcStyleWithNoPendingLayout()
     393{
     394    if (!m_layerNeedsCompositingUpdate)
     395        return;
     396   
     397    cacheAcceleratedCompositingFlags();
     398    updateCompositingLayers(CompositingUpdateAfterStyleChange);
     399}
     400
    387401void RenderLayerCompositor::customPositionForVisibleRectComputation(const GraphicsLayer* graphicsLayer, FloatPoint& position) const
    388402{
     
    657671void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType updateType, RenderLayer* updateRoot)
    658672{
     673    LOG(Compositing, "RenderLayerCompositor %p updateCompositingLayers %d %p", this, updateType, updateRoot);
     674
    659675    m_updateCompositingLayersTimer.stop();
    660676
     
    674690    if (!m_reevaluateCompositingAfterLayout && !m_compositing)
    675691        return;
     692
     693    ++m_compositingUpdateCount;
    676694
    677695    AnimationUpdateBlock animationUpdateBlock(&m_renderView.frameView().frame().animation());
     
    710728    if (isFullUpdate && updateType == CompositingUpdateAfterLayout)
    711729        m_reevaluateCompositingAfterLayout = false;
     730
     731    LOG(Compositing, " checkForHierarchyUpdate %d, needGeometryUpdate %d", checkForHierarchyUpdate, needHierarchyUpdate);
    712732
    713733#if !LOG_DISABLED
     
    920940    if (diff == StyleDifferenceEqual)
    921941        return;
     942
     943    m_layerNeedsCompositingUpdate = true;
    922944
    923945    const RenderStyle& newStyle = layer.renderer().style();
     
    41874209}
    41884210
     4211void RenderLayerCompositor::startTrackingCompositingUpdates()
     4212{
     4213    m_compositingUpdateCount = 0;
     4214}
     4215
     4216unsigned RenderLayerCompositor::compositingUpdateCount() const
     4217{
     4218    return m_compositingUpdateCount;
     4219}
     4220
    41894221} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r183454 r183710  
    120120    void setCompositingLayersNeedRebuild(bool needRebuild = true);
    121121    bool compositingLayersNeedRebuild() const { return m_compositingLayersNeedRebuild; }
     122   
     123    void willRecalcStyle();
     124    void didRecalcStyleWithNoPendingLayout();
    122125
    123126    // GraphicsLayers buffer state, which gets pushed to the underlying platform layers
     
    311314    WEBCORE_EXPORT void startTrackingLayerFlushes();
    312315    WEBCORE_EXPORT unsigned layerFlushCount() const;
     316
     317    WEBCORE_EXPORT void startTrackingCompositingUpdates();
     318    WEBCORE_EXPORT unsigned compositingUpdateCount() const;
    313319
    314320private:
     
    499505    unsigned m_layersWithTiledBackingCount { 0 };
    500506    unsigned m_layerFlushCount { 0 };
     507    unsigned m_compositingUpdateCount { 0 };
    501508
    502509    RootLayerAttachment m_rootLayerAttachment;
     
    535542    bool m_layerFlushThrottlingTemporarilyDisabledForInteraction;
    536543    bool m_hasPendingLayerFlush;
     544    bool m_layerNeedsCompositingUpdate { false };
    537545
    538546    Timer m_paintRelatedMilestonesTimer;
  • trunk/Source/WebCore/testing/Internals.cpp

    r183597 r183710  
    21152115}
    21162116
     2117void Internals::startTrackingCompositingUpdates(ExceptionCode& ec)
     2118{
     2119    Document* document = contextDocument();
     2120    if (!document || !document->renderView()) {
     2121        ec = INVALID_ACCESS_ERR;
     2122        return;
     2123    }
     2124
     2125    document->renderView()->compositor().startTrackingCompositingUpdates();
     2126}
     2127
     2128unsigned long Internals::compositingUpdateCount(ExceptionCode& ec)
     2129{
     2130    Document* document = contextDocument();
     2131    if (!document || !document->renderView()) {
     2132        ec = INVALID_ACCESS_ERR;
     2133        return 0;
     2134    }
     2135   
     2136    return document->renderView()->compositor().compositingUpdateCount();
     2137}
     2138
    21172139void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode& ec)
    21182140{
  • trunk/Source/WebCore/testing/Internals.h

    r183428 r183710  
    304304    unsigned long styleRecalcCount(ExceptionCode&);
    305305
     306    void startTrackingCompositingUpdates(ExceptionCode&);
     307    unsigned long compositingUpdateCount(ExceptionCode&);
     308
    306309    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode&);
    307310    void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionCode&);
  • trunk/Source/WebCore/testing/Internals.idl

    r183428 r183710  
    281281    [RaisesException] unsigned long styleRecalcCount();
    282282
     283    [RaisesException] void startTrackingCompositingUpdates();
     284    [RaisesException] unsigned long compositingUpdateCount();
     285
    283286    // |node| should be Document, HTMLIFrameElement, or unspecified.
    284287    // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
Note: See TracChangeset for help on using the changeset viewer.