Bug 231169

Summary: [Performance] Optimize RenderLayer::calculateRects
Product: WebKit Reporter: cathiechen <cathiechen>
Component: Layout and RenderingAssignee: cathiechen <cathiechen>
Status: NEW ---    
Severity: Normal CC: bfulgham, changseok, esprehn+autocc, ews-watchlist, fred.wang, glenn, kondapallykalyan, pdr, rbuis, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=229802
Attachments:
Description Flags
Patch
simon.fraser: review-
screenshot-of-optimized-collectRects
none
screenshot-of-original-collectRects none

Description cathiechen 2021-10-04 07:39:55 PDT
Optimize the performance of RenderLayer::calculateRects
Comment 1 cathiechen 2021-10-06 06:30:44 PDT
Created attachment 440356 [details]
Patch
Comment 2 cathiechen 2021-10-06 06:33:08 PDT
Here are the percentage of RenderLayer::calculateRects
* Original: 24.1%, 25.7%, 25%
* This patch: 14.9%, 14.9%, 16.0%
Comment 3 cathiechen 2021-10-06 06:34:56 PDT
Created attachment 440357 [details]
screenshot-of-optimized-collectRects
Comment 4 cathiechen 2021-10-06 06:38:46 PDT
Created attachment 440358 [details]
screenshot-of-original-collectRects
Comment 5 Simon Fraser (smfr) 2021-10-06 21:00:29 PDT
Comment on attachment 440356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=440356&action=review

> Source/WebCore/rendering/RenderLayer.cpp:4630
> +        bool backgroundRectNotNeedRepaint = !hasBackgroundClipRect
> +            && m_repaintRectsValid
> +            && !m_repaintRects.clippedOverflowRect.intersects(backgroundRect.rect())
> +            && !m_repaintRects.outlineBoundsRect.intersects(backgroundRect.rect());

This seems wrong. Clip rect computation should be independent of cached repaint rects, and this code is not about needing repaint.
Comment 6 cathiechen 2021-10-06 21:12:12 PDT
Comment on attachment 440356 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=440356&action=review

>> Source/WebCore/rendering/RenderLayer.cpp:4630
>> +            && !m_repaintRects.outlineBoundsRect.intersects(backgroundRect.rect());
> 
> This seems wrong. Clip rect computation should be independent of cached repaint rects, and this code is not about needing repaint.

Hmm, it seems if backgroundRect or foregroundRect doesn't intersect with repaint rests, then they can't intersect with these rects: overflowClipRect, clipRect, or borderBoxRect.

The repaint rests always cover these rests, no?
Comment 7 Radar WebKit Bug Importer 2021-10-11 07:40:24 PDT
<rdar://problem/84098726>