If You Think Battery Is the Only Thing Affecting App Performance, Doug Sillars’ Book High Performance Android Apps Will Tell You Why You’re Wrong and How To Fix It
Guest post by Rick Schwartz, Senior Product Manager at Qualcomm – Snapdragon Mobile Development Platforms
Chances are some of your favorite apps have problems with excessive power consumption or inefficient network usage. AVG recently measured the performance of some of the most popular apps over a six-month period and ranked them by battery usage, storage size, and network usage. What they found was surprising. Some of the most popular apps have serious problems.
As an app developer, you want to make sure your app is as good as possible so it never gets called out for these issues. This is easier said than done. While there are several good books on web performance, there is no comprehensive reference that is focused on mobile app performance and power conservation. Doug Sillars is hoping to change this.
I’ve heard Doug speak at a number of Android conferences for software developers, and his talks on performance and AT&T ARO are not to be missed. However, there is only so much you can cover in a one-hour time slot. You would need an entire day to cover everything you need to know. Doug recently finished a book, which is a deep dive into this important topic. The book is called “High Performance Android Apps.” You can find it on Amazon, Google Play, and any other place that carries O’Reilly books.
Once you read the forward by Colt McAnlis, a developer advocate at Google and one of the most popular speakers at Google I/O, you’ll know this book was a good investment of your time and money. McAnlis says, High Performance Android Apps is an “in the trenches’ guide to everything performance on Android.” He goes on to say, “Not only does it cover the basic algorithm topics, but also goes into how the hardware and platform are working so you can understand what the crazy tools are telling you.” It is true; some of the tools needed to address performance issues are not easy to use. Doug does a great job explaining complex topics with easy-to-understand language that anyone can pick up.
Although the book covers a lot of topics, it does go deep into several important areas – including some that are ignored in similar books. I especially liked his tips, which are annotated with a green squirrel icon.
How to Change Performance Testing to Get Reliable Results
So let’s jump right in and discuss a few things you’ll find in the book. Doug starts with the consequences of bad performance, and it’s not pretty. One of the biggest gripes of consumers involves battery drain. Apps that inefficiently use resources cause unnecessary drain and forces consumers to charge their mobile devices just to get through a single day. Excessive power consumption is only part of the problem, according to Doug, “98% of apps tested had room for potential performance improvements.” Doug stresses the importance of real performance testing, not just synthetic tests.
There are things in this book you won’t find in most others. For example, I really enjoyed reading the chapter on device testing. Doug points out the phones that developers use (e.g. rooted Nexus devices) are often very different than the phones typical consumers use. Doug recommends testing with both new and old popular consumer devices. According to Open Signal, there are more Samsung Galaxy SIII phones in use today than any other phone. That’s might surprise some developers because it’s over three years old. Doug has a list of requirements that should be included in a comprehensive device testing lab. For example, when it comes to screen size, you should have one phone with a small screen, one normal sized phone, a phablet, one or more tablets, and a wearable. It’s also important to have devices running all popular Android OS versions. By picking devices wisely, and having each device cover several different attributes, you can get by with a reasonable number of devices. To augment your devices, another good suggestion is the use of Open Device Labs, where you can test for free in some cases.
The chapter on hardware performance and battery life is a topic that’s near and dear to me. Doug recommends tools that will help you isolate power problems and provides solutions to address them. As a Product Manager at Qualcomm, I’m responsible for such tools including our new Snapdragon Profiler app that has a trace capture mode for taking Systrace functionality as described in his book.
Stats, Tips, and Advice to Help Your Apps Be More Responsive
The book is filled with interesting stats, like this one: “Studies have shown that 70% of battery drain when the device is idle is caused by apps turning on a radio connection to update.” Doug suggests using Battery Historian to look into power problems and goes into detail how to use it. I look forward to trying the new ‘screen off discharge rate’ and ‘per-app mobile radio active time’ features, which are available in the new 2.0 update. Doug includes real world examples of problem apps. For example, he found a popular third-party Twitter client used more mobile radio and caused more battery drain during a 4-hour period than a 30-minute teleconference. This is very surprising when you think about how different these two use cases are.
The chapter on screen and UI performance is another good one. It includes step-by-step instructions on how to optimize an app’s user interface, and suggestions on how to test for jank and jitter. If you follow Doug’s advice, your app should feel very responsive. For example, by using view tree optimizations, like removing relative and linear layouts, you can shorten render times by 6ms. Doug does a good job explaining how to use Systrace to flag issues slowing your UI. I enjoyed his numerous tips on how to improve perceived performance. There is also a chapter that looks into memory performance and discusses how apps like LeakCanary can help you find and fix memory leaks. Of course CPU performance testing is also discussed.
Doug is an expert on network performance issues, so it’s no surprise the chapter on that topic is excellent. Doug describes how to build network-aware apps, how to properly manage the cellular radio by grouping and closing your network connections. These two tips can result is substantial battery savings. He also provides suggestions on how to simulate the slower network conditions found in emerging markets. The final chapter is about real user monitoring (RUM). Doug covers several RUM tools that provide detail crash reports, analytics, and usage trends. You can even investigate how your app is performing around the world.
“Performance Android Apps” is a good book that is enjoyable to read. After reading it, you should have a much better understanding of what causes app power and performance problems and more importantly — how to fix them. Chances are your smartphone has a more advanced processor than your desktop, so your apps should fly when they are properly optimized. Well-written apps should also be power efficient, and not consume excess battery power. For years, Doug has been helping some of the biggest companies improve their apps. Now you can have access to the same tips and tricks.