You’re working happily on your app and all is well, then suddenly – POOF! – it crashes. Aaargh!!
Apparently ‘Crashes decrease with new session the very next day by almost 8x’ (Cue sad violin).
It happens to the best of us.
Stability issues can derail the success of even the best apps. Buggy apps can drive your users away, uninstallations aside, they have the potential to wreck your reputation when users leave one too many distasteful reviews.
Something to bear in mind is that it’s not only about crashes. Users face errors that are not necessarily a crash, so tracking user-facing errors such as error messages and API response times is also important. There are several types of crashes an app can experience- either it can be ANR errors or crashes related to API integrations.
Bug fixing doesn’t need to be hard. You’re likely to worsen the situation if you freak out and start changing things at random, hoping the bug will magically go away.
Instead, you need to take a methodical approach and learn how to reason your way through a crash and maintain app stability.
You can’t fix what you can’t find
The first order of business is to find out where exactly in your code the crash occurred: in which file and on which line.
You do have control over some of the errors and can find them. You can let the user know of the problem via building a communication channel when a user loses their WiFi connection while file transfer is in the process.
When errors are from unexpected app behaviour, your mobile app testing kit will need app monitoring and tracking tools to detect the behaviour that leads to app crashes. There are tools that are not only for mobile apps but also for OTT and Unity as well. In addition, no matter what tool you use, it’s normally an SDK that reports you about the crash alerts.
Even if you are able to collect all this data, it’s difficult to figure out which crashes to troubleshoot and fix first. And this issue follows our next approach to a stable app.
Follow Eisenhower’s Urgent/Important Principle
It’s important to prioritize and sift the problems most users are facing first.
As it’s common that teams tend to tackle bugs on a first come first served basis. Especially if the report comes from a loud voice or a key stakeholder.
This principle comes handy in such a situation which is more like a Rule of Thumb. This principle can tell you to quickly identify the activities that have an outcome that leads to us achieving our goals (Important), and activities that demands immediate attention (Urgent) that you should focus on, and the ones you should ignore.
Basically there are a couple of crashes or bugs that might be causing complaints, solve those first and iterate your priorities accordingly – you will see your crash rate and complaints decrease dramatically.
Practice better Exception Handling
An exception happens when something goes wrong. Tried to open a file but it doesn’t exist? You’ve got an exception. Attempted to call a method on an object but the variable was null? Boom! Exception.
And here comes Exception handling which is an error-handling mechanism. When something goes wrong, an exception is thrown. The exception causes your application to crash, if you do nothing.
For example: Developers often find themselves in a situation like- Is there a way to avoid an EXC_BAD_ACCESS from crashing an app, and handle an exception gracefully?
To handle the exception that was thrown, you need to catch it. You can do this by using an exception-handling block i.e. by using ‘try block and catch block’.
Proper Memory Management
One of the biggest causes behind app crashes is the lack of memory because not all users possess powerful smartphones and high-end tablets. Whereas, people write code as though only their apps exist.
Taking the similar example from above: You can also get EXC_BAD_ACCESS (while attempting to access nonexistent memory) because of the usable memory already being assigned to other processes. The unavailability of enough memory will prompt your app to shut down.
How to go on about this?
- Do your best to avoid using too much memory and use caching whenever possible.
- Find where your app holds the biggest data structures or uses the most amount of data and see if everything is absolutely necessary.
- You can profile your app to see if there is any memory leak.
- If there is no way to save memory, then prioritize what data/ features to dispense and keep, to save memory when it is already low.
These kinds of crashes become very rare with just a little defense and care in programming, and using “treat warnings as errors”.
While improving app usability, knowing how to deal with dysfunctional apps can be of great help. If you want assistance in development and testing of mobile applications, you can chat with us here.