Reproduce ANR on android app

can someone knows how to replicate ANR (app not responding) on android app , we are getting lots of issues on our android app, but those are very tricky to replicate, we don’t know what is root cause then we can easily able to see if that is fixed or not

here is an example of ANR stuff , but we saw sometimes on login screen , it gives popup app not responding
2023-03-10 17_07_48-platformpos-live - Unsafe.park - Firebase console

1 Like

I’m facing the same issue, but this is kind of tricky, for me it depends on a lot of factors like Ram, internet connection, specifications of the device, etc, that’s why isn’t easy to reproduce, and most likely is happening in 1/1000.

There are 2 ways that can assist with this, but none are guaranteed to reproduce the issues.

One way is to instrument logging to your application, where on app error or crash, it will send data to the cloud. I am assuming, if it is not able to catch the error/crash before it occurs, sometimes it may be able to get the “crash” data after restart of the application and send it to the cloud on next startup. I do not know the details of such instrumentation and logging, but there are services/frameworks/infrastructure for that such as sentry.io, Firebase, Crashlytics, etc. It might not be free. Or you can always build your own. This might be harder for some scenarios if the app is a web-app compared to a real installed Android app, as web-app case you can only catch web app specific issues and not browser specific issues if browser hangs or crashes.

Another way to help try to reproduce such issues, is in a prior job, we did monkey testing, where the tester just does random actions (or rather to say, press random keys on our product - a telephone base system). In this case the monkey testing for Android app could be doing any/all sorts of tapping swiping on the screen along with pressing buttons if any on the device like the volume/power/home buttons, etc. Also consider random speech triggering for the voice commands to the Android device as well.

3 Likes

For factors related to resource utilization CPU/memory, and internet connectivity, you can try reproducing by also instrumenting/controlling the test conditions, like limiting the internet connection reliability or speed via use of tools configured against the Android device via proxy server connection or via adjusting the actual network the device is connected to (i.e. configure the wifi network to restrict bandwidth to the device tracked by its MAC address). For CPU/memory, look for tools/apps that you can install on device or using the features of Android studio or ADB in developer/debug mode to force high CPU or high memory allocation elsewhere so the device’s system is already low performing, then test your app to see how it behaves under these conditions. I’m not aware of specific tooling/steps details for such process though. This is easier to do on Windows/MacOS than mobile.

On iOS there is or was a network link conditioner feature to help simulate network issues on device during testing, not sure if Android has similar tooling.

2 Likes

Did you try reproduce these using a network bandwidth limiter tool? I’m looking for one at the moment and the one I am using is pretty good, but not sure of it’s provenance even though it does the job well. iOS has a limiter built into the OS, but Android still has no such developer function.

What tool do you currently use? @conrad.connected

I used to use a short walk down the driveway, then I tried using the oven, fridge, and finally, the microwave with door closed (unplugged) was the fastest way to cut signal. But I’m jesting here David.

Only 2 apps on the play store seem to fit the bill ‘Throttly’, for £2.99 by two cities; and ’ NetThrottle ’ by Releasee , which is free. I’ve used the former but not the free one.

To be honest I would prefer/love an open-wrt wifi router OpenWrt/bandwidth_shape.sh at main · RVgo4it/OpenWrt · GitHub all pre-provisioned and with a shaping filter built and a console into it so that you don’t have to fiddle with the phone to make network changes. But the idea of building a controllable hotspot feels like too much work still.