Changeset 245958 in webkit


Ignore:
Timestamp:
May 31, 2019 4:03:14 AM (5 years ago)
Author:
ajuma@chromium.org
Message:

REGRESSION (r245396): Page load time performance regression
https://bugs.webkit.org/show_bug.cgi?id=198382

Reviewed by Simon Fraser.

Delay the scheduling of a rendering update by 500ms when a new
IntersectionObserver target is added during page load. This addresses
a page load time regression from r245396, which immediately scheduled a
rendering update when a target is added. Note that even with this change,
if anything else triggers a rendering update before the 500ms delay expires,
intersection observations will be updated during that rendering update.

Covered by intersection-observer/initial-observation.html

  • dom/Document.cpp:

(WebCore::Document::updateIntersectionObservations):
(WebCore::Document::scheduleInitialIntersectionObservationUpdate):

  • dom/Document.h:
  • page/IntersectionObserver.cpp:

(WebCore::IntersectionObserver::observe):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245952 r245958  
     12019-05-31  Ali Juma  <ajuma@chromium.org>
     2
     3        REGRESSION (r245396): Page load time performance regression
     4        https://bugs.webkit.org/show_bug.cgi?id=198382
     5
     6        Reviewed by Simon Fraser.
     7
     8        Delay the scheduling of a rendering update by 500ms when a new
     9        IntersectionObserver target is added during page load. This addresses
     10        a page load time regression from r245396, which immediately scheduled a
     11        rendering update when a target is added. Note that even with this change,
     12        if anything else triggers a rendering update before the 500ms delay expires,
     13        intersection observations will be updated during that rendering update.
     14
     15        Covered by intersection-observer/initial-observation.html
     16
     17        * dom/Document.cpp:
     18        (WebCore::Document::updateIntersectionObservations):
     19        (WebCore::Document::scheduleInitialIntersectionObservationUpdate):
     20        * dom/Document.h:
     21        * page/IntersectionObserver.cpp:
     22        (WebCore::IntersectionObserver::observe):
     23
    1242019-05-30  Zan Dobersek  <zdobersek@igalia.com>
    225
  • trunk/Source/WebCore/dom/Document.cpp

    r245946 r245958  
    353353};
    354354
     355#if ENABLE(INTERSECTION_OBSERVER)
     356static const Seconds intersectionObserversInitialUpdateDelay { 500_ms };
     357#endif
     358
    355359// DOM Level 2 says (letters added):
    356360//
     
    537541#if ENABLE(INTERSECTION_OBSERVER)
    538542    , m_intersectionObserversNotifyTimer(*this, &Document::notifyIntersectionObserversTimerFired)
     543    , m_intersectionObserversInitialUpdateTimer(*this, &Document::scheduleRenderingUpdate)
    539544#endif
    540545    , m_loadEventDelayTimer(*this, &Document::loadEventDelayTimerFired)
     
    74177422        return;
    74187423
     7424    m_intersectionObserversInitialUpdateTimer.stop();
     7425
    74197426    bool needsLayout = frameView->layoutContext().isLayoutPending() || (renderView() && renderView()->needsLayout());
    74207427    if (needsLayout || hasPendingStyleRecalc())
     
    75057512    m_intersectionObserversWithPendingNotifications.clear();
    75067513}
     7514
     7515void Document::scheduleInitialIntersectionObservationUpdate()
     7516{
     7517    if (m_readyState == Complete)
     7518        scheduleRenderingUpdate();
     7519    else if (!m_intersectionObserversInitialUpdateTimer.isActive())
     7520        m_intersectionObserversInitialUpdateTimer.startOneShot(intersectionObserversInitialUpdateDelay);
     7521}
    75077522#endif
    75087523
  • trunk/Source/WebCore/dom/Document.h

    r245868 r245958  
    13881388    unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
    13891389    void updateIntersectionObservations();
     1390    void scheduleInitialIntersectionObservationUpdate();
    13901391#endif
    13911392
     
    18221823    Vector<WeakPtr<IntersectionObserver>> m_intersectionObserversWithPendingNotifications;
    18231824    Timer m_intersectionObserversNotifyTimer;
     1825    Timer m_intersectionObserversInitialUpdateTimer;
    18241826#endif
    18251827
  • trunk/Source/WebCore/page/IntersectionObserver.cpp

    r245396 r245958  
    159159    if (!hadObservationTargets)
    160160        document->addIntersectionObserver(*this);
    161     document->scheduleRenderingUpdate();
     161    document->scheduleInitialIntersectionObservationUpdate();
    162162}
    163163
Note: See TracChangeset for help on using the changeset viewer.