Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 2e37d629 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

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
parent 566e8baf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment