Changeset 273264 in webkit


Ignore:
Timestamp:
Feb 22, 2021 11:12:03 AM (3 years ago)
Author:
svillar@igalia.com
Message:

REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
https://bugs.webkit.org/show_bug.cgi?id=222202
<rdar://problem/74537782>

Reviewed by Simon Fraser.

PerformanceTests:

New performance test for nested column flexboxes with percentage heights.

  • Layout/nested-column-flexboxes-relative-height.html: Added.

Source/WebCore:

The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
in pages with nested column flexboxes with relative heights.

No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
which is ~4000% better.

Inspired by Blink's crrev.com/c/1614058 by <cbiesinger@chromium.org>.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
relayoutChildren which is now unused. Do not layout the item, that should have been done in
computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
a consequence of the previous layout.
(WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
need to update it after laying out the child.

  • rendering/RenderFlexibleBox.h:
Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/TestExpectations

    r273245 r273264  
    39163916webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-012.html [ ImageOnlyFailure ]
    39173917webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-015.html [ ImageOnlyFailure ]
    3918 webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-017.html [ ImageOnlyFailure ]
     3918webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-column-017.html [ Failure ]
    39193919webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-007.html [ ImageOnlyFailure ]
    39203920webkit.org/b/219343 imported/w3c/web-platform-tests/css/css-flexbox/flex-aspect-ratio-img-row-010.html [ ImageOnlyFailure ]
  • trunk/PerformanceTests/ChangeLog

    r273122 r273264  
     12021-02-22  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
     4        https://bugs.webkit.org/show_bug.cgi?id=222202
     5        <rdar://problem/74537782>
     6
     7        Reviewed by Simon Fraser.
     8
     9        New performance test for nested column flexboxes with percentage heights.
     10
     11        * Layout/nested-column-flexboxes-relative-height.html: Added.
     12
    1132021-02-18  Myles C. Maxfield  <mmaxfield@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r273263 r273264  
     12021-02-22  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        REGRESSION (r266695): twitch.tv: when in fullscreen, WebKit continually does 350ms layouts. Firefox and Chrome do not
     4        https://bugs.webkit.org/show_bug.cgi?id=222202
     5        <rdar://problem/74537782>
     6
     7        Reviewed by Simon Fraser.
     8
     9        The problem was that we were doing the initial layout for the children of the flex container twice in those cases where
     10        the child inline axis was not the main axis (for example with column flex containers in horizontal writing modes).
     11        Refactored the code (specially the way we clear overriding sizes) so that we only do it once. This saves tons of layouts
     12        in pages with nested column flexboxes with relative heights.
     13
     14        No new tests as there is no change in functionality, we're removing duplicate extra layouts. We're however adding a new
     15        performance test for column flexboxes with percentage heights. With this patch we go from 3.5 layout/s to 145 layout/s
     16        which is ~4000% better.
     17
     18        Inspired by Blink's crrev.com/c/1614058 by <cbiesinger@chromium.org>.
     19
     20        * rendering/RenderFlexibleBox.cpp:
     21        (WebCore::RenderFlexibleBox::computeInnerFlexBaseSizeForChild): Do not unconditionally clear overriding sizes. Also removed
     22        relayoutChildren which is now unused. Do not layout the item, that should have been done in
     23        computeInnerFlexBaseSizeForChild() before. Added ASSERTs to verify that child's intrinsic main size was cached as
     24        a consequence of the previous layout.
     25        (WebCore::RenderFlexibleBox::constructFlexItem): Do not pass relayoutChildren to computeInnerFlexBaseSizeForChild. Also no
     26        need to update it after laying out the child.
     27        * rendering/RenderFlexibleBox.h:
     28
    1292021-02-22  Alex Christensen  <achristensen@webkit.org>
    230
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r273242 r273264  
    923923
    924924   
    925 LayoutUnit RenderFlexibleBox::computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding, bool relayoutChildren)
    926 {
    927     child.clearOverridingContentSize();
    928    
     925LayoutUnit RenderFlexibleBox::computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding)
     926{
    929927    Length flexBasis = flexBasisForChild(child);
    930928    if (childMainSizeIsDefinite(child, flexBasis))
     
    936934    }
    937935
    938     // The flex basis is indefinite (=auto), so we need to compute the actual
    939     // width of the child. For the logical width axis we just use the preferred
    940     // width; for the height we need to lay out the child.
     936    // The flex basis is indefinite (=auto), so we need to compute the actual width of the child.
    941937    LayoutUnit mainAxisExtent;
    942938    if (!mainAxisIsChildInlineAxis(child)) {
    943         updateBlockChildDirtyBitsBeforeLayout(relayoutChildren, child);
    944         if (child.needsLayout() || relayoutChildren || !m_intrinsicSizeAlongMainAxis.contains(&child)) {
    945             if (!child.needsLayout())
    946                 child.setChildNeedsLayout(MarkOnlyThis);
    947             child.layoutIfNeeded();
    948             cacheChildMainSize(child);
    949         }
     939        ASSERT(!child.needsLayout());
     940        ASSERT(m_intrinsicSizeAlongMainAxis.contains(&child));
    950941        mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
    951942    } else {
     
    13001291FlexItem RenderFlexibleBox::constructFlexItem(RenderBox& child, bool relayoutChildren)
    13011292{
     1293    child.clearOverridingContentSize();
    13021294    if (childHasIntrinsicMainAxisSize(child)) {
    13031295        // If this condition is true, then computeMainAxisExtentForChild will call
     
    13181310            child.layoutIfNeeded();
    13191311            cacheChildMainSize(child);
    1320             relayoutChildren = false;
    13211312            child.clearOverridingContainingBlockContentSize();
    13221313        }
     
    13241315   
    13251316    LayoutUnit borderAndPadding = isHorizontalFlow() ? child.horizontalBorderAndPaddingExtent() : child.verticalBorderAndPaddingExtent();
    1326     LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding, relayoutChildren);
     1317    LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding);
    13271318    LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(child, childInnerFlexBaseSize);
    13281319    LayoutUnit margin = isHorizontalFlow() ? child.horizontalMarginExtent() : child.verticalMarginExtent();
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r273242 r273264  
    147147    LayoutUnit computeMainSizeFromAspectRatioUsing(const RenderBox& child, Length crossSizeLength) const;
    148148    void setFlowAwareLocationForChild(RenderBox& child, const LayoutPoint&);
    149     LayoutUnit computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding, bool relayoutChildren);
     149    LayoutUnit computeInnerFlexBaseSizeForChild(RenderBox& child, LayoutUnit mainAxisBorderAndPadding);
    150150    void adjustAlignmentForChild(RenderBox& child, LayoutUnit);
    151151    ItemPosition alignmentForChild(const RenderBox& child) const;
Note: See TracChangeset for help on using the changeset viewer.