# How we reduced our ANR by three times

DevFeed: [How we reduced our ANR by three times](<https://devfeed.tech/articles/how-we-reduced-our-anr-by-three-times-37402.md>)

Original publisher: [Read original article](<https://medium.com/okcredit/how-we-reduced-our-anr-by-three-times-d9ae0b41ad94?source=rss----40ea5327aac7---4>)

Author: Anjal Saneen

Published: 2022-05-24T05:19:21Z

Content type: article

Language: en

Sources: [OkCredit - Medium](<https://devfeed.tech/sources/okcredit-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [App](<https://devfeed.tech/topics/app.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [app](<https://devfeed.tech/tags/app.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [mobile-app-performance](<https://devfeed.tech/tags/mobile-app-performance.md>), [okcredit](<https://devfeed.tech/tags/okcredit.md>), [performance](<https://devfeed.tech/tags/performance.md>), [timeout](<https://devfeed.tech/tags/timeout.md>), [traces](<https://devfeed.tech/tags/traces.md>), [user-experience](<https://devfeed.tech/tags/user-experience.md>)

## AI overview

This case study explains how OkCredit investigated and addressed Android App Not Responding (ANR) issues in production. It covers ANR categories, timeout behavior, tracking methods, stack-trace analysis, source-code analysis, and examples of resolved ANRs. The authors report a 60% improvement in ANR and a 70% improvement in cold-start performance.

## Source excerpt

App not responding is one of the most frustrating experiences for users. The user is stuck with an app that is hung and must terminate it. It is ridiculously difficult to observe and fix ANR for the android app in production due to their indeterministic nature. After studying stack traces of ANR, we were able to improve ANR by 60%, as well as cold startup performance by 70%. We've also been featured on Google I/O and the Android developer's blog has covered our ANR case study. The goal of this blog post is to discuss our learnings about ANR, challenges around solving ANR, how we track ANRs, an analysis of the source code of ANR generation, and some interesting ANRs that we found and how we resolved them. What is ANR A certain period of time needs to be allowed for the Android system to process events. As soon as the processing times out, an ANR dialogue appears, allowing the user to choose to wait or terminate the application immediately. To discover ANR, Android implements a set of sophisticated mechanisms at the system level. ANR can be classified into various categories. According to the background/foreground of the App, each category has a different timeout. InputDispatching Timeout(5s): A major reason for this is that the button or input event does not respond within a specific period of time. On Android, the timeout is set at 5 seconds by default. Broadcast Timeout (10s): If the broadcast receiver fails to complete its processing within the specified time, the broadcast timeout message is reported (foreground timeout is 10 seconds, background timeout is 60 seconds). Service Timeout (20s): The service does not complete the processing within the specified timeframe (foreground timeout is 20 seconds, background timeout is 200 seconds). User experience is directly affected by ANR since it forces the user to stop using the application through an automated dialogue. However, in the background, this dialogue will not be shown to the user, instead, the app is silently