I want to see how the Crash Reporting API works and have been trying to force a crash from my app. I was under the impression that if I’m using ‘Fast but no exceptions’ then an exception would cause the app to crash and be terminated. This is not the case. I did manage to force a crash by calling a recursive method but the API still reports 0 crash reports.
I have enabled the API in the settings, and I’m using Unity 5.3.6.
Can anyone help?
Anyone used the Crash Reporting API?
Hi andymads,
The “Fast but no exceptions” setting should indeed cause any uncaught exceptions to result in a crash on iOS. Are you sure the exception you’re generating is actually going uncaught? If you generate an exception in code that is called by the UI event system, the event system will catch the exception and log it, and it will not result in a crash. One way around this might be to set a flag when a button is pressed, and then check that flag in the Update() method and throw the exception if the flag is set.
Aside from this, we are currently working on native crash reporting as part of our Game Performance service. We have a custom preview build available that will allow you to capture native iOS crashes from your app and see them in the Game Performance dashboard. Please let me know if you’d be interested in trying that out.
You can try using something like:
using UnityEngine;
public class Crasher : MonoBehaviour
{
void Start()
{
object o = null;
Debug.Log(o.ToString()); // NullReferenceException
string[] a = new string[1];
Debug.Log(a[2]); // IndexOutOfBoundsException
int x = 0;
Debug.Log(42 / x); // DivisionByZeroException
}
}
If this doesn’t work you can also call into native code and simulate a crash there.
I was doing the right thing, the problem was that I was trying to do it in a button handler and the UI system will catch it. It worked as soon as I moved it somewhere else.
Why are exceptions handled differently for UI called code? I think I like the idea of my app hard crashing rather than continuing in an invalid state will probably have repercussions later on.
For this kind of code, i tend to have as minimal “overhead” as possible such as button clicks, etc.
I just make the game crash (or do whatever other action i am testing) as early as possible without anything that might get in the way (who would’ve thought that the UI actions are “protected” from exceptions huh?)