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

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

Issue 1852633002: Add UMA stats for time in paint+layout, compositing, paint invalidation and paint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 #include "core/page/FrameTree.h" 79 #include "core/page/FrameTree.h"
80 #include "core/page/Page.h" 80 #include "core/page/Page.h"
81 #include "core/page/scrolling/ScrollingCoordinator.h" 81 #include "core/page/scrolling/ScrollingCoordinator.h"
82 #include "core/paint/FramePainter.h" 82 #include "core/paint/FramePainter.h"
83 #include "core/paint/PaintLayer.h" 83 #include "core/paint/PaintLayer.h"
84 #include "core/paint/PaintPropertyTreeBuilder.h" 84 #include "core/paint/PaintPropertyTreeBuilder.h"
85 #include "core/plugins/PluginView.h" 85 #include "core/plugins/PluginView.h"
86 #include "core/style/ComputedStyle.h" 86 #include "core/style/ComputedStyle.h"
87 #include "core/svg/SVGDocumentExtensions.h" 87 #include "core/svg/SVGDocumentExtensions.h"
88 #include "core/svg/SVGSVGElement.h" 88 #include "core/svg/SVGSVGElement.h"
89 #include "platform/Histogram.h"
89 #include "platform/HostWindow.h" 90 #include "platform/HostWindow.h"
90 #include "platform/RuntimeEnabledFeatures.h" 91 #include "platform/RuntimeEnabledFeatures.h"
91 #include "platform/ScriptForbiddenScope.h" 92 #include "platform/ScriptForbiddenScope.h"
92 #include "platform/TraceEvent.h" 93 #include "platform/TraceEvent.h"
93 #include "platform/TracedValue.h" 94 #include "platform/TracedValue.h"
94 #include "platform/fonts/FontCache.h" 95 #include "platform/fonts/FontCache.h"
95 #include "platform/geometry/DoubleRect.h" 96 #include "platform/geometry/DoubleRect.h"
96 #include "platform/geometry/FloatRect.h" 97 #include "platform/geometry/FloatRect.h"
97 #include "platform/geometry/LayoutRect.h" 98 #include "platform/geometry/LayoutRect.h"
98 #include "platform/graphics/GraphicsContext.h" 99 #include "platform/graphics/GraphicsContext.h"
(...skipping 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); 2481 ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled());
2481 2482
2482 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); 2483 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InUpdatePaintProperties); });
2483 PaintPropertyTreeBuilder().buildPropertyTrees(*this); 2484 PaintPropertyTreeBuilder().buildPropertyTrees(*this);
2484 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); 2485 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); });
2485 } 2486 }
2486 2487
2487 void FrameView::synchronizedPaint() 2488 void FrameView::synchronizedPaint()
2488 { 2489 {
2489 TRACE_EVENT0("blink", "FrameView::synchronizedPaint"); 2490 TRACE_EVENT0("blink", "FrameView::synchronizedPaint");
2491 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Paint.UpdateTime");
2490 2492
2491 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame())); 2493 ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalF rame()));
2492 2494
2493 LayoutViewItem view = layoutViewItem(); 2495 LayoutViewItem view = layoutViewItem();
2494 ASSERT(!view.isNull()); 2496 ASSERT(!view.isNull());
2495 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InPaint); }); 2497 forAllNonThrottledFrameViews([](FrameView& frameView) { frameView.lifecycle( ).advanceTo(DocumentLifecycle::InPaint); });
2496 2498
2497 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree, 2499 // A null graphics layer can occur for painting of SVG images that are not p arented into the main frame tree,
2498 // or when the FrameView is the main frame view of a page overlay. The page overlay is in the layer tree of 2500 // or when the FrameView is the main frame view of a page overlay. The page overlay is in the layer tree of
2499 // the host page and will be painted during synchronized painting of the hos t page. 2501 // 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
2567 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests); 2569 collectFrameTimingRequestsRecursive(graphicsLayerTimingRequests);
2568 2570
2569 for (const auto& iter : graphicsLayerTimingRequests) { 2571 for (const auto& iter : graphicsLayerTimingRequests) {
2570 const GraphicsLayer* graphicsLayer = iter.key; 2572 const GraphicsLayer* graphicsLayer = iter.key;
2571 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value); 2573 graphicsLayer->platformLayer()->setFrameTimingRequests(iter.value);
2572 } 2574 }
2573 } 2575 }
2574 2576
2575 void FrameView::updateStyleAndLayoutIfNeededRecursive() 2577 void FrameView::updateStyleAndLayoutIfNeededRecursive()
2576 { 2578 {
2579 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.StyleAndLayout.UpdateTime");
2580 updateStyleAndLayoutIfNeededRecursiveInternal();
2581 }
2582
2583 void FrameView::updateStyleAndLayoutIfNeededRecursiveInternal()
2584 {
2577 if (shouldThrottleRendering()) 2585 if (shouldThrottleRendering())
2578 return; 2586 return;
2579 2587
2580 // We have to crawl our entire subtree looking for any FrameViews that need 2588 // We have to crawl our entire subtree looking for any FrameViews that need
2581 // layout and make sure they are up to date. 2589 // layout and make sure they are up to date.
2582 // Mac actually tests for intersection with the dirty region and tries not t o 2590 // Mac actually tests for intersection with the dirty region and tries not t o
2583 // update layout for frames that are outside the dirty region. Not only doe s this seem 2591 // update layout for frames that are outside the dirty region. Not only doe s this seem
2584 // pointless (since those frames will have set a zero timer to layout anyway ), but 2592 // pointless (since those frames will have set a zero timer to layout anyway ), but
2585 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty 2593 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty
2586 // region but then become included later by the second frame adding rects to the dirty region 2594 // region but then become included later by the second frame adding rects to the dirty region
(...skipping 23 matching lines...) Expand all
2610 // observable effects on the frame tree but we're not quite there yet. 2618 // observable effects on the frame tree but we're not quite there yet.
2611 HeapVector<Member<FrameView>> frameViews; 2619 HeapVector<Member<FrameView>> frameViews;
2612 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2620 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2613 if (!child->isLocalFrame()) 2621 if (!child->isLocalFrame())
2614 continue; 2622 continue;
2615 if (FrameView* view = toLocalFrame(child)->view()) 2623 if (FrameView* view = toLocalFrame(child)->view())
2616 frameViews.append(view); 2624 frameViews.append(view);
2617 } 2625 }
2618 2626
2619 for (const auto& frameView : frameViews) 2627 for (const auto& frameView : frameViews)
2620 frameView->updateStyleAndLayoutIfNeededRecursive(); 2628 frameView->updateStyleAndLayoutIfNeededRecursiveInternal();
2621 2629
2622 RELEASE_ASSERT(!needsLayout()); 2630 RELEASE_ASSERT(!needsLayout());
2623 2631
2624 // When SVG filters are invalidated using Document::scheduleSVGFilterLayerUp dateHack() they may trigger an 2632 // When SVG filters are invalidated using Document::scheduleSVGFilterLayerUp dateHack() they may trigger an
2625 // extra style recalc. See PaintLayer::filterNeedsPaintInvalidation(). 2633 // extra style recalc. See PaintLayer::filterNeedsPaintInvalidation().
2626 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) { 2634 if (m_frame->document()->hasSVGFilterElementsRequiringLayerUpdate()) {
2627 m_frame->document()->updateLayoutTree(); 2635 m_frame->document()->updateLayoutTree();
2628 2636
2629 if (needsLayout()) 2637 if (needsLayout())
2630 layout(); 2638 layout();
(...skipping 12 matching lines...) Expand all
2643 lifecycle().advanceTo(DocumentLifecycle::LayoutClean); 2651 lifecycle().advanceTo(DocumentLifecycle::LayoutClean);
2644 2652
2645 // Ensure that we become visually non-empty eventually. 2653 // Ensure that we become visually non-empty eventually.
2646 // TODO(esprehn): This should check isRenderingReady() instead. 2654 // TODO(esprehn): This should check isRenderingReady() instead.
2647 if (frame().document()->hasFinishedParsing() && frame().loader().stateMachin e()->committedFirstRealDocumentLoad()) 2655 if (frame().document()->hasFinishedParsing() && frame().loader().stateMachin e()->committedFirstRealDocumentLoad())
2648 m_isVisuallyNonEmpty = true; 2656 m_isVisuallyNonEmpty = true;
2649 } 2657 }
2650 2658
2651 void FrameView::invalidateTreeIfNeededRecursive() 2659 void FrameView::invalidateTreeIfNeededRecursive()
2652 { 2660 {
2661 SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.PaintInvalidation.UpdateTime");
2662 invalidateTreeIfNeededRecursiveInternal();
2663 }
2664
2665 void FrameView::invalidateTreeIfNeededRecursiveInternal()
2666 {
2653 RELEASE_ASSERT(layoutView()); 2667 RELEASE_ASSERT(layoutView());
2654 2668
2655 // We need to stop recursing here since a child frame view might not be thro ttled 2669 // We need to stop recursing here since a child frame view might not be thro ttled
2656 // even though we are (e.g., it didn't compute its visibility yet). 2670 // even though we are (e.g., it didn't compute its visibility yet).
2657 if (shouldThrottleRendering()) 2671 if (shouldThrottleRendering())
2658 return; 2672 return;
2659 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii()); 2673 TRACE_EVENT1("blink", "FrameView::invalidateTreeIfNeededRecursive", "root", layoutView()->debugName().ascii());
2660 2674
2661 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 2675 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
2662 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations); 2676 PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDela yedPaintInvalidations);
2663 2677
2664 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) 2678 if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean)
2665 invalidateTreeIfNeeded(rootPaintInvalidationState); 2679 invalidateTreeIfNeeded(rootPaintInvalidationState);
2666 2680
2667 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause 2681 // Some frames may be not reached during the above invalidateTreeIfNeeded be cause
2668 // - the frame is a detached frame; or 2682 // - the frame is a detached frame; or
2669 // - it didn't need paint invalidation. 2683 // - it didn't need paint invalidation.
2670 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required 2684 // We need to call invalidateTreeIfNeededRecursive() for such frames to fini sh required
2671 // paint invalidation and advance their life cycle state. 2685 // paint invalidation and advance their life cycle state.
2672 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { 2686 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) {
2673 if (child->isLocalFrame()) { 2687 if (child->isLocalFrame()) {
2674 FrameView& childFrameView = *toLocalFrame(child)->view(); 2688 FrameView& childFrameView = *toLocalFrame(child)->view();
2675 // The children frames can be in any state, including stopping. 2689 // The children frames can be in any state, including stopping.
2676 // Thus we have to check that it makes sense to do paint 2690 // Thus we have to check that it makes sense to do paint
2677 // invalidation onto them here. 2691 // invalidation onto them here.
2678 if (!childFrameView.layoutView()) 2692 if (!childFrameView.layoutView())
2679 continue; 2693 continue;
2680 childFrameView.invalidateTreeIfNeededRecursive(); 2694 childFrameView.invalidateTreeIfNeededRecursiveInternal();
2681 } 2695 }
2682 } 2696 }
2683 2697
2684 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details. 2698 // Process objects needing paint invalidation on the next frame. See the def inition of PaintInvalidationDelayedFull for more details.
2685 for (auto& target : pendingDelayedPaintInvalidations) 2699 for (auto& target : pendingDelayedPaintInvalidations)
2686 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull); 2700 target->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
2687 } 2701 }
2688 2702
2689 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e) 2703 void FrameView::enableAutoSizeMode(const IntSize& minSize, const IntSize& maxSiz e)
2690 { 2704 {
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4092 return m_hiddenForThrottling && m_crossOriginForThrottling; 4106 return m_hiddenForThrottling && m_crossOriginForThrottling;
4093 } 4107 }
4094 4108
4095 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const 4109 LayoutBox& FrameView::boxForScrollControlPaintInvalidation() const
4096 { 4110 {
4097 ASSERT(layoutView()); 4111 ASSERT(layoutView());
4098 return *layoutView(); 4112 return *layoutView();
4099 } 4113 }
4100 4114
4101 } // namespace blink 4115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698