Title: [128521] trunk/Source
Revision
128521
Author
[email protected]
Date
2012-09-13 16:04:21 -0700 (Thu, 13 Sep 2012)

Log Message

Add optional debug logging when we fall into/out of threaded scrolling
https://bugs.webkit.org/show_bug.cgi?id=93898
<rdar://problem/12089098>

Reviewed by Simon Fraser.

Add logging when we enter and exit the threaded scrolling mode, and logs the reasons we
fall into main-thread scrolling.

The logging output looks like this:
    SCROLLING: Switching to main-thread scrolling mode. Time: 15843.554718 Reason(s): viewport-constrained objects
    SCROLLING: Switching to threaded scrolling mode. Time: 15844.550866
    SCROLLING: Switching to main-thread scrolling mode. Time: 15845.551214 Reason(s): viewport-constrained objects
    SCROLLING: Switching to threaded scrolling mode. Time: 15846.552619
    SCROLLING: Switching to main-thread scrolling mode. Time: 15847.553587 Reason(s): viewport-constrained objects
    SCROLLING: Switching to threaded scrolling mode. Time: 15848.554084

No new tests, as this is just debugging logging.

* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread):
Construct a bitfield describing the reasons we fall into main-thread scrolling mode.

* page/scrolling/ScrollingCoordinatorNone.cpp:
(WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/ScrollingTreeNode.cpp:
(WebCore::ScrollingTreeNode::ScrollingTreeNode):
* page/scrolling/ScrollingTreeNode.h:
(WebCore::ScrollingTreeNode::shouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/ScrollingTreeState.cpp:
(WebCore::ScrollingTreeState::ScrollingTreeState):
(WebCore::ScrollingTreeState::setShouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/ScrollingTreeState.h:
(WebCore::ScrollingTreeState::shouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
(WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
* page/scrolling/ScrollingCoordinator.cpp:
(WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
Use the reasons bitfield instead of a boolean.

* page/scrolling/ScrollingCoordinator.h:
(ScrollingCoordinator):
Add MainThreadScrollingReasons enum, with the current reasons that we might fallback to main-thread scrolling.

* page/scrolling/ScrollingTree.cpp:
(WebCore::ScrollingTree::scrollingPerformanceLoggingEnabled):
Fix a typo (scrollingPeformanceLoggingEnabled -> scrollingPerformanceLoggingEnabled).

* page/scrolling/mac/ScrollingTreeNodeMac.mm:
(WebCore::ScrollingTreeNodeMac::update):
(WebCore::ScrollingTreeNodeMac::setScrollPosition):
(WebCore::logThreadedScrollingMode):
Pretty-print the scrolling mode and shouldUpdateScrollLayerPositionOnMainThreadReason.

Update the scrolling tree's scrollingPerformanceLoggingEnabled preference
before the early-return if we don't have layer debugging borders on.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updatePreferences):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (128520 => 128521)


--- trunk/Source/WebCore/ChangeLog	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/ChangeLog	2012-09-13 23:04:21 UTC (rev 128521)
@@ -1,3 +1,59 @@
+2012-09-13  Tim Horton  <[email protected]>
+
+        Add optional debug logging when we fall into/out of threaded scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=93898
+        <rdar://problem/12089098>
+
+        Reviewed by Simon Fraser.
+
+        Add logging when we enter and exit the threaded scrolling mode, and logs the reasons we
+        fall into main-thread scrolling.
+
+        The logging output looks like this:
+            SCROLLING: Switching to main-thread scrolling mode. Time: 15843.554718 Reason(s): viewport-constrained objects
+            SCROLLING: Switching to threaded scrolling mode. Time: 15844.550866
+            SCROLLING: Switching to main-thread scrolling mode. Time: 15845.551214 Reason(s): viewport-constrained objects
+            SCROLLING: Switching to threaded scrolling mode. Time: 15846.552619
+            SCROLLING: Switching to main-thread scrolling mode. Time: 15847.553587 Reason(s): viewport-constrained objects
+            SCROLLING: Switching to threaded scrolling mode. Time: 15848.554084
+
+        No new tests, as this is just debugging logging.
+
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::updateShouldUpdateScrollLayerPositionOnMainThread):
+        Construct a bitfield describing the reasons we fall into main-thread scrolling mode.
+
+        * page/scrolling/ScrollingCoordinatorNone.cpp:
+        (WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/ScrollingTreeNode.cpp:
+        (WebCore::ScrollingTreeNode::ScrollingTreeNode):
+        * page/scrolling/ScrollingTreeNode.h:
+        (WebCore::ScrollingTreeNode::shouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/ScrollingTreeState.cpp:
+        (WebCore::ScrollingTreeState::ScrollingTreeState):
+        (WebCore::ScrollingTreeState::setShouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/ScrollingTreeState.h:
+        (WebCore::ScrollingTreeState::shouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/chromium/ScrollingCoordinatorChromium.cpp:
+        (WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
+        * page/scrolling/ScrollingCoordinator.cpp:
+        (WebCore::ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread):
+        Use the reasons bitfield instead of a boolean.
+
+        * page/scrolling/ScrollingCoordinator.h:
+        (ScrollingCoordinator):
+        Add MainThreadScrollingReasons enum, with the current reasons that we might fallback to main-thread scrolling.
+        
+        * page/scrolling/ScrollingTree.cpp:
+        (WebCore::ScrollingTree::scrollingPerformanceLoggingEnabled):
+        Fix a typo (scrollingPeformanceLoggingEnabled -> scrollingPerformanceLoggingEnabled).
+
+        * page/scrolling/mac/ScrollingTreeNodeMac.mm:
+        (WebCore::ScrollingTreeNodeMac::update):
+        (WebCore::ScrollingTreeNodeMac::setScrollPosition):
+        (WebCore::logThreadedScrollingMode):
+        Pretty-print the scrolling mode and shouldUpdateScrollLayerPositionOnMainThreadReason.
+
 2012-09-13  Joshua Bell  <[email protected]>
 
         [V8] Binding: Generate batched attribute/const/callback struct names can collide

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -384,11 +384,20 @@
 {
     FrameView* frameView = m_page->mainFrame()->view();
 
-    setShouldUpdateScrollLayerPositionOnMainThread(m_forceMainThreadScrollLayerPositionUpdates
-        || frameView->hasSlowRepaintObjects()
-        || (!supportsFixedPositionLayers() && frameView->hasViewportConstrainedObjects())
-        || (supportsFixedPositionLayers() && hasNonLayerFixedObjects(frameView))
-        || m_page->mainFrame()->document()->isImageDocument());
+    MainThreadScrollingReasons mainThreadScrollingReasons = (MainThreadScrollingReasons)0;
+
+    if (m_forceMainThreadScrollLayerPositionUpdates)
+        mainThreadScrollingReasons |= ForcedOnMainThread;
+    if (frameView->hasSlowRepaintObjects())
+        mainThreadScrollingReasons |= HasSlowRepaintObjects;
+    if (!supportsFixedPositionLayers() && frameView->hasViewportConstrainedObjects())
+        mainThreadScrollingReasons |= HasViewportConstrainedObjectsWithoutSupportingFixedLayers;
+    if (supportsFixedPositionLayers() && hasNonLayerFixedObjects(frameView))
+        mainThreadScrollingReasons |= HasNonLayerFixedObjects;
+    if (m_page->mainFrame()->document()->isImageDocument())
+        mainThreadScrollingReasons |= IsImageDocument;
+
+    setShouldUpdateScrollLayerPositionOnMainThread(mainThreadScrollingReasons);
 }
 
 void ScrollingCoordinator::setForceMainThreadScrollLayerPositionUpdates(bool forceMainThreadScrollLayerPositionUpdates)
@@ -435,14 +444,14 @@
     scheduleTreeStateCommit();
 }
 
-void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool shouldUpdateScrollLayerPositionOnMainThread)
+void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
 {
     // The FrameView's GraphicsLayer is likely to be out-of-synch with the PlatformLayer
     // at this point. So we'll update it before we switch back to main thread scrolling
     // in order to avoid layer positioning bugs.
-    if (shouldUpdateScrollLayerPositionOnMainThread)
+    if (reasons)
         updateMainFrameScrollLayerPosition();
-    m_scrollingTreeState->setShouldUpdateScrollLayerPositionOnMainThread(shouldUpdateScrollLayerPositionOnMainThread);
+    m_scrollingTreeState->setShouldUpdateScrollLayerPositionOnMainThread(reasons);
     scheduleTreeStateCommit();
 }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h	2012-09-13 23:04:21 UTC (rev 128521)
@@ -44,6 +44,8 @@
 
 namespace WebCore {
 
+typedef unsigned MainThreadScrollingReasons;
+
 class FrameView;
 class GraphicsLayer;
 class Page;
@@ -127,6 +129,14 @@
     // Attach/detach layer position to ancestor fixed position container.
     void setLayerIsFixedToContainerLayer(GraphicsLayer*, bool);
 
+    enum MainThreadScrollingReasonFlags {
+        ForcedOnMainThread = 1 << 0,
+        HasSlowRepaintObjects = 1 << 1,
+        HasViewportConstrainedObjectsWithoutSupportingFixedLayers = 1 << 2,
+        HasNonLayerFixedObjects = 1 << 3,
+        IsImageDocument = 1 << 4
+    };
+
 private:
     explicit ScrollingCoordinator(Page*);
 
@@ -155,7 +165,7 @@
 
     void setScrollParameters(const ScrollParameters&);
     void setWheelEventHandlerCount(unsigned);
-    void setShouldUpdateScrollLayerPositionOnMainThread(bool);
+    void setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons);
 
     void updateMainFrameScrollLayerPosition();
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingCoordinatorNone.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -67,7 +67,7 @@
 {
 }
 
-void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool)
+void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons)
 {
 }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -224,7 +224,7 @@
     m_scrollingPerformanceLoggingEnabled = flag;
 }
 
-bool ScrollingTree::scrollingPeformanceLoggingEnabled()
+bool ScrollingTree::scrollingPerformanceLoggingEnabled()
 {
     return m_scrollingPerformanceLoggingEnabled;
 }

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h	2012-09-13 23:04:21 UTC (rev 128521)
@@ -98,7 +98,7 @@
 #endif
 
     void setScrollingPerformanceLoggingEnabled(bool flag);
-    bool scrollingPeformanceLoggingEnabled();
+    bool scrollingPerformanceLoggingEnabled();
 
 private:
     explicit ScrollingTree(ScrollingCoordinator*);

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -34,7 +34,7 @@
 
 ScrollingTreeNode::ScrollingTreeNode(ScrollingTree* scrollingTree)
     : m_scrollingTree(scrollingTree)
-    , m_shouldUpdateScrollLayerPositionOnMainThread(false)
+    , m_shouldUpdateScrollLayerPositionOnMainThread(0)
     , m_horizontalScrollElasticity(ScrollElasticityNone)
     , m_verticalScrollElasticity(ScrollElasticityNone)
     , m_hasEnabledHorizontalScrollbar(false)

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeNode.h	2012-09-13 23:04:21 UTC (rev 128521)
@@ -30,6 +30,7 @@
 
 #include "IntRect.h"
 #include "ScrollTypes.h"
+#include "ScrollingCoordinator.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
@@ -47,7 +48,7 @@
     virtual void handleWheelEvent(const PlatformWheelEvent&) = 0;
     virtual void setScrollPosition(const IntPoint&) = 0;
 
-    bool shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
+    MainThreadScrollingReasons shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
 
 protected:
     explicit ScrollingTreeNode(ScrollingTree*);
@@ -74,7 +75,7 @@
     IntSize m_contentsSize;
     IntPoint m_scrollOrigin;
 
-    bool m_shouldUpdateScrollLayerPositionOnMainThread;
+    MainThreadScrollingReasons m_shouldUpdateScrollLayerPositionOnMainThread;
 
     ScrollElasticity m_horizontalScrollElasticity;
     ScrollElasticity m_verticalScrollElasticity;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeState.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeState.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeState.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -38,7 +38,7 @@
 ScrollingTreeState::ScrollingTreeState()
     : m_changedProperties(0)
     , m_wheelEventHandlerCount(0)
-    , m_shouldUpdateScrollLayerPositionOnMainThread(false)
+    , m_shouldUpdateScrollLayerPositionOnMainThread(0)
     , m_horizontalScrollElasticity(ScrollElasticityNone)
     , m_verticalScrollElasticity(ScrollElasticityNone)
     , m_hasEnabledHorizontalScrollbar(false)
@@ -88,12 +88,12 @@
     m_changedProperties |= WheelEventHandlerCount;
 }
 
-void ScrollingTreeState::setShouldUpdateScrollLayerPositionOnMainThread(bool shouldUpdateScrollLayerPositionOnMainThread)
+void ScrollingTreeState::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
 {
-    if (m_shouldUpdateScrollLayerPositionOnMainThread == shouldUpdateScrollLayerPositionOnMainThread)
+    if (m_shouldUpdateScrollLayerPositionOnMainThread == reasons)
         return;
 
-    m_shouldUpdateScrollLayerPositionOnMainThread = shouldUpdateScrollLayerPositionOnMainThread;
+    m_shouldUpdateScrollLayerPositionOnMainThread = reasons;
     m_changedProperties |= ShouldUpdateScrollLayerPositionOnMainThread;
 }
 

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeState.h (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeState.h	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeState.h	2012-09-13 23:04:21 UTC (rev 128521)
@@ -32,6 +32,7 @@
 #include "IntRect.h"
 #include "Region.h"
 #include "ScrollTypes.h"
+#include "ScrollingCoordinator.h"
 #include <wtf/PassOwnPtr.h>
 
 #if PLATFORM(MAC)
@@ -81,8 +82,8 @@
     unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; }
     void setWheelEventHandlerCount(unsigned);
 
-    bool shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
-    void setShouldUpdateScrollLayerPositionOnMainThread(bool);
+    MainThreadScrollingReasons shouldUpdateScrollLayerPositionOnMainThread() const { return m_shouldUpdateScrollLayerPositionOnMainThread; }
+    void setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons);
 
     ScrollElasticity horizontalScrollElasticity() const { return m_horizontalScrollElasticity; }
     void setHorizontalScrollElasticity(ScrollElasticity);
@@ -126,7 +127,7 @@
 
     unsigned m_wheelEventHandlerCount;
 
-    bool m_shouldUpdateScrollLayerPositionOnMainThread;
+    MainThreadScrollingReasons m_shouldUpdateScrollLayerPositionOnMainThread;
 
     ScrollElasticity m_horizontalScrollElasticity;
     ScrollElasticity m_verticalScrollElasticity;

Modified: trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/chromium/ScrollingCoordinatorChromium.cpp	2012-09-13 23:04:21 UTC (rev 128521)
@@ -223,12 +223,12 @@
         m_private->scrollLayer()->setHaveWheelEventHandlers(wheelEventHandlerCount > 0);
 }
 
-void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(bool should)
+void ScrollingCoordinator::setShouldUpdateScrollLayerPositionOnMainThread(MainThreadScrollingReasons reasons)
 {
     // We won't necessarily get a setScrollLayer() call before this one, so grab the root ourselves.
     setScrollLayer(scrollLayerForFrameView(m_page->mainFrame()->view()));
     if (m_private->scrollLayer())
-        m_private->scrollLayer()->setShouldScrollOnMainThread(should);
+        m_private->scrollLayer()->setShouldScrollOnMainThread(reasons);
 }
 
 bool ScrollingCoordinator::supportsFixedPositionLayers() const

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm (128520 => 128521)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeNodeMac.mm	2012-09-13 23:04:21 UTC (rev 128521)
@@ -29,6 +29,7 @@
 #if ENABLE(THREADED_SCROLLING)
 
 #include "PlatformWheelEvent.h"
+#include "ScrollingCoordinator.h"
 #include "ScrollingTree.h"
 #include "ScrollingTreeState.h"
 #include "Settings.h"
@@ -37,9 +38,13 @@
 
 #include <wtf/CurrentTime.h>
 #include <wtf/Deque.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/CString.h>
 
 namespace WebCore {
 
+static void logThreadedScrollingMode(unsigned mainThreadScrollingReasons);
+
 PassOwnPtr<ScrollingTreeNode> ScrollingTreeNode::create(ScrollingTree* scrollingTree)
 {
     return adoptPtr(new ScrollingTreeNodeMac(scrollingTree));
@@ -70,15 +75,22 @@
     if (state->changedProperties() & (ScrollingTreeState::ScrollLayer | ScrollingTreeState::ContentsSize | ScrollingTreeState::ViewportRect))
         updateMainFramePinState(scrollPosition());
 
-    if ((state->changedProperties() & ScrollingTreeState::ShouldUpdateScrollLayerPositionOnMainThread) && shouldUpdateScrollLayerPositionOnMainThread()) {
-        // We're transitioning to the slow "update scroll layer position on the main thread" mode.
-        // Initialize the probable main thread scroll position with the current scroll layer position.
-        if (state->changedProperties() & ScrollingTreeState::RequestedScrollPosition)
-            m_probableMainThreadScrollPosition = state->requestedScrollPosition();
-        else {
-            CGPoint scrollLayerPosition = m_scrollLayer.get().position;
-            m_probableMainThreadScrollPosition = IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
+    if ((state->changedProperties() & ScrollingTreeState::ShouldUpdateScrollLayerPositionOnMainThread)) {
+        unsigned mainThreadScrollingReasons = this->shouldUpdateScrollLayerPositionOnMainThread();
+
+        if (mainThreadScrollingReasons) {
+            // We're transitioning to the slow "update scroll layer position on the main thread" mode.
+            // Initialize the probable main thread scroll position with the current scroll layer position.
+            if (state->changedProperties() & ScrollingTreeState::RequestedScrollPosition)
+                m_probableMainThreadScrollPosition = state->requestedScrollPosition();
+            else {
+                CGPoint scrollLayerPosition = m_scrollLayer.get().position;
+                m_probableMainThreadScrollPosition = IntPoint(-scrollLayerPosition.x, -scrollLayerPosition.y);
+            }
         }
+
+        if (scrollingTree()->scrollingPerformanceLoggingEnabled())
+            logThreadedScrollingMode(mainThreadScrollingReasons);
     }
 }
 
@@ -240,7 +252,7 @@
 
     setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
 
-    if (scrollingTree()->scrollingPeformanceLoggingEnabled())
+    if (scrollingTree()->scrollingPerformanceLoggingEnabled())
         logExposedUnfilledArea();
 }
 
@@ -330,6 +342,30 @@
         WTFLogAlways("SCROLLING: Exposed tileless area. Time: %f Unfilled Pixels: %u\n", WTF::monotonicallyIncreasingTime(), unfilledArea);
 }
 
+static void logThreadedScrollingMode(unsigned mainThreadScrollingReasons)
+{
+    if (mainThreadScrollingReasons) {
+        StringBuilder reasonsDescription;
+
+        if (mainThreadScrollingReasons & ScrollingCoordinator::ForcedOnMainThread)
+            reasonsDescription.append("forced,");
+        if (mainThreadScrollingReasons & ScrollingCoordinator::HasSlowRepaintObjects)
+            reasonsDescription.append("slow-repaint objects,");
+        if (mainThreadScrollingReasons & ScrollingCoordinator::HasViewportConstrainedObjectsWithoutSupportingFixedLayers)
+            reasonsDescription.append("viewport-constrained objects,");
+        if (mainThreadScrollingReasons & ScrollingCoordinator::HasNonLayerFixedObjects)
+            reasonsDescription.append("non-layer viewport-constrained objects,");
+        if (mainThreadScrollingReasons & ScrollingCoordinator::IsImageDocument)
+            reasonsDescription.append("image document,");
+
+        // Strip the trailing comma.
+        String reasonsDescriptionTrimmed = reasonsDescription.toString().left(reasonsDescription.length() - 1);
+
+        WTFLogAlways("SCROLLING: Switching to main-thread scrolling mode. Time: %f Reason(s): %s\n", WTF::monotonicallyIncreasingTime(), reasonsDescriptionTrimmed.ascii().data());
+    } else
+        WTFLogAlways("SCROLLING: Switching to threaded scrolling mode. Time: %f\n", WTF::monotonicallyIncreasingTime());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(THREADED_SCROLLING)

Modified: trunk/Source/WebKit2/ChangeLog (128520 => 128521)


--- trunk/Source/WebKit2/ChangeLog	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebKit2/ChangeLog	2012-09-13 23:04:21 UTC (rev 128521)
@@ -1,3 +1,17 @@
+2012-09-13  Tim Horton  <[email protected]>
+
+        Add optional debug logging when we fall into/out of threaded scrolling
+        https://bugs.webkit.org/show_bug.cgi?id=93898
+        <rdar://problem/12089098>
+
+        Reviewed by Simon Fraser.
+
+        Update the scrolling tree's scrollingPerformanceLoggingEnabled preference
+        before the early-return if we don't have layer debugging borders on.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updatePreferences):
+
 2012-09-13  Sudarsana Nagineni  <[email protected]>
 
         [WK2][WTR] WebKitTestRunner needs testRunner.callShouldCloseOnWebView

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (128520 => 128521)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-09-13 23:01:34 UTC (rev 128520)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2012-09-13 23:04:21 UTC (rev 128521)
@@ -205,6 +205,9 @@
 
 void TiledCoreAnimationDrawingArea::updatePreferences(const WebPreferencesStore&)
 {
+    bool scrollingPerformanceLoggingEnabled = m_webPage->scrollingPerformanceLoggingEnabled();
+    ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled));
+
     bool showDebugBorders = m_webPage->corePage()->settings()->showDebugBorders();
 
     if (showDebugBorders == !!m_debugInfoLayer)
@@ -218,10 +221,7 @@
         m_debugInfoLayer = nullptr;
     }
 
-    bool scrollingPerformanceLoggingEnabled = m_webPage->scrollingPerformanceLoggingEnabled();
-
     ScrollingThread::dispatch(bind(&ScrollingTree::setDebugRootLayer, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), m_debugInfoLayer));
-    ScrollingThread::dispatch(bind(&ScrollingTree::setScrollingPerformanceLoggingEnabled, m_webPage->corePage()->scrollingCoordinator()->scrollingTree(), scrollingPerformanceLoggingEnabled));
 }
 
 void TiledCoreAnimationDrawingArea::dispatchAfterEnsuringUpdatedScrollPosition(const Function<void ()>& functionRef)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to