Changeset 264008 in webkit


Ignore:
Timestamp:
Jul 6, 2020 8:46:01 PM (4 years ago)
Author:
Simon Fraser
Message:

High CPU usage on Stash search results pages
https://bugs.webkit.org/show_bug.cgi?id=214018
<rdar://problem/64832917>

Reviewed by Tim Horton.
Source/WebCore:

Stash search results pages can contain a lot of overflow:scroll areas, so scrolling thread CA commits
would take a long time because ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters() would
open and close a CA commit for each scroller.

Fix by not explicitly starting a CA commit, and only entering this code if a gesture is active and in
the momentum phase.

Also sprinkle BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS in more places that call into Core
Animation.

  • page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:

(WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
(WebCore::ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers):

  • page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:

(WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):

  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:

(WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
(WebCore::ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters):

Source/WebKit:

Stash search results pages can contain a lot of overflow:scroll areas, so scrolling thread CA commits
would take a long time because ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters() would
open and close a CA commit for each scroller.

Fix by not explicitly starting a CA commit, and only entering this code if a gesture is active and in
the momentum phase.

Also sprinkle BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS in more places that call into Core
Animation.

  • UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:

(WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r264006 r264008  
     12020-07-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        High CPU usage on Stash search results pages
     4        https://bugs.webkit.org/show_bug.cgi?id=214018
     5        <rdar://problem/64832917>
     6
     7        Reviewed by Tim Horton.
     8
     9        Stash search results pages can contain a lot of overflow:scroll areas, so scrolling thread CA commits
     10        would take a long time because ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters() would
     11        open and close a CA commit for each scroller.
     12
     13        Fix by not explicitly starting a CA commit, and only entering this code if a gesture is active and in
     14        the momentum phase.
     15
     16        Also sprinkle BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS in more places that call into Core
     17        Animation.
     18
     19        * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
     20        (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers):
     21        (WebCore::ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers):
     22        * page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm:
     23        (WebCore::ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers):
     24        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h:
     25        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
     26        (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
     27        (WebCore::ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters):
     28
    1292020-07-06  Simon Fraser  <simon.fraser@apple.com>
    230
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm

    r263485 r264008  
    3939#import "TileController.h"
    4040#import "WebCoreCALayerExtras.h"
     41#import <wtf/BlockObjCExceptions.h>
    4142#import <wtf/Deque.h>
    4243#import <wtf/text/CString.h>
     
    159160void ScrollingTreeFrameScrollingNodeMac::repositionScrollingLayers()
    160161{
     162    BEGIN_BLOCK_OBJC_EXCEPTIONS
    161163    // We use scroll position here because the root content layer is offset to account for scrollOrigin (see FrameView::positionForRootContentLayer).
    162164    static_cast<CALayer*>(scrolledContentsLayer()).position = -currentScrollPosition();
     165    END_BLOCK_OBJC_EXCEPTIONS
    163166}
    164167
    165168void ScrollingTreeFrameScrollingNodeMac::repositionRelatedLayers()
    166169{
     170    BEGIN_BLOCK_OBJC_EXCEPTIONS
    167171    auto scrollPosition = currentScrollPosition();
    168172    auto layoutViewport = this->layoutViewport();
     
    192196            m_footerLayer.get().position = FloatPoint(horizontalScrollOffsetForBanner, FrameView::yPositionForFooterLayer(scrollPosition, topContentInset, totalContentsSize().height(), footerHeight()));
    193197    }
     198    END_BLOCK_OBJC_EXCEPTIONS
    194199
    195200    m_delegate.updateScrollbarPainters();
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeOverflowScrollingNodeMac.mm

    r262294 r264008  
    3333#import "ScrollingTree.h"
    3434#import "WebCoreCALayerExtras.h"
     35#import <wtf/BlockObjCExceptions.h>
    3536#import <wtf/text/TextStream.h>
    3637
     
    9495void ScrollingTreeOverflowScrollingNodeMac::repositionScrollingLayers()
    9596{
     97    BEGIN_BLOCK_OBJC_EXCEPTIONS
    9698    [static_cast<CALayer*>(scrollContainerLayer()) _web_setLayerBoundsOrigin:currentScrollOffset()];
     99    END_BLOCK_OBJC_EXCEPTIONS
    97100}
    98101
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.h

    r262042 r264008  
    9696
    9797    ScrollController m_scrollController;
     98   
     99    bool m_inMomentumPhase { false };
    98100
    99101    RetainPtr<NSScrollerImp> m_verticalScrollerImp;
  • trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm

    r263485 r264008  
    3636#import <QuartzCore/QuartzCore.h>
    3737#import <pal/spi/mac/NSScrollerImpSPI.h>
     38#import <wtf/BlockObjCExceptions.h>
    3839
    3940namespace WebCore {
     
    122123bool ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
    123124{
    124     if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseBegan) {
    125         [m_verticalScrollerImp setUsePresentationValue:YES];
    126         [m_horizontalScrollerImp setUsePresentationValue:YES];
    127     }
    128     if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded || wheelEvent.momentumPhase() == PlatformWheelEventPhaseCancelled) {
    129         [m_verticalScrollerImp setUsePresentationValue:NO];
    130         [m_horizontalScrollerImp setUsePresentationValue:NO];
     125    bool wasInMomentumPhase = m_inMomentumPhase;
     126
     127    if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseBegan)
     128        m_inMomentumPhase = true;
     129    else if (wheelEvent.momentumPhase() == PlatformWheelEventPhaseEnded || wheelEvent.momentumPhase() == PlatformWheelEventPhaseCancelled)
     130        m_inMomentumPhase = false;
     131   
     132    if (wasInMomentumPhase != m_inMomentumPhase) {
     133        [m_verticalScrollerImp setUsePresentationValue:m_inMomentumPhase];
     134        [m_horizontalScrollerImp setUsePresentationValue:m_inMomentumPhase];
    131135    }
    132136
     
    389393void ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters()
    390394{
    391     if (m_verticalScrollerImp || m_horizontalScrollerImp) {
     395    if (m_inMomentumPhase && (m_verticalScrollerImp || m_horizontalScrollerImp)) {
     396        BEGIN_BLOCK_OBJC_EXCEPTIONS
    392397        auto scrollOffset = scrollingNode().currentScrollOffset();
    393398
    394         [CATransaction begin];
    395399        [CATransaction lock];
    396400
     
    410414
    411415        [CATransaction unlock];
    412         [CATransaction commit];
     416        END_BLOCK_OBJC_EXCEPTIONS
    413417    }
    414418}
  • trunk/Source/WebKit/ChangeLog

    r264006 r264008  
     12020-07-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        High CPU usage on Stash search results pages
     4        https://bugs.webkit.org/show_bug.cgi?id=214018
     5        <rdar://problem/64832917>
     6
     7        Reviewed by Tim Horton.
     8       
     9        Stash search results pages can contain a lot of overflow:scroll areas, so scrolling thread CA commits
     10        would take a long time because ScrollingTreeScrollingNodeDelegateMac::updateScrollbarPainters() would
     11        open and close a CA commit for each scroller.
     12
     13        Fix by not explicitly starting a CA commit, and only entering this code if a gesture is active and in
     14        the momentum phase.
     15
     16        Also sprinkle BEGIN_BLOCK_OBJC_EXCEPTIONS/END_BLOCK_OBJC_EXCEPTIONS in more places that call into Core
     17        Animation.
     18
     19        * UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm:
     20        (WebKit::ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers):
     21
    1222020-07-06  Simon Fraser  <simon.fraser@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeFrameScrollingNodeRemoteIOS.mm

    r255037 r264008  
    3333#import <WebCore/ScrollingStateScrollingNode.h>
    3434#import <WebCore/ScrollingTree.h>
     35#import <wtf/BlockObjCExceptions.h>
    3536
    3637namespace WebKit {
     
    128129void ScrollingTreeFrameScrollingNodeRemoteIOS::repositionRelatedLayers()
    129130{
     131    BEGIN_BLOCK_OBJC_EXCEPTIONS
    130132    auto layoutViewport = this->layoutViewport();
    131133
     
    143145            [m_footerLayer setPosition:FloatPoint(layoutViewport.x(), totalContentsSize().height() - footerHeight())];
    144146    }
     147    END_BLOCK_OBJC_EXCEPTIONS
    145148}
    146149
Note: See TracChangeset for help on using the changeset viewer.