Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent iOS crash reporters from crashing MonoTouch apps?
    primarykey
    data
    text
    <p>There are plenty iOS crash reporting libraries in iOS, including <a href="https://testflightapp.com" rel="nofollow noreferrer">TestFlight</a> and <a href="http://hockeyapp.net" rel="nofollow noreferrer">HockeyApp</a>. If you don't want to depend on services, you can still use libraries like <a href="http://code.google.com/p/plcrashreporter/" rel="nofollow noreferrer">PLCrashReporter</a>. Binding these libraries is <a href="http://docs.xamarin.com/ios/Guides/Advanced_Topics/Binding_Objective-C_Libraries" rel="nofollow noreferrer">fairly trivial</a> because their public API usually consists of a couple of classes with several initialization methods.</p> <p>However, when trying to use TestFlight, and later HockeyApp in our application, our app began to randomly crash. Turns out, this <em>is</em> a known issue <a href="https://bugzilla.xamarin.com/show_bug.cgi?id=4120" rel="nofollow noreferrer">reported</a> <a href="http://monotouch.2284126.n4.nabble.com/Re-App-crashes-before-starting-td4657864.html" rel="nofollow noreferrer">several</a> <a href="https://stackoverflow.com/questions/7865374/problems-getting-testflight-to-work-with-monotouch-app/7867056#7867056">times</a>, but Xamarin doesn't warn about it, it is relatively obscure and we found it the hard way.</p> <p>We have learned that <strong>all iOS crash reporters prevent Mono from catching null reference exceptions:</strong></p> <pre><code>try { object o = null; o.GetHashCode (); } catch { // Catch block isn't called with crash reporting enabled. // Instead, the app will crash. } </code></pre> <p>Why does this happen? Quoting Rolf, a Xamarin developer,</p> <blockquote> <p>A null reference exception is actually a SIGSEGV signal at first. Usually the mono runtime handles this and translates it into a nullreference exception, allowing the execution to continue. The problem is that SIGSEGV signals are a very bad thing in ObjC apps (and when it occurs outside of managed code), so any crash reporting solution will report it as a crash (and kill the app) - this happens before MonoTouch gets a chance to handle the SIGSEGV, so there is nothing MonoTouch can do about this.</p> </blockquote> <p>I'm sure many use TestFlight in MonoTouch apps without knowing it causes crashes.<br> <a href="http://fgk.hanau.net/articles/ironic.html" rel="nofollow noreferrer">Isn't it ironic?</a> </p> <p><strong>How do you make crash reporting libraries <em>not</em> crash MonoTouch apps?</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload