Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameView.cpp

Issue 1864543002: Add UMA stats for time in paint+layout, compositing, paint invalidation and paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Dirk Mueller <mueller@kde.org> 5 * 2000 Dirk Mueller <mueller@kde.org>
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2009 Google Inc. All rights reserved. 9 * Copyright (C) 2009 Google Inc. All rights reserved.
10 * 10 *
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #include "core/page/FrameTree.h" 78 #include "core/page/FrameTree.h"
79 #include "core/page/Page.h" 79 #include "core/page/Page.h"
80 #include "core/page/scrolling/ScrollingCoordinator.h" 80 #include "core/page/scrolling/ScrollingCoordinator.h"
81 #include "core/paint/FramePainter.h" 81 #include "core/paint/FramePainter.h"
82 #include "core/paint/PaintLayer.h" 82 #include "core/paint/PaintLayer.h"
83 #include "core/paint/PaintPropertyTreeBuilder.h" 83 #include "core/paint/PaintPropertyTreeBuilder.h"
84 #include "core/plugins/PluginView.h" 84 #include "core/plugins/PluginView.h"
85 #include "core/style/ComputedStyle.h" 85 #include "core/style/ComputedStyle.h"
86 #include "core/svg/SVGDocumentExtensions.h" 86 #include "core/svg/SVGDocumentExtensions.h"
87 #include "core/svg/SVGSVGElement.h" 87 #include "core/svg/SVGSVGElement.h"
88 #include "platform/Histogram.h"
88 #include "platform/HostWindow.h" 89 #include "platform/HostWindow.h"
89 #include "platform/RuntimeEnabledFeatures.h" 90 #include "platform/RuntimeEnabledFeatures.h"
90 #include "platform/ScriptForbiddenScope.h" 91 #include "platform/ScriptForbiddenScope.h"
91 #include "platform/TraceEvent.h" 92 #include "platform/TraceEvent.h"
92 #include "platform/TracedValue.h" 93 #include "platform/TracedValue.h"
93 #include "platform/fonts/FontCache.h" 94 #include "platform/fonts/FontCache.h"
94 #include "platform/geometry/DoubleRect.h" 95 #include "platform/geometry/DoubleRect.h"
95 #include "platform/geometry/FloatRect.h" 96 #include "platform/geometry/FloatRect.h"
96 #include "platform/geometry/LayoutRect.h" 97 #include "platform/geometry/LayoutRect.h"
97 #include "platform/graphics/GraphicsContext.h" 98 #include "platform/graphics/GraphicsContext.h"
(...skipping 2417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2516 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2516 2517
2517 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); 2518 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); });
2518 PaintPropertyTreeBuilder().buildPropertyTrees(*this); 2519 PaintPropertyTreeBuilder().buildPropertyTrees(*this);
2519 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); 2520 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); });
2520 } 2521 }
2521 2522
2522 void FrameView::synchronizedPaint() 2523 void FrameView::synchronizedPaint()
2523 { 2524 {
2524 TRACE_EVENT0("blink", "FrameView::synchronizedPaint"); 2525 TRACE_EVENT0("blink", "FrameView::synchronizedPaint");
2526 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Paint.UpdateTime");
2525 2527
2526 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2528 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2527 2529
2528 LayoutView* view = layoutView(); 2530 LayoutView* view = layoutView();
2529 ASSERT(view); 2531 ASSERT(view);
2530 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InPaint); }); 2532 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InPaint); });
2531 2533
2532 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree, 2534 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree,
2533 // or when the FrameView is the main frame view of a page overlay. The page overlay is in the layer tree of 2535 // or when the FrameView is the main frame view of a page overlay. The page overlay is in the layer tree of
2534 // the host page and will be painted during synchronized painting of the hos t page. 2536 // the host page and will be painted during synchronized painting of the hos t page.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2602 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); 2604 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests);
2603 2605
2604 for (const auto& iter : graphicsLayerTimingRequests) { 2606 for (const auto& iter : graphicsLayerTimingRequests) {
2605 const GraphicsLayer* graphicsLayer = iter.key; 2607 const GraphicsLayer* graphicsLayer = iter.key;
2606 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); 2608 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value);
2607 } 2609 }
2608 } 2610 }
2609 2611
2610 void FrameView::updateStyleAndLayoutIfNeededRecursive() 2612 void FrameView::updateStyleAndLayoutIfNeededRecursive()
2611 { 2613 {
2614 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.StyleAndLayout.UpdateTime");
2615 updateStyleAndLayoutIfNeededRecursiveInternal();
2616 }
2617
2618 void FrameView::updateStyleAndLayoutIfNeededRecursiveInternal()
2619 {
2612 if (shouldThrottleRendering()) 2620 if (shouldThrottleRendering())
2613 return; 2621 return;
2614 2622
2615 // We have to crawl our entire subtree looking for any FrameViews that need 2623 // We have to crawl our entire subtree looking for any FrameViews that need
2616 // layout and make sure they are up to date. 2624 // layout and make sure they are up to date.
2617 // Mac actually tests for intersection with the dirty region and tries not t o 2625 // Mac actually tests for intersection with the dirty region and tries not t o
2618 // update layout for frames that are outside the dirty region. Not only doe s this seem 2626 // update layout for frames that are outside the dirty region. Not only doe s this seem
2619 // pointless (since those frames will have set a zero timer to layout anyway ), but 2627 // pointless (since those frames will have set a zero timer to layout anyway ), but
2620 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty 2628 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty
2621 // region but then become included later by the second frame adding rects to the dirty region 2629 // region but then become included later by the second frame adding rects to the dirty region
(...skipping 23 matching lines...) Expand all
2645 // observable effects on the frame tree but we're not quite there yet. 2653 // observable effects on the frame tree but we're not quite there yet.
2646 WillBeHeapVector<RefPtrWillBeMember<FrameView>> frameViews; 2654 WillBeHeapVector<RefPtrWillBeMember<FrameView>> frameViews;
2647 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2655 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2648 if (!child->isLocalFrame()) 2656 if (!child->isLocalFrame())
2649 continue; 2657 continue;
2650 if (FrameView* view = toLocalFrame(child)->view()) 2658 if (FrameView* view = toLocalFrame(child)->view())
2651 frameViews.append(view); 2659 frameViews.append(view);
2652 } 2660 }
2653 2661
2654 for (const auto& frameView : frameViews) 2662 for (const auto& frameView : frameViews)
2655 frameView->updateStyleAndLayoutIfNeededRecursive(); 2663 frameView->updateStyleAndLayoutIfNeededRecursiveInternal();
2656 2664
2657 RELEASE_ASSERT(!needsLayout()); 2665 RELEASE_ASSERT(!needsLayout());
2658 2666
2659 // When SVG filters are invalidated using Document::scheduleSVGFilterLayerUp dateHack() they may trigger an 2667 // When SVG filters are invalidated using Document::scheduleSVGFilterLayerUp dateHack() they may trigger an
2660 // extra style recalc. See PaintLayer::filterNeedsPaintInvalidation(). 2668 // extra style recalc. See PaintLayer::filterNeedsPaintInvalidation().
2661 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) { 2669 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) {
2662 m_frame->document()->updateLayoutTree(); 2670 m_frame->document()->updateLayoutTree();
2663 2671
2664 if (needsLayout()) 2672 if (needsLayout())
2665 layout(); 2673 layout();
(...skipping 12 matching lines...) Expand all
2678 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 2686 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
2679 2687
2680 // Ensure that we become visually non-empty eventually. 2688 // Ensure that we become visually non-empty eventually.
2681 // TODO(esprehn): This should check isRenderingReady() instead. 2689 // TODO(esprehn): This should check isRenderingReady() instead.
2682 if (frame().document()->hasFinishedParsing() && frame().loader().stateMachin e()->committedFirstRealDocumentLoad()) 2690 if (frame().document()->hasFinishedParsing() && frame().loader().stateMachin e()->committedFirstRealDocumentLoad())
2683 m_isVisuallyNonEmpty = true; 2691 m_isVisuallyNonEmpty = true;
2684 } 2692 }
2685 2693
2686 void FrameView::invalidateTreeIfNeededRecursive() 2694 void FrameView::invalidateTreeIfNeededRecursive()
2687 { 2695 {
2696 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.PaintInvalidation.UpdateTime");
2697 invalidateTreeIfNeededRecursiveInternal();
2698 }
2699
2700 void FrameView::invalidateTreeIfNeededRecursiveInternal()
2701 {
2688 RELEASE_ASSERT(layoutView()); 2702 RELEASE_ASSERT(layoutView());
2689 2703
2690 // We need to stop recursing here since a child frame view might not be thro ttled 2704 // We need to stop recursing here since a child frame view might not be thro ttled
2691 // even though we are (e.g., it didn't compute its visibility yet). 2705 // even though we are (e.g., it didn't compute its visibility yet).
2692 if (shouldThrottleRendering()) 2706 if (shouldThrottleRendering())
2693 return; 2707 return;
2694 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); 2708 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii());
2695 2709
2696 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 2710 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
2697 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); 2711 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations);
2698 2712
2699 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) 2713 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean)
2700 invalidateTreeIfNeeded(rootPaintInvalidationState); 2714 invalidateTreeIfNeeded(rootPaintInvalidationState);
2701 2715
2702 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause 2716 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause
2703 // - the frame is a detached frame; or 2717 // - the frame is a detached frame; or
2704 // - it didn't need paint invalidation. 2718 // - it didn't need paint invalidation.
2705 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required 2719 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required
2706 // paint invalidation and advance their life cycle state. 2720 // paint invalidation and advance their life cycle state.
2707 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2721 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2708 if (child->isLocalFrame()) { 2722 if (child->isLocalFrame()) {
2709 FrameView& childFrameView = *toLocalFrame(child)->view(); 2723 FrameView& childFrameView = *toLocalFrame(child)->view();
2710 // The children frames can be in any state, including stopping. 2724 // The children frames can be in any state, including stopping.
2711 // Thus we have to check that it makes sense to do paint 2725 // Thus we have to check that it makes sense to do paint
2712 // invalidation onto them here. 2726 // invalidation onto them here.
2713 if (!childFrameView.layoutView()) 2727 if (!childFrameView.layoutView())
2714 continue; 2728 continue;
2715 childFrameView.invalidateTreeIfNeededRecursive(); 2729 childFrameView.invalidateTreeIfNeededRecursiveInternal();
2716 } 2730 }
2717 } 2731 }
2718 2732
2719 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details. 2733 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details.
2720 for (auto& target : pendingDelayedPaintInvalidations) 2734 for (auto& target : pendingDelayedPaintInvalidations)
2721 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 2735 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
2722 } 2736 }
2723 2737
2724 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e) 2738 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e)
2725 { 2739 {
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 return m_hiddenForThrottling && m_crossOriginForThrottling; 4129 return m_hiddenForThrottling && m_crossOriginForThrottling;
4116 } 4130 }
4117 4131
4118 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4132 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4119 { 4133 {
4120 ASSERT(layoutView()); 4134 ASSERT(layoutView());
4121 return *layoutView(); 4135 return *layoutView();
4122 } 4136 }
4123 4137
4124 } // namespace blink 4138 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698