Title: [186133] trunk/Source
Revision
186133
Author
[email protected]
Date
2015-06-30 14:45:55 -0700 (Tue, 30 Jun 2015)

Log Message

Web Inspector: Reduce rendering frames "Other" time by instrumenting compositing
https://bugs.webkit.org/show_bug.cgi?id=146168

Reviewed by Brian Burg.

Source/_javascript_Core:

* inspector/protocol/Timeline.json:
New timeline record type for compositing events.

Source/WebCore:

Added Inspector instrumentation for measuring CoreAnimation compositing time. We mark the start of a composite
event when the LayerFlushScheduler triggers a scheduled layer flush. InspectorController now exports a function
for marking the end of the composite event, which should be called during the CA transaction post-commit phase
(based on platform support). Lacking platform support, the event is considered complete after CoreAnimation
runloop observers have run.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::didComposite):
* inspector/InspectorController.h:
New export for instrumentation in WebKit2.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::willCompositeImpl):
(WebCore::InspectorInstrumentation::didCompositeImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::willComposite):
(WebCore::InspectorInstrumentation::didComposite):
Plumbing for new instrumentation.

* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):
(WebCore::InspectorTimelineAgent::willComposite):
(WebCore::InspectorTimelineAgent::didComposite):
(WebCore::toProtocol):
* inspector/InspectorTimelineAgent.h:
New Composite event type and instrumentation.

* page/FrameView.cpp:
(WebCore::FrameView::flushCompositingStateIncludingSubframes):
Hook for start of compositing.

* platform/spi/cocoa/QuartzCoreSPI.h:
New header include and interface declaration.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager.prototype._processRecord):
Added handling for new Composite record type. Paint records with a parent Composite record
are flagged to simplify processing after the event hierarchy is unpacked.

* UserInterface/Images/TimelineRecordComposite.svg: Added.
New composite record icon.

* UserInterface/Models/LayoutTimelineRecord.js:
(WebInspector.LayoutTimelineRecord):
(WebInspector.LayoutTimelineRecord.displayNameForEventType):
(WebInspector.LayoutTimelineRecord.prototype.get duringComposite): Added
Composite record support.

* UserInterface/Models/RenderingFrameTimelineRecord.js:
(WebInspector.RenderingFrameTimelineRecord.prototype.durationForTask.get validRecordForTaskType):
Add compositing time when bucketing runloop tasks, ignoring Paint events that are
contained within a Composite event.

* UserInterface/Views/LayoutTimelineOverviewGraph.js:
(WebInspector.LayoutTimelineOverviewGraph.prototype._layoutTimelineRecordAdded):
Add Composite records to paint timeline row.

* UserInterface/Views/RenderingFrameTimelineView.js:
(WebInspector.RenderingFrameTimelineView.prototype._processPendingRecords):
Small unrelated fix.

* UserInterface/Views/TimelineIcons.css:
(.composite-record .icon):
* UserInterface/Views/TimelineRecordBar.css:
(.timeline-record-bar.timeline-record-type-layout.layout-timeline-record-composite > .segment):
* UserInterface/Views/TimelineRecordTreeElement.js:
(WebInspector.TimelineRecordTreeElement):
New styles and tree element icon.

Source/WebKit2:

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::flushLayers):
Added CA transaction post-commit handlers to instrument end of composite.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (186132 => 186133)


--- trunk/Source/_javascript_Core/ChangeLog	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-06-30 21:45:55 UTC (rev 186133)
@@ -1,3 +1,13 @@
+2015-06-30  Matt Baker  <[email protected]>
+
+        Web Inspector: Reduce rendering frames "Other" time by instrumenting compositing
+        https://bugs.webkit.org/show_bug.cgi?id=146168
+
+        Reviewed by Brian Burg.
+
+        * inspector/protocol/Timeline.json:
+        New timeline record type for compositing events.
+
 2015-06-29  Dean Jackson  <[email protected]>
 
         Temporarily disable PICTURE_SIZES

Modified: trunk/Source/_javascript_Core/inspector/protocol/Timeline.json (186132 => 186133)


--- trunk/Source/_javascript_Core/inspector/protocol/Timeline.json	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/_javascript_Core/inspector/protocol/Timeline.json	2015-06-30 21:45:55 UTC (rev 186133)
@@ -13,6 +13,7 @@
                 "InvalidateLayout",
                 "Layout",
                 "Paint",
+                "Composite",
                 "RenderingFrame",
                 "ScrollLayer",
                 "ParseHTML",

Modified: trunk/Source/WebCore/ChangeLog (186132 => 186133)


--- trunk/Source/WebCore/ChangeLog	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/ChangeLog	2015-06-30 21:45:55 UTC (rev 186133)
@@ -1,3 +1,45 @@
+2015-06-30  Matt Baker  <[email protected]>
+
+        Web Inspector: Reduce rendering frames "Other" time by instrumenting compositing
+        https://bugs.webkit.org/show_bug.cgi?id=146168
+
+        Reviewed by Brian Burg.
+
+        Added Inspector instrumentation for measuring CoreAnimation compositing time. We mark the start of a composite
+        event when the LayerFlushScheduler triggers a scheduled layer flush. InspectorController now exports a function
+        for marking the end of the composite event, which should be called during the CA transaction post-commit phase
+        (based on platform support). Lacking platform support, the event is considered complete after CoreAnimation
+        runloop observers have run.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::didComposite):
+        * inspector/InspectorController.h:
+        New export for instrumentation in WebKit2.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willCompositeImpl):
+        (WebCore::InspectorInstrumentation::didCompositeImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::willComposite):
+        (WebCore::InspectorInstrumentation::didComposite):
+        Plumbing for new instrumentation.
+
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::internalStart):
+        (WebCore::InspectorTimelineAgent::internalStop):
+        (WebCore::InspectorTimelineAgent::willComposite):
+        (WebCore::InspectorTimelineAgent::didComposite):
+        (WebCore::toProtocol):
+        * inspector/InspectorTimelineAgent.h:
+        New Composite event type and instrumentation.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::flushCompositingStateIncludingSubframes):
+        Hook for start of compositing.
+
+        * platform/spi/cocoa/QuartzCoreSPI.h:
+        New header include and interface declaration.
+
 2015-06-30  Beth Dakin  <[email protected]>
 
         The bounds on InteractionInformationAtPosition should be more precise

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2015-06-30 21:45:55 UTC (rev 186133)
@@ -453,4 +453,9 @@
     return m_executionStopwatch.copyRef();
 }
 
+void InspectorController::didComposite(Frame& frame)
+{
+    InspectorInstrumentation::didComposite(frame);
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/InspectorController.h (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorController.h	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorController.h	2015-06-30 21:45:55 UTC (rev 186133)
@@ -137,6 +137,8 @@
     virtual void frontendInitialized() override;
     virtual Ref<WTF::Stopwatch> executionStopwatch() override;
 
+    WEBCORE_EXPORT void didComposite(Frame&);
+
 private:
     friend class InspectorInstrumentation;
 

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2015-06-30 21:45:55 UTC (rev 186133)
@@ -475,6 +475,18 @@
         timelineAgent->didDispatchXHRLoadEvent();
 }
 
+void InspectorInstrumentation::willCompositeImpl(InstrumentingAgents& instrumentingAgents, Frame& frame)
+{
+    if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
+        timelineAgent->willComposite(frame);
+}
+
+void InspectorInstrumentation::didCompositeImpl(InstrumentingAgents& instrumentingAgents)
+{
+    if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())
+        timelineAgent->didComposite();
+}
+
 void InspectorInstrumentation::willPaintImpl(InstrumentingAgents& instrumentingAgents, RenderObject* renderer)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2015-06-30 21:45:55 UTC (rev 186133)
@@ -164,6 +164,8 @@
     static void didDispatchXHRLoadEvent(const InspectorInstrumentationCookie&);
     static void willScrollLayer(Frame&);
     static void didScrollLayer(Frame&);
+    static void willComposite(Frame&);
+    static void didComposite(Frame&);
     static void willPaint(RenderObject*);
     static void didPaint(RenderObject*, const LayoutRect&);
     static InspectorInstrumentationCookie willRecalculateStyle(Document&);
@@ -342,6 +344,8 @@
     static void didDispatchXHRLoadEventImpl(const InspectorInstrumentationCookie&);
     static void willScrollLayerImpl(InstrumentingAgents&, Frame&);
     static void didScrollLayerImpl(InstrumentingAgents&);
+    static void willCompositeImpl(InstrumentingAgents&, Frame&);
+    static void didCompositeImpl(InstrumentingAgents&);
     static void willPaintImpl(InstrumentingAgents&, RenderObject*);
     static void didPaintImpl(InstrumentingAgents&, RenderObject*, const LayoutRect&);
     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents&, Document&);
@@ -814,6 +818,20 @@
         didDispatchXHRLoadEventImpl(cookie);
 }
 
+inline void InspectorInstrumentation::willComposite(Frame& frame)
+{
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
+        willCompositeImpl(*instrumentingAgents, frame);
+}
+
+inline void InspectorInstrumentation::didComposite(Frame& frame)
+{
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(&frame))
+        didCompositeImpl(*instrumentingAgents);
+}
+
 inline void InspectorInstrumentation::willPaint(RenderObject* renderer)
 {
     FAST_RETURN_IF_NO_FRONTENDS(void());

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2015-06-30 21:45:55 UTC (rev 186133)
@@ -170,8 +170,13 @@
 
         ASSERT(m_runLoopNestingLevel > 0);
         m_runLoopNestingLevel--;
-        if (!m_runLoopNestingLevel)
-            didCompleteCurrentRecord(TimelineRecordType::RenderingFrame);
+        if (m_runLoopNestingLevel)
+            return;
+
+        if (m_startedComposite)
+            didComposite();
+
+        didCompleteCurrentRecord(TimelineRecordType::RenderingFrame);
     });
 
     m_frameStartObserver->schedule(currentRunLoop(), kCFRunLoopEntry | kCFRunLoopAfterWaiting);
@@ -216,6 +221,7 @@
     clearRecordStack();
 
     m_enabled = false;
+    m_startedComposite = false;
 
     if (m_frontendDispatcher)
         m_frontendDispatcher->recordingStopped();
@@ -399,6 +405,20 @@
     didCompleteCurrentRecord(TimelineRecordType::RecalculateStyles);
 }
 
+void InspectorTimelineAgent::willComposite(Frame& frame)
+{
+    ASSERT(!m_startedComposite);
+    pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Composite, true, &frame);
+    m_startedComposite = true;
+}
+
+void InspectorTimelineAgent::didComposite()
+{
+    ASSERT(m_startedComposite);
+    didCompleteCurrentRecord(TimelineRecordType::Composite);
+    m_startedComposite = false;
+}
+
 void InspectorTimelineAgent::willPaint(Frame& frame)
 {
     pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Paint, true, &frame);
@@ -607,6 +627,8 @@
         return Inspector::Protocol::Timeline::EventType::Layout;
     case TimelineRecordType::Paint:
         return Inspector::Protocol::Timeline::EventType::Paint;
+    case TimelineRecordType::Composite:
+        return Inspector::Protocol::Timeline::EventType::Composite;
     case TimelineRecordType::RenderingFrame:
         return Inspector::Protocol::Timeline::EventType::RenderingFrame;
     case TimelineRecordType::ScrollLayer:
@@ -720,15 +742,8 @@
 InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorType type, InspectorClient* client)
     : InspectorAgentBase(ASCIILiteral("Timeline"), instrumentingAgents)
     , m_pageAgent(pageAgent)
-    , m_scriptDebugServer(nullptr)
-    , m_id(1)
-    , m_callStackDepth(0)
-    , m_maxCallStackDepth(5)
     , m_inspectorType(type)
     , m_client(client)
-    , m_enabled(false)
-    , m_enabledFromFrontend(false)
-    , m_runLoopNestingLevel(0)
 {
 }
 

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (186132 => 186133)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2015-06-30 21:45:55 UTC (rev 186133)
@@ -72,6 +72,7 @@
     InvalidateLayout,
     Layout,
     Paint,
+    Composite,
     RenderingFrame,
     ScrollLayer,
 
@@ -155,6 +156,8 @@
     void didScroll();
     void willDispatchXHRLoadEvent(const String&, Frame*);
     void didDispatchXHRLoadEvent();
+    void willComposite(Frame&);
+    void didComposite();
     void willPaint(Frame&);
     void didPaint(RenderObject*, const LayoutRect&);
     void willRecalculateStyle(Frame*);
@@ -229,29 +232,30 @@
     Page* page();
 
     InspectorPageAgent* m_pageAgent;
-    PageScriptDebugServer* m_scriptDebugServer;
+    PageScriptDebugServer* m_scriptDebugServer { nullptr };
 
     std::unique_ptr<Inspector::TimelineFrontendDispatcher> m_frontendDispatcher;
     RefPtr<Inspector::TimelineBackendDispatcher> m_backendDispatcher;
 
     Vector<TimelineRecordEntry> m_recordStack;
 
-    int m_id;
-    int m_callStackDepth;
-    int m_maxCallStackDepth;
+    int m_id { 1 };
+    int m_callStackDepth { 0 };
+    int m_maxCallStackDepth { 5 };
     InspectorType m_inspectorType;
     InspectorClient* m_client;
 
     Vector<TimelineRecordEntry> m_pendingConsoleProfileRecords;
 
-    bool m_enabled;
-    bool m_enabledFromFrontend;
+    bool m_enabled { false };
+    bool m_enabledFromFrontend { false };
 
 #if PLATFORM(COCOA)
     std::unique_ptr<WebCore::RunLoopObserver> m_frameStartObserver;
     std::unique_ptr<WebCore::RunLoopObserver> m_frameStopObserver;
 #endif
-    int m_runLoopNestingLevel;
+    int m_runLoopNestingLevel { 0 };
+    bool m_startedComposite { false };
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/FrameView.cpp (186132 => 186133)


--- trunk/Source/WebCore/page/FrameView.cpp	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/page/FrameView.cpp	2015-06-30 21:45:55 UTC (rev 186133)
@@ -1082,6 +1082,8 @@
 
 bool FrameView::flushCompositingStateIncludingSubframes()
 {
+    InspectorInstrumentation::willComposite(frame());
+
     bool allFramesFlushed = flushCompositingStateForThisFrame(&frame());
 
     for (Frame* child = frame().tree().firstRenderedChild(); child; child = child->tree().traverseNextRendered(m_frame.ptr())) {

Modified: trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h (186132 => 186133)


--- trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebCore/platform/spi/cocoa/QuartzCoreSPI.h	2015-06-30 21:45:55 UTC (rev 186133)
@@ -45,6 +45,7 @@
 #import <QuartzCore/CAContext.h>
 #import <QuartzCore/CAFilter.h>
 #import <QuartzCore/CATiledLayerPrivate.h>
+#import <QuartzCore/CATransactionPrivate.h>
 
 #ifdef __cplusplus
 }
@@ -112,6 +113,18 @@
 + (CAFilter *)filterWithType:(NSString *)type;
 @property (copy) NSString *name;
 @end
+
+#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+typedef enum {
+    kCATransactionPhasePreLayout,
+    kCATransactionPhasePreCommit,
+    kCATransactionPhasePostCommit,
+} CATransactionPhase;
+
+@interface CATransaction (Details)
++ (void)addCommitHandler:(void(^)(void))block forPhase:(CATransactionPhase)phase;
+@end
+#endif
 #endif // __OBJC__
 
 #endif

Modified: trunk/Source/WebInspectorUI/ChangeLog (186132 => 186133)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-06-30 21:45:55 UTC (rev 186133)
@@ -1,3 +1,46 @@
+2015-06-30  Matt Baker  <[email protected]>
+
+        Web Inspector: Reduce rendering frames "Other" time by instrumenting compositing
+        https://bugs.webkit.org/show_bug.cgi?id=146168
+
+        Reviewed by Brian Burg.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Controllers/TimelineManager.js:
+        (WebInspector.TimelineManager.prototype._processRecord):
+        Added handling for new Composite record type. Paint records with a parent Composite record
+        are flagged to simplify processing after the event hierarchy is unpacked.
+
+        * UserInterface/Images/TimelineRecordComposite.svg: Added.
+        New composite record icon.
+
+        * UserInterface/Models/LayoutTimelineRecord.js:
+        (WebInspector.LayoutTimelineRecord):
+        (WebInspector.LayoutTimelineRecord.displayNameForEventType):
+        (WebInspector.LayoutTimelineRecord.prototype.get duringComposite): Added
+        Composite record support.
+
+        * UserInterface/Models/RenderingFrameTimelineRecord.js:
+        (WebInspector.RenderingFrameTimelineRecord.prototype.durationForTask.get validRecordForTaskType):
+        Add compositing time when bucketing runloop tasks, ignoring Paint events that are
+        contained within a Composite event.
+
+        * UserInterface/Views/LayoutTimelineOverviewGraph.js:
+        (WebInspector.LayoutTimelineOverviewGraph.prototype._layoutTimelineRecordAdded):
+        Add Composite records to paint timeline row.
+
+        * UserInterface/Views/RenderingFrameTimelineView.js:
+        (WebInspector.RenderingFrameTimelineView.prototype._processPendingRecords):
+        Small unrelated fix.
+
+        * UserInterface/Views/TimelineIcons.css:
+        (.composite-record .icon):
+        * UserInterface/Views/TimelineRecordBar.css:
+        (.timeline-record-bar.timeline-record-type-layout.layout-timeline-record-composite > .segment):
+        * UserInterface/Views/TimelineRecordTreeElement.js:
+        (WebInspector.TimelineRecordTreeElement):
+        New styles and tree element icon.
+
 2015-06-30  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: iOS 8: Uncaught Exception expanding Object Prototype

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -108,6 +108,7 @@
 localizedStrings["Collapse columns"] = "Collapse columns";
 localizedStrings["Comment"] = "Comment";
 localizedStrings["Comment All Properties"] = "Comment All Properties";
+localizedStrings["Composite"] = "Composite";
 localizedStrings["Compressed"] = "Compressed";
 localizedStrings["Compression"] = "Compression";
 localizedStrings["Computed"] = "Computed";

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -262,11 +262,19 @@
         case TimelineAgent.EventType.Paint:
             // COMPATIBILITY (iOS 6): Paint records data contained x, y, width, height properties. This became a quad "clip".
             var quad = recordPayload.data.clip ? new WebInspector.Quad(recordPayload.data.clip) : null;
+            var duringComposite = recordPayload.__duringComposite || false;
             if (quad)
-                return new WebInspector.LayoutTimelineRecord(WebInspector.LayoutTimelineRecord.EventType.Paint, startTime, endTime, callFrames, sourceCodeLocation, null, null, quad.width, quad.height, quad);
+                return new WebInspector.LayoutTimelineRecord(WebInspector.LayoutTimelineRecord.EventType.Paint, startTime, endTime, callFrames, sourceCodeLocation, null, null, quad.width, quad.height, quad, duringComposite);
             else
-                return new WebInspector.LayoutTimelineRecord(WebInspector.LayoutTimelineRecord.EventType.Paint, startTime, endTime, callFrames, sourceCodeLocation, recordPayload.data.x, recordPayload.data.y, recordPayload.data.width, recordPayload.data.height);
+                return new WebInspector.LayoutTimelineRecord(WebInspector.LayoutTimelineRecord.EventType.Paint, startTime, endTime, callFrames, sourceCodeLocation, recordPayload.data.x, recordPayload.data.y, recordPayload.data.width, recordPayload.data.height, null, duringComposite);
 
+        case TimelineAgent.EventType.Composite:
+            recordPayload.children.forEach(function(childRecordPayload) {
+                console.assert(childRecordPayload.type === TimelineAgent.EventType.Paint, childRecordPayload.type);
+                childRecordPayload.__duringComposite = true;
+            });
+            return new WebInspector.LayoutTimelineRecord(WebInspector.LayoutTimelineRecord.EventType.Composite, startTime, endTime, callFrames, sourceCodeLocation);
+
         case TimelineAgent.EventType.RenderingFrame:
             if (!recordPayload.children)
                 return null;

Added: trunk/Source/WebInspectorUI/UserInterface/Images/TimelineRecordComposite.svg (0 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Images/TimelineRecordComposite.svg	                        (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Images/TimelineRecordComposite.svg	2015-06-30 21:45:55 UTC (rev 186133)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright © 2015 Apple Inc. All rights reserved. -->
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
+    <path fill="rgb(176, 204, 105)" d="M 13 1 L 3 1 C 1.898438 1 1 1.898438 1 3 L 1 13 C 1 14.101562 1.898438 15 3 15 L 13 15 C 14.101562 15 15 14.101562 15 13 L 15 3 C 15 1.898438 14.101562 1 13 1 Z"/>
+    <path fill="rgb(152, 188, 77)" d="M 13 1 L 3 1 C 1.898438 1 1 1.898438 1 3 L 1 13 C 1 14.101562 1.898438 15 3 15 L 13 15 C 14.101562 15 15 14.101562 15 13 L 15 3 C 15 1.898438 14.101562 1 13 1 M 13 2 C 13.550781 2 14 2.449219 14 3 L 14 13 C 14 13.550781 13.550781 14 13 14 L 3 14 C 2.449219 14 2 13.550781 2 13 L 2 3 C 2 2.449219 2.449219 2 3 2 L 13 2"/>
+    <path fill="rgb(152, 188, 77)" d="M 4.773438 11.542969 C 3.855469 10.621094 3.390625 9.347656 3.390625 7.769531 C 3.390625 6.15625 3.863281 4.878906 4.789062 3.964844 C 5.710938 3.054688 7.003906 2.59375 8.625 2.59375 C 9.570312 2.59375 10.519531 2.707031 11.441406 2.929688 C 11.890625 3.035156 12.210938 3.4375 12.210938 3.902344 L 12.210938 5.195312 C 12.210938 5.519531 12.050781 5.824219 11.789062 6.011719 C 11.613281 6.132812 11.410156 6.195312 11.207031 6.195312 C 11.097656 6.195312 10.984375 6.179688 10.878906 6.140625 C 10.015625 5.835938 9.308594 5.683594 8.769531 5.683594 C 8.058594 5.683594 7.753906 5.941406 7.589844 6.132812 C 7.296875 6.476562 7.148438 7.019531 7.148438 7.746094 C 7.148438 8.445312 7.308594 8.972656 7.621094 9.320312 C 7.808594 9.523438 8.148438 9.796875 8.921875 9.796875 C 9.542969 9.796875 10.1875 9.632812 10.839844 9.308594 C 10.980469 9.242188 11.132812 9.207031 11.285156 9.207031 C 11.46875 9.207031 11.648438 9.257812 11
 .8125 9.359375 C 12.105469 9.539062 12.285156 9.859375 12.285156 10.207031 L 12.285156 11.425781 C 12.285156 11.820312 12.050781 12.179688 11.691406 12.339844 C 10.792969 12.738281 9.730469 12.941406 8.527344 12.941406 C 6.957031 12.941406 5.691406 12.472656 4.773438 11.542969"/>
+    <path fill="white" d="M 11.285156 11.425781 C 10.515625 11.769531 9.597656 11.941406 8.527344 11.941406 C 7.226562 11.941406 6.210938 11.574219 5.484375 10.839844 C 4.757812 10.105469 4.394531 9.082031 4.394531 7.769531 C 4.394531 6.429688 4.757812 5.398438 5.492188 4.675781 C 6.222656 3.957031 7.269531 3.59375 8.625 3.59375 C 9.492188 3.59375 10.351562 3.695312 11.210938 3.902344 L 11.210938 5.195312 C 10.238281 4.855469 9.425781 4.683594 8.769531 4.683594 C 7.933594 4.683594 7.285156 4.949219 6.832031 5.484375 C 6.375 6.015625 6.148438 6.769531 6.148438 7.746094 C 6.148438 8.707031 6.394531 9.453125 6.882812 9.992188 C 7.371094 10.527344 8.050781 10.796875 8.921875 10.796875 C 9.703125 10.796875 10.488281 10.601562 11.285156 10.207031 Z"/>
+</svg>

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/LayoutTimelineRecord.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Models/LayoutTimelineRecord.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/LayoutTimelineRecord.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -25,7 +25,7 @@
 
 WebInspector.LayoutTimelineRecord = class LayoutTimelineRecord extends WebInspector.TimelineRecord
 {
-    constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, x, y, width, height, quad)
+    constructor(eventType, startTime, endTime, callFrames, sourceCodeLocation, x, y, width, height, quad, duringComposite)
     {
         super(WebInspector.TimelineRecord.Type.Layout, startTime, endTime, callFrames, sourceCodeLocation);
 
@@ -40,6 +40,7 @@
         this._width = typeof width === "number" ? width : NaN;
         this._height = typeof height === "number" ? height : NaN;
         this._quad = quad instanceof WebInspector.Quad ? quad : null;
+        this._duringComposite = duringComposite || false;
     }
 
     // Static
@@ -59,6 +60,8 @@
             return WebInspector.UIString("Layout");
         case WebInspector.LayoutTimelineRecord.EventType.Paint:
             return WebInspector.UIString("Paint");
+        case WebInspector.LayoutTimelineRecord.EventType.Composite:
+            return WebInspector.UIString("Composite");
         }
     }
 
@@ -106,6 +109,11 @@
         return this._quad;
     }
 
+    get duringComposite()
+    {
+        return this._duringComposite;
+    }
+
     saveIdentityToCookie(cookie)
     {
         super.saveIdentityToCookie(cookie);
@@ -120,7 +128,8 @@
     InvalidateLayout: "layout-timeline-record-invalidate-layout",
     ForcedLayout: "layout-timeline-record-forced-layout",
     Layout: "layout-timeline-record-layout",
-    Paint: "layout-timeline-record-paint"
+    Paint: "layout-timeline-record-paint",
+    Composite: "layout-timeline-record-composite"
 };
 
 WebInspector.LayoutTimelineRecord.TypeIdentifier = "layout-timeline-record";

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/RenderingFrameTimelineRecord.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Models/RenderingFrameTimelineRecord.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/RenderingFrameTimelineRecord.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -83,9 +83,9 @@
             case WebInspector.RenderingFrameTimelineRecord.TaskType.Script:
                 return record.type === WebInspector.TimelineRecord.Type.Script;
             case WebInspector.RenderingFrameTimelineRecord.TaskType.Layout:
-                return record.type === WebInspector.TimelineRecord.Type.Layout && record.eventType !== WebInspector.LayoutTimelineRecord.EventType.Paint;
+                return record.type === WebInspector.TimelineRecord.Type.Layout && record.eventType !== WebInspector.LayoutTimelineRecord.EventType.Paint && record.eventType !== WebInspector.LayoutTimelineRecord.EventType.Composite;
             case WebInspector.RenderingFrameTimelineRecord.TaskType.Paint:
-                return record.type === WebInspector.TimelineRecord.Type.Layout && record.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint;
+                return record.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint || record.eventType === WebInspector.LayoutTimelineRecord.EventType.Composite;
             default:
                 console.error("Unsupported task type: " + taskType);
                 return false;
@@ -106,14 +106,21 @@
                 return previousValue + currentDuration;
             }, 0);
 
-            // Time spent in layout events which were synchronously triggered from _javascript_ must be deducted from the
-            // rendering frame's script duration, to prevent the time from being counted twice.
             if (taskType === WebInspector.RenderingFrameTimelineRecord.TaskType.Script) {
+                // Layout events synchronously triggered from _javascript_ must be subtracted from the total
+                // script time, to prevent the time from being counted twice.
                 duration -= this._children.reduce(function(previousValue, currentValue) {
                     if (currentValue.type === WebInspector.TimelineRecord.Type.Layout && (currentValue.sourceCodeLocation || currentValue.callFrames))
                         return previousValue + currentValue.duration;
                     return previousValue;
                 }, 0);
+            } else if (taskType === WebInspector.RenderingFrameTimelineRecord.TaskType.Paint) {
+                // Paint events triggered during a Composite event must be subtracted from the total painting time,
+                // since the compositing time already includes time spent in these Paint events.
+                var paintRecords = this._children.filter(function(record) { return record.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint; });
+                duration -= paintRecords.reduce(function(previousValue, currentValue) {
+                    return currentValue.duringComposite ? previousValue + currentValue.duration : previousValue;
+                }, 0);
             }
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineOverviewGraph.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineOverviewGraph.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayoutTimelineOverviewGraph.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -105,7 +105,7 @@
         var layoutTimelineRecord = event.data.record;
         console.assert(layoutTimelineRecord instanceof WebInspector.LayoutTimelineRecord);
 
-        if (layoutTimelineRecord.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint)
+        if (layoutTimelineRecord.eventType === WebInspector.LayoutTimelineRecord.EventType.Paint || layoutTimelineRecord.eventType === WebInspector.LayoutTimelineRecord.EventType.Composite)
             this._timelinePaintRecordRow.records.push(layoutTimelineRecord);
         else
             this._timelineLayoutRecordRow.records.push(layoutTimelineRecord);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RenderingFrameTimelineView.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -225,6 +225,7 @@
 
                     this._dataGrid.addRowInSortOrder(layoutTreeElement, layoutDataGridNode, treeElement);
                 } else if (childRecord.type === WebInspector.TimelineRecord.Type.Script) {
+                    var rootNodes = [];
                     if (childRecord.profile) {
                         // FIXME: Support using the bottom-up tree once it is implemented.
                         rootNodes = childRecord.profile.topDownRootNodes;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineIcons.css	2015-06-30 21:45:55 UTC (rev 186133)
@@ -75,6 +75,10 @@
     content: url(../Images/TimelineRecordPaint.svg);
 }
 
+.composite-record .icon {
+    content: url(../Images/TimelineRecordComposite.svg);
+}
+
 .rendering-frame-record .icon {
     content: url(../Images/TimelineRecordRenderingFrame.svg);
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.css (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.css	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordBar.css	2015-06-30 21:45:55 UTC (rev 186133)
@@ -87,7 +87,9 @@
     border-color: rgb(212, 108, 108);
 }
 
-.timeline-record-bar.timeline-record-type-layout.layout-timeline-record-paint > .segment {
+
+.timeline-record-bar.timeline-record-type-layout.layout-timeline-record-paint > .segment,
+.timeline-record-bar.timeline-record-type-layout.layout-timeline-record-composite > .segment {
     background-color: rgb(176, 204, 105);
     border-color: rgb(152, 188, 77);
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js (186132 => 186133)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordTreeElement.js	2015-06-30 21:45:55 UTC (rev 186133)
@@ -62,6 +62,9 @@
             case WebInspector.LayoutTimelineRecord.EventType.Paint:
                 iconStyleClass = WebInspector.TimelineRecordTreeElement.PaintRecordIconStyleClass;
                 break;
+            case WebInspector.LayoutTimelineRecord.EventType.Composite:
+                iconStyleClass = WebInspector.TimelineRecordTreeElement.CompositeRecordIconStyleClass;
+                break;
             default:
                 console.error("Unknown LayoutTimelineRecord eventType: " + timelineRecord.eventType, timelineRecord);
             }
@@ -157,6 +160,7 @@
 WebInspector.TimelineRecordTreeElement.StyleRecordIconStyleClass = "style-record";
 WebInspector.TimelineRecordTreeElement.LayoutRecordIconStyleClass = "layout-record";
 WebInspector.TimelineRecordTreeElement.PaintRecordIconStyleClass = "paint-record";
+WebInspector.TimelineRecordTreeElement.CompositeRecordIconStyleClass = "composite-record";
 WebInspector.TimelineRecordTreeElement.RenderingFrameRecordIconStyleClass = "rendering-frame-record";
 WebInspector.TimelineRecordTreeElement.EvaluatedRecordIconStyleClass = "evaluated-record";
 WebInspector.TimelineRecordTreeElement.EventRecordIconStyleClass = "event-record";

Modified: trunk/Source/WebKit2/ChangeLog (186132 => 186133)


--- trunk/Source/WebKit2/ChangeLog	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-30 21:45:55 UTC (rev 186133)
@@ -1,3 +1,16 @@
+2015-06-30  Matt Baker  <[email protected]>
+
+        Web Inspector: Reduce rendering frames "Other" time by instrumenting compositing
+        https://bugs.webkit.org/show_bug.cgi?id=146168
+
+        Reviewed by Brian Burg.
+
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::flushLayers):
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::flushLayers):
+        Added CA transaction post-commit handlers to instrument end of composite.
+
 2015-06-30  Beth Dakin  <[email protected]>
 
         The bounds on InteractionInformationAtPosition should be more precise

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (186132 => 186133)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm	2015-06-30 21:45:55 UTC (rev 186133)
@@ -40,8 +40,10 @@
 #import <WebCore/DebugPageOverlays.h>
 #import <WebCore/Frame.h>
 #import <WebCore/FrameView.h>
+#import <WebCore/InspectorController.h>
 #import <WebCore/MainFrame.h>
 #import <WebCore/PageOverlayController.h>
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebCore/RenderLayerCompositor.h>
 #import <WebCore/RenderView.h>
 #import <WebCore/Settings.h>
@@ -359,6 +361,12 @@
     FloatRect visibleRect(FloatPoint(), m_viewSize);
     visibleRect.intersect(m_scrolledExposedRect);
 
+#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+    [CATransaction addCommitHandler:^{
+        m_webPage.corePage()->inspectorController().didComposite(m_webPage.mainFrameView()->frame());
+    } forPhase:kCATransactionPhasePostCommit];
+#endif
+
     m_webPage.mainFrameView()->flushCompositingStateIncludingSubframes();
 
     // Because our view-relative overlay root layer is not attached to the FrameView's GraphicsLayer tree, we need to flush it manually.

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


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2015-06-30 21:40:01 UTC (rev 186132)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm	2015-06-30 21:45:55 UTC (rev 186133)
@@ -43,10 +43,12 @@
 #import <WebCore/FrameView.h>
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/GraphicsLayerCA.h>
+#import <WebCore/InspectorController.h>
 #import <WebCore/MachSendRight.h>
 #import <WebCore/MainFrame.h>
 #import <WebCore/Page.h>
 #import <WebCore/PlatformCAAnimationCocoa.h>
+#import <WebCore/QuartzCoreSPI.h>
 #import <WebCore/RenderLayerBacking.h>
 #import <WebCore/RenderLayerCompositor.h>
 #import <WebCore/RenderView.h>
@@ -388,6 +390,12 @@
         if (m_viewOverlayRootLayer)
             m_viewOverlayRootLayer->flushCompositingState(visibleRect);
 
+#if (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100)
+        [CATransaction addCommitHandler:^{
+            m_webPage.corePage()->inspectorController().didComposite(m_webPage.mainFrameView()->frame());
+        } forPhase:kCATransactionPhasePostCommit];
+#endif
+
         bool returnValue = m_webPage.mainFrameView()->flushCompositingStateIncludingSubframes();
 #if ENABLE(ASYNC_SCROLLING)
         if (ScrollingCoordinator* scrollingCoordinator = m_webPage.corePage()->scrollingCoordinator())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to