Remove onPreDrawListeners earlier in TextView
Bug 5556478 Launcher pre-populates its all apps and widget pages with their content, which includes text. The layout calls some onMeasure methods that trigger TextView's registerForPreDraw(), which in turns adds a listener in the ViewTreeObserver. However, some of these pages may never be actually displayed, leaving the listeners in the list since onDraw() is never called. As a result, every frame displayed by launcher is slowned down by this array copy of 6-18 listeners. The problem is not Launcher specific since other applications may use a similar caching mechanism. The solution is to unsubscribe the listener in onPreDraw. The drawback is that several successive calls to registerForPreDraw() will add/remove the some listener object. However, these calls are rare and are relatively cheap since we're just adding the object in and out of an ArrayList which should not need to change its size. Change-Id: Ifb65655a27e302d31a2ad622d18f839aec99689e
Loading
Please register or sign in to comment