7 Keys To Boost Apps Responsiveness

on Wednesday, 22 February 2012. Posted in Android, Mobile Technology

Responsiveness Increase Happiness

7 Keys To Boost Apps Responsiveness

One of the most important aspects that app developers need to give much attention to, if they want to deliver a high quality user experience, is the "application responsiveness".  Studies have shown that responsive application will have positive impact to user experience.

Android puts high importance in application responsiveness by having some guards in the system against unresponsive applications, and display the dreaded ANR ("Application Not Responding") dialog when the app does not respond to an input event for 5 seconds, for example. This will hopefully enforce developers to think harder to design their app for responsiveness.

In this article, we'll share with you what are the approaches you can take to improve the responsiveness of your Android apps.  We'll not delve into the details of the techniques and tools you can use, but we'll just give you the big picture and directions of what are the things you need to give attention to when you are designing your app to achieve better responsiveness.

 

So, what can you do to improve your app responsiveness. The answer largely will depend on what are causing your app to become sluggish and does not respond to user inputs as snappy as it should. There are dozens of possible causes, among the common ones are: running long processes in the UI thread, ineffective use of resources such as memory allocations/GC and disk I/O activities, inefficient UI layouts/views/resources, bugs, complex algorithms, etc.

In general, here are some of the things you need to give special attentions to, if you want to improve your apps responsiveness:

  1. Optimize for performance. Application that is optimized for performance, performs its tasks more efficiently and faster, thereby reducing the time it takes for the app to respond back to user inputs, and deliver the results. Read the Designing for Performance article in the Android Developer website for some suggestions on how to optimize your app for performance. And don't miss the Google I/O 2010 talk by Brad Fitzpatrick on Writing zippy Android apps for more tips and practical techniques. However, performance is not equal to responsiveness. It's not unusual for apps that have best performance to become unresponsive in certain conditions.
  2. Concurrency. Perform non-UI processes, especially the long-running and high-latency ones, in separate thread than the UI thread, so that the UI thread will not be blocked and is free to do UI-related tasks further. With free/unblocked UI-thread, you can give immediate (visual) response and allow the user to still interact with your app, while it's doing some works in the background. Lars Vogel has written a nice tutorial on using the Android Threads, Handlers, and AsyncTasks, the trio that you will deal with alot when you need to do some background processing.
  3. Memory management. If you use the memory effectively, it can help to improve the overall responsiveness of your app. For example, by caching some of the reusable objects in memory, you can save the time needed to create the objects everytime you use them. This can be especially helpful, for example if you use the objects during animation, since it can potentially reduce the time to render each frame/view of the animation, making the animation smooth, flowing and responsive. However you need to be careful, because if you cache too many objects and fill up too much memory, the GC can kick in anytime to reclaim some memory, and will "disturb" your animation, making it a bit "choppy". In any case, avoid allocating memory if you don't need to.
  4. Efficient UI resources. Related to the previous point about memory management, using inefficient UI resources, such as complex layouts, large drawables, etc, can put heavy burden on the memory usage, which can cause frequent GC which block the UI thread and slowing down your app's response. There are a lot of techniques you can use to improve the efficiency of your UI resources. For example, Romain Guy has written a nice little tips on how to speed up your UI.
  5. Work-ahead. If your app provides different options or different path of executions that the users can choose, and you can anticipate how the user will normally interact with your app, then you can precompute or work-ahead some common solutions beforehand, so that your app is able to response and produce results in the shortest amount of time as possible.
  6. Acknowledge early, do afterward. In general, in term of responsiveness, it's better to acknowledge/respond to user inputs/interaction immediately, and then do whatever works need to be done afterward. This is especially important when you need to do long-running high-latency works. The most common techniques are by using animation or progress indicator to give indication that your app has received the user's command and about to do some long running tasks to get the result. For example, when the user initiate a resource download from the internet by clicking on a button, it's better to immediately show a progress bar or notification before you do any setup for the actual download. You can acknowledge user inputs with tactile, audio, or visual responds. You can also make use of the StateListDrawable for simple visual "acknowledgements" to indicate different states of user interactions.
  7. Visual tricks. Some researches have shown that certain visual trick can improve user's perception of application responsiveness/performance by creating an illusion of speed. This technique has been used by some operating systems, for example the Mac OS X. The DroidUX Progress widgets are designed to make it easy to employ such tricks with features to add animated pattern and easily changing the progress colors.

The points listed above do not in any case cover all the things you can or need to do to improve your app's responsiveness. There are perhaps many other techniques you can implement to increase your app's responsiveness, either by reducing the actual response time for your app to provide results to the user, or by increasing the perceived responsiveness by keeping the user informed or even "entertained" (by using animation, progress indicator, or visual tricks) while waiting for the result.

But at least, if you implement the techniques mentioned in this article, your app's responsiveness will improve considerably.

Happy coding! ≧❂◡❂≦

 
blog comments powered by Disqus