I'm working on my first real app using Xamarin.IOS. Most of the times the app works great, but a few times a day it crashes with the following stacktrace:
mono-rt: Stacktrace:
mono-rt: at <unknown> <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.Foundation.NSObject.monotouch_release_managed_ref (intptr) <IL 0x00023, 0xffffffff>
mono-rt: at MonoTouch.Foundation.NSObject.ReleaseManagedRef () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:98
mono-rt: at MonoTouch.Foundation.NSObject/NSObject_Disposer.Drain (MonoTouch.Foundation.NSObject) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSObject2.cs:545
mono-rt: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
mono-rt: at <unknown> <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
mono-rt: at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
mono-rt: at Diet52App.Application.Main (string[]) [0x00008] in /Users/danielnordmark/Projects/Diet52App/Diet52App/Main.cs:16
mono-rt: at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
mono-rt:
Native stacktrace:
mono-rt:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
My guess is that some object gets garbage collected before I'm trying to use it. But I feel a bit lost how to find out when and where in my code this happends.
How can I found out where the problem is? Any help is much appreciated!
The problem seemed to be related to my UITableViewController, I had a base class and two different instances. A conflict between these two resulted in a SIGSEGV error.
I managed to track the problem thanks to this answer https://stackoverflow.com/a/6769885/248905
The only modification I had to make was to wrap the code with InvokeOnMainThread like this,
Update: I updated my solution after I had contact with Rolf at Xamarin, the correct fix is to put the code in ViewDidDissapear instead of Dispose.
public override void ViewDidDisappear (bool animated)
{
searchController.SearchResultsSource = null;
searchController.Delegate = null;
base.ViewDidDisappear (animated);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With