Android Performance Checking and Solving(2 ) : ANR vs Crash

Previously on Frozen Frames story i tell a story about how to find and fixing Rendering Performance Issues (Slow Rendering and ANR).

This time i called Rendering Issues as ANR (Android Not Responding) issues.

Once you fixed ANR be aware of CRASH.

1. ANR Problem

Code above explain that function initBitrate running on Main Thread. And inside initBitrate there is 1 line code that access diskAndroid SharedPreference. Which is this should be running on other Thread.

2. ANR Fixing

Code above explain that i move init bitrate into other Thread. and the ANR issue has solved.

I got a new crash issue. that caused by ANR issue fixing.

3. Log of a crash that caused by ANR fixing

On that log, we found that i access List that at the other Thread that list got update. That causing Illegal State Exception.

So now i try to fix the crash without causing ANR anymore.

4. Crash Fixing.

Short story.. i fix the crash with RX Java. I make sure the accessing and modify List object at the same Thread.

Sometimes if you want to fix ANR issues, fix carefully, Its not just move Thread from UI Thread to other Thread, but be aware of possibility Crash Issues.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store