[MonoTouch] SDK 5 issue
Sergio Fadda
sergio.fadda at logobject.ch
Tue Oct 18 12:24:14 EDT 2011
Ok, after solving the issue in the topic, I finally isolated the problem I
have in my project.
Should be a synchronization issue with the GC.
Here's the app that replicate the issue:
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace MTFailure
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
}
public class MyUIOperation : NSOperation
{
private NSAction _action;
public MyUIOperation(NSAction action)
{
_action = action;
}
public override void Main ()
{
// Execute these actions in the main thread since it's a UI manipulation
InvokeOnMainThread(_action);
}
}
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
private MonoTouch.UIKit.UIWindow __mt_window;
private UINavigationController _navCtrl;
public override bool FinishedLaunching (UIApplication app, NSDictionary
options)
{
__mt_window = new UIWindow(UIScreen.MainScreen.Bounds);
__mt_window.BackgroundColor = UIColor.White;
_navCtrl = new UINavigationController();
_navCtrl.PushViewController(CreatePage(), true);
__mt_window.AddSubview(_navCtrl.View);
__mt_window.MakeKeyAndVisible ();
return true;
}
protected UIViewController CreatePage()
{
UIViewController result = new UIViewController();
UIView pageView = new UIView(UIScreen.MainScreen.Bounds);
UIButton btn = UIButton.FromType(UIButtonType.RoundedRect);
btn.Frame = new RectangleF(0, 50, 320, 37);
btn.TouchUpInside += HandleBtnTouchUpInside;
btn.SetTitle("Touch me!!!", UIControlState.Normal);
pageView.AddSubview(btn);
result.View = pageView;
return result;
}
private NSOperationQueue _queue = new NSOperationQueue();
private NSOperation _op;
void HandleBtnTouchUpInside (object sender, EventArgs e)
{
// Enqueue the operation and let the os to handle it in another thread
_op = new MyUIOperation(DeferredAction);
_queue.AddOperation(_op);
}
private UIViewController _subCtrl;
private void DeferredAction()
{
_navCtrl.PushViewController(CreatePage (), true);
}
// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
}
}
That is, a simple navigation app with a button in a view; the action of the
button must be deferred and usually is a UI manipulation; running the
application and pressing the button a variable number of times the
application crashes and displays the following message:
Stacktrace:
Native stacktrace:
0 MTFailure 0x000d5c18
mono_handle_native_sigsegv + 408
1 MTFailure 0x00012fcf
mono_sigsegv_signal_handler + 351
2 libsystem_c.dylib 0x9435859b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 libobjc.A.dylib 0x0199dc09 _class_getVariable + 99
5 libobjc.A.dylib 0x0199415f
object_getInstanceVariable + 56
6 MTFailure 0x002cc543
monotouch_release_trampoline + 419
7 Foundation 0x00747d16 __release_object_op + 37
8 libdispatch.dylib 0x0214cc7b
_dispatch_async_f_redirect_invoke + 146
9 libdispatch.dylib 0x0214c4e6 _dispatch_worker_thread2
+ 284
10 libsystem_c.dylib 0x94302b24 _pthread_wqthread + 346
11 libsystem_c.dylib 0x943046fe start_wqthread + 30
=================================================================
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.
=================================================================
This issue is present only with iOS 5 (both device and simulator), but in
iOS 4.3 works fine!
What's wrong now?
Thanks,
Sergio
--
View this message in context: http://monotouch.2284126.n4.nabble.com/SDK-5-issue-tp3912223p3915935.html
Sent from the MonoTouch mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111018/f0001050/attachment.html
More information about the MonoTouch
mailing list