New issue
Advanced search Search tips

Issue 725712 link

Starred by 4 users

Issue metadata

Status: Duplicate
Owner: ----
Closed: May 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

UpdateLayerTree executed each time a transition happened and is expensive when the structure is complex

Reported by samuel.m...@gmail.com, May 23 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/60.0.3080.5 Chrome/60.0.3080.5 Safari/537.36

Steps to reproduce the problem:
1. Open the attached file
2. Open the console and capture the performance
3. Press Enter to launch the transition
4. Stop the performance profiling

The current example creates 50 000 div in a container. Each one creates a layer (since they are positioned absolutely). When pressing enter, it moves a div using a transition by changing the value of a transform. (This div is not a child of the container)

On the timeline, we can see that a "UpdateLayerTree" operation occurs before the browser starts animating. It takes around 50ms on my laptop (well, there are 50000 divs in the structure...). But on a lowend device, it could be a lot more.. as throttling the cpu down to 20x can show

What is the expected behavior?

What went wrong?
Since we only change the transform value on the node, we're wondering why this updateLayerTree occurs ?

I'm also wondering if this behavior is something that will be adressed with slimming paint v2 ?

Finally, would there be something we could do to improve the updateLayerTree operation performance from the web application point of view without reducing the amount of layers ? 
(as web developper point of view, it's like the performance of a component is affected by another component, non related to the first one, on the page.)

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 60.0.3080.5  Channel: n/a
OS Version: 
Flash Version: Shockwave Flash 11.2 r999

This seems to be related to ttps://bugs.chromium.org/p/chromium/issues/detail?id=720925
 
index.html
1.6 KB View Download
timeline.png
87.8 KB View Download
Labels: PaintTeamTriaged-20170525 BugSource-User
Status: Available (was: Unconfirmed)
To answer the questions:
If the document lifecycle decides a layer update is needed for the document, as it is due to the transform, then we update the whole document layer tree. It's not strictly necessary but for whatever reason we do not try to identify cases that would allow us to avoid work. This is not historically my area of the code but I am looking into it.

The hope is to improve tings with Slimming Paint V2 but we'll see what happens in practice. Some portions have landed but they have not avoided costs like this.

Beyond reducing the number of layers there's not much you can do as far as I know, at least in this situation. I agree that unrelated parts of the page should not be correlated.

A better bug for reference is https://bugs.chromium.org/p/chromium/issues/detail?id=516437, where I just posted profile data that shows why this is structurally hard to fix.


Thanks a lot for your answers.

I wanted to check the issue you mentionned but it seems that i don't have the permissions. Is there something i can do to get those ?

Anyway, thanks again for your answers.
I'm sorry about the permissions. It has some info we would rather not leak. Here's a repost of the profile data:

Profiling reveals why this is a largely intractable problem in the current world. Using the gperftools on the example from Docs, focusing on code that passes through UpdateLifecyclePhasesInternal (which contains the tracing block for UpdateLayerTree) we get this list below of top cpu users.

Of note, no method uses more than 1.18% itself.

There are 160 methods here and they account for only 24% of the total cost.

Basically a huge number of methods are called that each take a tiny amount of time, which is almost impossible to optimize easily.

The only way to reduce the cost would be to process fewer paint layers, and the most obvious way to do that is to not process those that we cannot see. But they all affect the length of the page to some extent, so we can correctly paint the scrollbar.

It is worth also noting that come of the cost is in SPv2 methods, like the pre paint walk and the geometry mapper, that would be worth optimizing. Although as far as I know they are already somewhat optimized.

(pprof) top
Showing nodes accounting for 12.78s, 24.72% of 51.70s total
Dropped 362 nodes (cum <= 0.26s)
Showing top 160 nodes out of 192
      flat  flat%   sum%        cum   cum%
     0.61s  1.18%  1.18%      0.61s  1.18%  blink::PaintLayerStackingNodeIterator::Next
     0.59s  1.14%  2.32%      4.93s  9.54%  blink::CompositingInputsUpdater::UpdateRecursive
     0.49s  0.95%  3.27%      0.92s  1.78%  blink::AccumulateOffsetTowardsAncestor
     0.42s  0.81%  4.08%      0.86s  1.66%  blink::PaintPropertyTreeBuilder::UpdatePropertiesForSelf
     0.41s  0.79%  4.87%      0.41s  0.79%  blink::PaintLayer::ContainingLayer
     0.39s  0.75%  5.63%      0.85s  1.64%  blink::LayoutGeometryMap::PushMappingsToAncestor
     0.35s  0.68%  6.31%      2.19s  4.24%  blink::PaintInvalidator::InvalidatePaint
     0.32s  0.62%  6.92%      0.32s  0.62%  blink::LayoutObject::Container
     0.31s   0.6%  7.52%      4.57s  8.84%  blink::PrePaintTreeWalk::Walk
     0.30s  0.58%  8.10%      0.30s  0.58%  blink::PaintLayer::SticksToScroller
     0.28s  0.54%  8.65%      0.31s   0.6%  WTF::Partitions::FastFree
     0.28s  0.54%  9.19%      0.69s  1.33%  blink::CompositingLayerAssigner::AssignLayersToBackingsInternal
     0.28s  0.54%  9.73%      1.18s  2.28%  blink::LayoutObject::MapLocalToAncestor
     0.24s  0.46% 10.19%      0.36s   0.7%  blink::LayoutBoxModelObject::RelativePositionOffset
     0.23s  0.44% 10.64%      3.36s  6.50%  blink::PaintLayerPainter::Paint
     0.22s  0.43% 11.06%      0.22s  0.43%  blink::LayoutBox::VisualOverflowRect
     0.22s  0.43% 11.49%      0.22s  0.43%  blink::PaintLayer::ClearNeedsRepaintRecursively
     0.22s  0.43% 11.91%      0.22s  0.43%  blink::PaintLayerCompositor::CanBeComposited
     0.21s  0.41% 12.32%      0.21s  0.41%  <unknown>
     0.20s  0.39% 12.71%      0.20s  0.39%  blink::ComputedStyle::HasTransformRelatedProperty
     0.20s  0.39% 13.09%      0.22s  0.43%  blink::GraphicsLayerUpdater::UpdateRecursive
     0.19s  0.37% 13.46%      1.06s  2.05%  blink::CompositingRequirementsUpdater::UpdateRecursive
     0.17s  0.33% 13.79%      0.18s  0.35%  blink::CompositingReasonFinder::NonStyleDeterminedDirectReasons
     0.17s  0.33% 14.12%      0.17s  0.33%  blink::PaintLayer::ScrollsOverflow
     0.17s  0.33% 14.45%      0.49s  0.95%  blink::PaintLayerClipper::CalculateRects
     0.16s  0.31% 14.76%      0.16s  0.31%  blink::LayoutBox::LocalVisualRect
     0.16s  0.31% 15.07%      0.40s  0.77%  blink::LayoutBox::LocationContainer
     0.16s  0.31% 15.38%      0.68s  1.32%  blink::LayoutBox::OffsetFromContainer
     0.16s  0.31% 15.69%      0.16s  0.31%  blink::LayoutObject::ContainingBlock
     0.16s  0.31% 16.00%      0.21s  0.41%  blink::PaintLayer::Update3DTransformedDescendantStatus
     0.15s  0.29% 16.29%      0.15s  0.29%  blink::PaintLayer::EnsureClipRectsCache
     0.15s  0.29% 16.58%      3.38s  6.54%  blink::PaintLayerPainter::PaintLayerContents
     0.14s  0.27% 16.85%      0.14s  0.27%  MallocExtension::VerifyAllMemory
     0.14s  0.27% 17.12%      0.14s  0.27%  blink::CompositingReasonFinder::RequiresCompositingForAnimation
     0.13s  0.25% 17.37%      0.13s  0.25%  WTF::PartitionAllocator::FreeVectorBacking
     0.13s  0.25% 17.62%      0.13s  0.25%  blink::LayoutBoxModelObject::BorderLeft
     0.12s  0.23% 17.85%      0.12s  0.23%  ChromeMainDelegate::ShouldTerminateServiceManagerOnInstanceQuit
     0.12s  0.23% 18.09%      0.12s  0.23%  WTF::PartitionAllocator::AllocateBacking
     0.12s  0.23% 18.32%      0.13s  0.25%  blink::ClipRects::Create
     0.12s  0.23% 18.55%      0.14s  0.27%  blink::GraphicsLayerTreeBuilder::Rebuild
     0.12s  0.23% 18.78%      0.46s  0.89%  blink::PaintInvalidator::MapLocalRectToVisualRectInBacking
     0.12s  0.23% 19.01%      0.12s  0.23%  blink::PropertyTreeState::operator=
     0.11s  0.21% 19.23%      0.11s  0.21%  blink::ClipPaintPropertyNode::GetClipCache
     0.11s  0.21% 19.44%      0.11s  0.21%  blink::ComputedStyle::HasTransform
     0.11s  0.21% 19.65%      0.11s  0.21%  blink::LayoutGeometryMap::PopMappingsToAncestor
     0.11s  0.21% 19.86%      0.11s  0.21%  blink::PaintLayerPainter::PaintedOutputInvisible
     0.11s  0.21% 20.08%      0.11s  0.21%  blink::PaintLayerStackingNode::AncestorStackingContextNode
     0.10s  0.19% 20.27%      0.10s  0.19%  blink::LayoutBoxModelObject::BackgroundStolenForBeingBody
     0.10s  0.19% 20.46%      0.10s  0.19%  blink::LayoutObject::HasClipRelatedProperty
     0.10s  0.19% 20.66%      0.10s  0.19%  blink::PaintLayer::GetCompositingState
     0.10s  0.19% 20.85%      2.17s  4.20%  blink::PaintLayerClipper::CalculateBackgroundClipRect
     0.10s  0.19% 21.04%      0.10s  0.19%  blink::PaintLayerScrollableArea::VerticalScrollbarWidth
     0.09s  0.17% 21.22%      0.12s  0.23%  blink::BlockFlowPaintInvalidator::InvalidateDisplayItemClients
     0.09s  0.17% 21.39%      0.26s   0.5%  blink::LayoutBox::PhysicalLocation
     0.09s  0.17% 21.57%      0.09s  0.17%  tcmalloc::FL_Push
     0.08s  0.15% 21.72%      0.43s  0.83%  blink::GeometryMapper::LocalToAncestorClipRectInternal
     0.08s  0.15% 21.88%      0.19s  0.37%  blink::LayoutBox::OverflowClipRect
     0.08s  0.15% 22.03%      0.15s  0.29%  blink::PaintInvalidationCapableScrollableArea::InvalidatePaintOfScrollControlsIfNeeded
     0.07s  0.14% 22.17%      0.16s  0.31%  (anonymous namespace)::do_free_with_callback
     0.07s  0.14% 22.30%      0.14s  0.27%  blink::GeometryMapper::LocalToAncestorMatrixInternal
     0.07s  0.14% 22.44%      0.09s  0.17%  blink::GeometryMapperClipCache::GetCachedClip
     0.07s  0.14% 22.57%      0.48s  0.93%  blink::PaintLayer::UpdateLayerPosition
     0.07s  0.14% 22.71%      0.13s  0.25%  blink::PrePaintTreeWalkContext::PrePaintTreeWalkContext
     0.06s  0.12% 22.82%      1.95s  3.77%  blink::PaintLayerClipper::GetClipRects
     0.05s 0.097% 22.92%      0.14s  0.27%  blink::BoxPaintInvalidator::InvalidateScrollingContentsBackgroundIfNeeded
     0.05s 0.097% 23.02%      0.32s  0.62%  blink::ObjectPaintInvalidatorWithContext::InvalidatePaintWithComputedReason
     0.05s 0.097% 23.11%      0.09s  0.17%  blink::PaintLayer::PhysicalBoundingBox
     0.05s 0.097% 23.21%      0.18s  0.35%  blink::PaintLayer::SupportsSubsequenceCaching
     0.05s 0.097% 23.31%      0.68s  1.32%  blink::PaintLayer::TransparencyClipBox
     0.05s 0.097% 23.40%      0.17s  0.33%  blink::PaintPropertyTreeBuilder::UpdatePropertiesForChildren
     0.04s 0.077% 23.48%      0.78s  1.51%  blink::BoxPaintInvalidator::InvalidatePaint
     0.04s 0.077% 23.56%      0.11s  0.21%  blink::LayoutBox::ExcludeScrollbars
     0.04s 0.077% 23.64%      0.09s  0.17%  blink::LayoutBox::OriginAdjustmentForScrollbars
     0.04s 0.077% 23.71%      0.22s  0.43%  blink::LayoutBox::ScrolledContentOffset
     0.04s 0.077% 23.79%      0.09s  0.17%  blink::LayoutGeometryMap::Push
     0.04s 0.077% 23.87%      0.53s  1.03%  blink::PaintLayer::AppendSingleFragmentIgnoringPagination
     0.04s 0.077% 23.95%      0.23s  0.44%  blink::PaintLayer::UpdateDescendantDependentFlags
     0.04s 0.077% 24.02%      1.47s  2.84%  blink::PaintLayerClipper::CalculateClipRects
     0.02s 0.039% 24.06%      0.28s  0.54%  blink::CompositingLayerAssigner::ComputeCompositedLayerUpdate
     0.02s 0.039% 24.10%      0.41s  0.79%  blink::GeometryMapper::SourceToDestinationClipRectInternal
     0.02s 0.039% 24.14%      0.41s  0.79%  blink::LayoutBoxModelObject::OffsetForInFlowPosition
     0.02s 0.039% 24.18%      1.24s  2.40%  blink::LayoutObject::LocalToAncestorPoint
     0.02s 0.039% 24.22%      0.56s  1.08%  blink::PaintLayer::CollectFragments
     0.02s 0.039% 24.26%      0.42s  0.81%  blink::PaintLayer::ConvertToLayerCoords
     0.02s 0.039% 24.29%      0.17s  0.33%  blink::PaintLayer::FragmentsBoundingBox
     0.02s 0.039% 24.33%      3.36s  6.50%  blink::PaintLayerPainter::PaintChildren
     0.02s 0.039% 24.37%      0.70s  1.35%  blink::PaintLayerPainter::PaintFragmentWithPhase
     0.01s 0.019% 24.39%      0.10s  0.19%  WTF::Vector::ReserveCapacity
     0.01s 0.019% 24.41%      0.26s   0.5%  blink::BlockFlowPainter::PaintContents
     0.01s 0.019% 24.43%      0.77s  1.49%  blink::BlockPaintInvalidator::InvalidatePaint
     0.01s 0.019% 24.45%      0.12s  0.23%  blink::CachingWordShapeIterator::ShapeWord
     0.01s 0.019% 24.47%      0.18s  0.35%  blink::CompositingReasonFinder::DirectReasons
     0.01s 0.019% 24.49%      0.78s  1.51%  blink::FrameView::UpdateStyleAndLayoutIfNeededRecursive
     0.01s 0.019% 24.51%      0.18s  0.35%  blink::GeometryMapper::LocalToAncestorVisualRectInternal
     0.01s 0.019% 24.53%      0.23s  0.44%  blink::GeometryMapper::SlowLocalToAncestorVisualRectWithEffects
     0.01s 0.019% 24.55%      0.42s  0.81%  blink::GeometryMapper::SourceToDestinationClipRect
     0.01s 0.019% 24.56%      0.25s  0.48%  blink::GeometryMapper::SourceToDestinationVisualRect
     0.01s 0.019% 24.58%      0.24s  0.46%  blink::GeometryMapper::SourceToDestinationVisualRectInternal
     0.01s 0.019% 24.60%      0.21s  0.41%  blink::InlineFlowBoxPainter::Paint
     0.01s 0.019% 24.62%      0.14s  0.27%  blink::LayoutSVGContainer::Paint
     0.01s 0.019% 24.64%      0.23s  0.44%  blink::LineBoxListPainter::Paint
     0.01s 0.019% 24.66%      0.27s  0.52%  blink::PaintLayer::UpdateAncestorDependentCompositingInputs
     0.01s 0.019% 24.68%      0.49s  0.95%  blink::PaintLayer::UpdateLayerPositionRecursive
     0.01s 0.019% 24.70%      0.22s  0.43%  blink::PaintLayerClipper::StoreClipRectsInCache
     0.01s 0.019% 24.72%      0.15s  0.29%  blink::PaintRecordBuilder::EndRecording
         0     0% 24.72%     15.98s 30.91%  ChromeMain
         0     0% 24.72%      0.13s  0.25%  WTF::Vector::AppendSlowCase
         0     0% 24.72%     15.96s 30.87%  __libc_start_main
         0     0% 24.72%     16.09s 31.12%  base::MessageLoop::DeferOrRunPendingTask
         0     0% 24.72%      1.34s  2.59%  base::MessageLoop::DoDelayedWork
         0     0% 24.72%     14.74s 28.51%  base::MessageLoop::DoWork
         0     0% 24.72%     16.10s 31.14%  base::MessageLoop::RunTask
         0     0% 24.72%     16.06s 31.06%  base::MessagePumpDefault::Run
         0     0% 24.72%     16.05s 31.04%  base::RunLoop::Run
         0     0% 24.72%     16.23s 31.39%  base::debug::TaskAnnotator::RunTask
         0     0% 24.72%     15.40s 29.79%  base::internal::Invoker::RunImpl
         0     0% 24.72%      0.32s  0.62%  blink::BlockPainter::Paint
         0     0% 24.72%      0.33s  0.64%  blink::BlockPainter::PaintObject
         0     0% 24.72%      0.16s  0.31%  blink::BoxPainter::PaintChildren
         0     0% 24.72%      0.12s  0.23%  blink::CachingWordShapeIterator::ShapeToEndIndex
         0     0% 24.72%      0.11s  0.21%  blink::CachingWordShapeIterator::ShapeWordWithoutSpacing
         0     0% 24.72%      3.38s  6.54%  blink::CompositedLayerMapping::DoPaintTask
         0     0% 24.72%      3.38s  6.54%  blink::CompositedLayerMapping::PaintContents
         0     0% 24.72%      4.93s  9.54%  blink::CompositingInputsUpdater::Update
         0     0% 24.72%      0.69s  1.33%  blink::CompositingLayerAssigner::Assign
         0     0% 24.72%      1.06s  2.05%  blink::CompositingRequirementsUpdater::Update
         0     0% 24.72%      0.10s  0.19%  blink::Document::UpdateStyleAndLayoutTree
         0     0% 24.72%      0.83s  1.61%  blink::EventHandler::UpdateCursor
         0     0% 24.72%      0.13s  0.25%  blink::Font::DrawText
         0     0% 24.72%      0.14s  0.27%  blink::FramePainter::Paint
         0     0% 24.72%      0.14s  0.27%  blink::FramePainter::PaintContents
         0     0% 24.72%      0.22s  0.43%  blink::FrameView::ForAllNonThrottledFrameViews
         0     0% 24.72%      0.14s  0.27%  blink::FrameView::Paint
         0     0% 24.72%      3.42s  6.62%  blink::FrameView::PaintGraphicsLayerRecursively
         0     0% 24.72%      3.64s  7.04%  blink::FrameView::PaintTree
         0     0% 24.72%      4.57s  8.84%  blink::FrameView::PrePaint
         0     0% 24.72%      0.62s  1.20%  blink::FrameView::UpdateLayout
         0     0% 24.72%     16.34s 31.61%  blink::FrameView::UpdateLifecyclePhasesInternal
         0     0% 24.72%      0.77s  1.49%  blink::FrameView::UpdateStyleAndLayoutIfNeededRecursiveInternal
         0     0% 24.72%      0.09s  0.17%  blink::GeometryMapper::SourceToDestinationRect
         0     0% 24.72%      0.32s  0.62%  blink::GraphicsContext::DrawImage
         0     0% 24.72%      0.13s  0.25%  blink::GraphicsContext::DrawText
         0     0% 24.72%      0.13s  0.25%  blink::GraphicsContext::DrawTextPasses
         0     0% 24.72%      3.42s  6.62%  blink::GraphicsLayer::Paint
         0     0% 24.72%      3.38s  6.54%  blink::GraphicsLayer::PaintWithoutCommit
         0     0% 24.72%      0.22s  0.43%  blink::GraphicsLayerUpdater::Update
         0     0% 24.72%      0.10s  0.19%  blink::HarfBuzzShaper::Shape
         0     0% 24.72%      0.10s  0.19%  blink::HarfBuzzShaper::ShapeSegment
         0     0% 24.72%      0.33s  0.64%  blink::ImagePainter::Paint
         0     0% 24.72%      0.31s   0.6%  blink::ImagePainter::PaintIntoRect
         0     0% 24.72%      0.33s  0.64%  blink::ImagePainter::PaintReplaced
         0     0% 24.72%      0.22s  0.43%  blink::InlineFlowBox::Paint
         0     0% 24.72%      0.14s  0.27%  blink::InlineTextBox::Paint
         0     0% 24.72%      0.14s  0.27%  blink::InlineTextBoxPainter::Paint
         0     0% 24.72%      0.88s  1.70%  blink::LayoutBlock::InvalidatePaint
         0     0% 24.72%      0.32s  0.62%  blink::LayoutBlock::Paint
         0     0% 24.72%      0.34s  0.66%  blink::LayoutBlock::PaintObject
         0     0% 24.72%      0.12s  0.23%  blink::LayoutBlockFlow::InvalidateDisplayItemClients
         0     0% 24.72%      0.33s  0.64%  blink::LayoutImage::Paint
         0     0% 24.72%      0.33s  0.64%  blink::LayoutImage::PaintReplaced

Ok, no worries, thanks for the data 
Project Member

Comment 5 by sheriffbot@chromium.org, May 29 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Mergedinto: 516437
Status: Duplicate (was: Untriaged)

Sign in to add a comment