New issue
Advanced search Search tips

Issue 916512 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 14
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Memory buildup in LayoutTreeImpl element_id_to_transform_animations_ on YouTube TV test

Project Member Reported by as...@vewd.com, Dec 19

Issue description

Chrome Version: 73.0.3646.0
OS: 16.04.1-Ubuntu (also reproduced on ARM)

What steps will reproduce the problem?
(1) Add log of element_id_to_transform_animations_.size() in `LayerTreeImpl::SetTransformMutated`
(2) Build content_shell (I did a non-debug dcheck build)
(3) Run: ./content_shell --url "https://www.youtube.com/tv?automationRoutine=airstreamBrowseWatchRoutine&env_forceFullAnimation=1"
(4) Observe log output

What is the expected result?
element_id_to_transform_animations_ is occasionally reset

What happens instead?
element_id_to_transform_animations_ keeps growing.

On x86, in our (Vewd) browser, the buildup in memory is some MBs per hour running the test case. On some of our ARM devices the buildup is bigger.

Additional info:

In our product, the buildup is in the "active" layout tree. In content shell it seems to be 2 trees that buildup - I'm not sure what the difference is but I assume at least one of them is the active tree. (We are running our product on Chromium 72) 

AFAICT the reason for the buildup stems from code introduced in this change (combined with yttv updates?) to do a lazy removal of objects in the affected map: https://chromium-review.googlesource.com/c/chromium/src/+/627026/, combined with the fact that `UpdatePropertyTreeAnimationFromMainThread` is never called on the active_tree (Probably by design? It's called via LayerTreeHost::FinishCommitOnImplThread and if I understand correctly commits are done on pending_tree usually?) 

Reverting https://chromium-review.googlesource.com/c/chromium/src/+/627026/ will fix the buildup, but it seems like a better way may be to leave the lazy removal but to add it in an additional path that will be taken in the active_tree?

I have no idea what path would be suitable for that. Can you recommend something? 

BR,
Åsa@Vewd
  
 
Cc: flackr@chromium.org smcgruer@chromium.org
Components: Internals>Compositing>Animation
Labels: -Pri-3 Hotlist-Polish Pri-2
Owner: smcgruer@chromium.org
Status: Assigned (was: Untriaged)
Thanks for the great bug-report!

Confirmed that over a ~30s viewing of this demo, the map on the active tree does seem to be growing out of control. We see the pending one being cleared periodically but not the active one.

[1:8:1219/094135.086538:INFO:layer_tree_impl.cc(681)] 1: element_id_to_transform_animations_.size(): 98
[1:8:1219/094135.086620:INFO:layer_tree_impl.cc(681)] 0: element_id_to_transform_animations_.size(): 12
[1:8:1219/094135.094711:INFO:layer_tree_impl.cc(681)] 1: element_id_to_transform_animations_.size(): 98
[1:8:1219/094135.094824:INFO:layer_tree_impl.cc(681)] 0: element_id_to_transform_animations_.size(): 1

I will investigate, but not sure if I will be able to get to this before the winter holidays.
Coming back to looking at this. The immediate observation is that it's not clear why we bother filling element_id_to_transform_animations_ on the active tree (assuming we have a pending tree), since it is only used in LayerTreeImpl::UpdatePropertyTreeAnimationFromMainThread which is only called on the sync_tree == pending_tree.

I wonder if the correct solution might be to not populate the map in the active tree if !CommitToActiveTree. Alternatively we could sync the maps during LayerTreeHostImpl::ActivateSyncTree.

Note that this leakage likely occurs to:

  * element_id_to_opacity_animations_
  * element_id_to_transform_animations_
  * element_id_to_filter_animations_

It may or may not occur to element_id_to_scrollable_layer_. I just found LayerTreeImpl::RemoveFromElementLayerList which seems to clear that map. I am now looking at whether RemoveFromElementLayerList should be used for the animations maps too.
I tested a patch which uses RemoveFromElementLayerList and it does stop the memory leak, but given that the original patch was aiming to reduce references to LayerImpl::element_id_ and that would just add three back on, I don't think it is the correct approach.

Next I'm going to try syncing the maps during activation (because within a tree you understandably don't know if it the pending or active tree, so we can't really track whether we need element_id_to_transform_animations_).
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 14

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d362daef89cdaaf03ff8e474119122bf121d2689

commit d362daef89cdaaf03ff8e474119122bf121d2689
Author: Stephen McGruer <smcgruer@chromium.org>
Date: Mon Jan 14 20:30:33 2019

Don't track element_id_to_*_animations_ maps on non-sync trees

For the active tree, the element_id_to_*_animations_ maps were not being
cleared, ever. The only code that cleared them was
LayerTreeImpl::UpdatePropertyTreeAnimationFromMainThread which was only
called for the sync tree (which is usually the pending tree). However,
they also aren't used on the active tree.

To fix this, only track them on the sync tree.

Bug:  916512 
Change-Id: Ib9cae536ff38fb84700934c9aed9216311932c9c
Reviewed-on: https://chromium-review.googlesource.com/c/1403334
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622582}
[modify] https://crrev.com/d362daef89cdaaf03ff8e474119122bf121d2689/cc/trees/layer_tree_impl.cc
[modify] https://crrev.com/d362daef89cdaaf03ff8e474119122bf121d2689/cc/trees/layer_tree_impl.h
[modify] https://crrev.com/d362daef89cdaaf03ff8e474119122bf121d2689/cc/trees/layer_tree_impl_unittest.cc

Status: Fixed (was: Assigned)
This should be fixed by the above CL. Since the original regression landed in M62, not planning to merge this back - it should make it into the next Chrome release (M73). The fix should be available in the next M73 canary release.

Sign in to add a comment