Prevent leaking surfaces from exiting windows
AM would set the exiting app to be invisible twice by calling setAppVisibility(). If the screen is turned off during these calls, the window surfaces of this exiting app won't be destroyed. The flow: 1. Screen is on 2. App A is finished 3. AM calls setAppVisibility() token=App A, visible=false 4. WM sets a dummy animation to App A 5. WM marks App A's wtoken.inPendingTransaction=true 6. Screen is turned off 7. AM calls setAppVisibility() token=App A, visible=false 8. WM calls setTokenVisibilityLocked() directly (screen is off) 9. WM sends app visibility to App A's client (ViewRootImpl) 10. WM clears the dummy animation from App A 11. App A's client calls WMS.relayoutWindow() to be not visible 12. WM sets App A's window mExiting=true but not destroy its surface 13. App A's window surface leaks... Note: a. The call in 3. is from ActivityStack.finishActivityLocked b. The call in 7. is from ActivityStack.resumeTopActivityInnerLocked c. In 10., App A won't get the real animation while screen is off d. In 12., App A's inPendingTransaction=true; WM takes it's animating e. mExiting won't be cleared because App A has no animation to trigger WindowStateAnimator.finishExit() After applying this patch, WM would destroy the surface in 12. of the above flow. Change-Id: I18b79ba96695ec80d57a85dc15cf92a9e7d3a6ef
Loading
Please register or sign in to comment