Performance work has a shelf life. A rule that was correct two years ago can become busywork without anyone announcing it, because the tool underneath quietly started doing the job. Android UI is in that position now, and a lot of review comments have not caught up.
Why UI Code Is Expensive in the First Place
Modern Android screens are built from functions the framework re-runs whenever data changes. Google states the cost model in one line: "Composable functions can run very frequently, as often as for every frame of an animation." (Android). Anything careless inside one of those functions is careless many times a second.
The Rule That Expired
For years the fix was manual: annotate data types and wrap callbacks so the compiler could skip work. Since Kotlin 2.0.20 the compiler does this by default. Our own article on the subject told readers to do it by hand until this month. It was out of date, and so is every code review that still asks for it.
Google goes further and warns against the old habit: "Trying to make your entire UI skippable is a premature optimization that could lead to maintenance difficulties in the future" (Android).
Measuring the Wrong Build
The other common waste is measuring a development build and acting on the result. "Debug mode is useful for spotting many problems, but it imposes a performance cost and can make it hard to spot other issues." (Android). A slow screen on an engineer's desk is not evidence of a slow screen in a customer's hand.
What to Ask Your Team
- Which performance rules in our review checklist predate our current compiler? Retire the ones the tool now handles.
- Are our performance numbers taken from release builds? If not, they describe a product nobody ships.
- Do we fix what we measured, or what we suspect? The platform ships a tool that counts the wasted work. Use it first.
- Who owns keeping technical guidance current? Ours was stale for months before a source check caught it.
-Rocky
#MobilePerformance #Android #EngineeringProductivity #EngineeringDreams #StrategiaX
Originally published on ANDROID-ARCHITECT, the Android engineering blog of Strategia-X, with the code and the corrected guidance.
