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

ade sueb
2 min readAug 3, 2020

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.

ANR Problem

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.

Fixing the ANR Issue

2. ANR Fixing

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

New Problem

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.

Fixing The Crash

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.

Conclusion

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.

at java.lang.Thread.run (Thread.java:764)

--

--

ade sueb

Still believe, can change the world with code..