Title: [245958] trunk/Source/WebCore
Revision
245958
Author
aj...@chromium.org
Date
2019-05-31 04:03:14 -0700 (Fri, 31 May 2019)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (245957 => 245958)


--- trunk/Source/WebCore/ChangeLog	2019-05-31 08:17:39 UTC (rev 245957)
+++ trunk/Source/WebCore/ChangeLog	2019-05-31 11:03:14 UTC (rev 245958)
@@ -1,3 +1,26 @@
+2019-05-31  Ali Juma  <aj...@chromium.org>
+
+        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):
+
 2019-05-30  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed. Suppress -Wunused-variable warnings for the unused static

Modified: trunk/Source/WebCore/dom/Document.cpp (245957 => 245958)


--- trunk/Source/WebCore/dom/Document.cpp	2019-05-31 08:17:39 UTC (rev 245957)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-05-31 11:03:14 UTC (rev 245958)
@@ -352,6 +352,10 @@
     bool m_disallowLayout { false };
 };
 
+#if ENABLE(INTERSECTION_OBSERVER)
+static const Seconds intersectionObserversInitialUpdateDelay { 500_ms };
+#endif
+
 // DOM Level 2 says (letters added):
 //
 // a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
@@ -536,6 +540,7 @@
 #endif
 #if ENABLE(INTERSECTION_OBSERVER)
     , m_intersectionObserversNotifyTimer(*this, &Document::notifyIntersectionObserversTimerFired)
+    , m_intersectionObserversInitialUpdateTimer(*this, &Document::scheduleRenderingUpdate)
 #endif
     , m_loadEventDelayTimer(*this, &Document::loadEventDelayTimerFired)
 #if PLATFORM(IOS_FAMILY) && ENABLE(DEVICE_ORIENTATION)
@@ -7416,6 +7421,8 @@
     if (!frameView)
         return;
 
+    m_intersectionObserversInitialUpdateTimer.stop();
+
     bool needsLayout = frameView->layoutContext().isLayoutPending() || (renderView() && renderView()->needsLayout());
     if (needsLayout || hasPendingStyleRecalc())
         return;
@@ -7504,6 +7511,14 @@
     }
     m_intersectionObserversWithPendingNotifications.clear();
 }
+
+void Document::scheduleInitialIntersectionObservationUpdate()
+{
+    if (m_readyState == Complete)
+        scheduleRenderingUpdate();
+    else if (!m_intersectionObserversInitialUpdateTimer.isActive())
+        m_intersectionObserversInitialUpdateTimer.startOneShot(intersectionObserversInitialUpdateDelay);
+}
 #endif
 
 #if ENABLE(RESIZE_OBSERVER)

Modified: trunk/Source/WebCore/dom/Document.h (245957 => 245958)


--- trunk/Source/WebCore/dom/Document.h	2019-05-31 08:17:39 UTC (rev 245957)
+++ trunk/Source/WebCore/dom/Document.h	2019-05-31 11:03:14 UTC (rev 245958)
@@ -1387,6 +1387,7 @@
     void removeIntersectionObserver(IntersectionObserver&);
     unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
     void updateIntersectionObservations();
+    void scheduleInitialIntersectionObservationUpdate();
 #endif
 
 #if ENABLE(RESIZE_OBSERVER)
@@ -1821,6 +1822,7 @@
     Vector<WeakPtr<IntersectionObserver>> m_intersectionObservers;
     Vector<WeakPtr<IntersectionObserver>> m_intersectionObserversWithPendingNotifications;
     Timer m_intersectionObserversNotifyTimer;
+    Timer m_intersectionObserversInitialUpdateTimer;
 #endif
 
 #if ENABLE(RESIZE_OBSERVER)

Modified: trunk/Source/WebCore/page/IntersectionObserver.cpp (245957 => 245958)


--- trunk/Source/WebCore/page/IntersectionObserver.cpp	2019-05-31 08:17:39 UTC (rev 245957)
+++ trunk/Source/WebCore/page/IntersectionObserver.cpp	2019-05-31 11:03:14 UTC (rev 245958)
@@ -158,7 +158,7 @@
     auto* document = trackingDocument();
     if (!hadObservationTargets)
         document->addIntersectionObserver(*this);
-    document->scheduleRenderingUpdate();
+    document->scheduleInitialIntersectionObservationUpdate();
 }
 
 void IntersectionObserver::unobserve(Element& target)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to