Fix leak with transitions when views get removed
Transitions, when started, add an OnPreDrawListener to the current ViewTreeObserver (which is global to the view hierarchy). This listener is removed when the listener is called. It is possible to add this listener and then remove the view from the hierarchy before the listener is called. This could result in either the listener not getting called at all (since there was no drawing event) or (in the case of this bug) the listener getting called when the sceneRoot had no AttachInfo (which is the case when that root has been removed from the hierarchy). This results in the listener trying to remove itself from a *different* ViewTreeObserver than the one it added itself to, leaving the actual listener still sitting on a list of listeners in that original VTO. This can result in a growing list of listeners and a growing amount of work that gets done on every frame. It can also lead to a serious memory leak, since the objects referred to by the transition may be non-trivial (as in the case of this bug). The fix is to add another mechanism for the listener to get removed. Specifically, we now listen for detach events on the sceneRoot. If that view gets detached before the listener is called, then we have a chance to remove it from the correct VTO before the AttachInfo becomes null. Issue #11307391 keyguard is slow after updating to krt16c and playing music Change-Id: I108413ea2f18f5351df0a11d4ae56fec0b4aa154
Loading
Please register or sign in to comment