2013-04-10 21 views
0

在论坛上过了几个小时,我仍然无法弄清楚。TableHeader视图中的MonoTouch SIGSEGV错误

场景: 我有一个带有可扩展列表的表格视图。当用户想要扩展列表时,点击标题并用新的计数值刷新表格。 表头的看法是:

[MonoTouch.Foundation.Export("tableView:viewForHeaderInSection:")] 
public override UIView GetViewForHeader (UITableView tableView, int section) 
{ 
    float headerHeight= ...; 
    UIView headerView = new UIView (new RectangleF ...); 

    UIButton button1=new UIButton(new RectangleF (...)); 

    //set label for button 
    UILabel labelTextButton = new UILabel(new RectangleF ...); 
    labelTextButton.Text=...; 
    labelTextButton.Lines=2; 

    button1.AddSubview(labelTextButton); 

    button1.TouchUpInside+= (sender, e) =>{ 

     ... 
     tableView.ReloadData(); 
    }; 

    headerView.AddSubview (button1); 

    return headerView; 
} 
  • 在模拟器上运行时它总是给我这样的错误在第一次运行:
 
     Stacktrace: 
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) 
    at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
     at XXX.Mobile.IOS.Application.Main (string[]) [0x00000] in ..../Main.cs:17 
     at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr) 
    Native stacktrace: 
    0 XXXXXXXXX       0x000a4d6c mono_handle_native_sigsegv + 284 
    1 XXXXXXXXX       0x00018668 mono_sigsegv_signal_handler + 248 
    2 libsystem_c.dylib     0x96a028cb _sigtramp + 43 
    3 ???         0xffffffff 0x0 + 4294967295 
    4 UIKit        0x018bf258 -[UIApplication send Action:toTarget:fromSender:forEvent:] + 61 
    5 UIKit        0x01980021 -[UIControl sendAction:to:forEvent:] + 66 
    6 UIKit        0x0198057f -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578 
    7 UIKit        0x0197f6e8 -[UIControl touchesEnded:withEvent:] + 546 
    8 UIKit        0x01b831d3 _UIGestureRecognizerUpdate + 7407 
    9 CoreFoundation      0x03ee2afe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30 
    10 CoreFoundation      0x03ee2a3d __CFRunLoopDoObservers + 381 
    11 CoreFoundation      0x03ec07c2 __CFRunLoopRun + 1106 
    12 CoreFoundation      0x03ebff44 CFRunLoopRunSpecific + 276 
    13 CoreFoundation      0x03ebfe1b CFRunLoopRunInMode + 123 
    14 GraphicsServices     0x04e8a7e3 GSEventRunModal + 88 
    15 GraphicsServices     0x04e8a668 GSEventRun + 104 
    16 UIKit        0x018bbffc UIApplicationMain + 1211 
    17 ???         0x0eeb24ed 0x0 + 250291437 
    18 ???         0x0ec26f40 0x0 + 247623488 
    19 ???         0x0ec26b48 0x0 + 247622472 
    20 ???         0x0ec26c9e 0x0 + 247622814 
    21 XXXXXXXXX       0x0001ca32 mono_jit_runtime_invoke + 722 
    22 XXXXXXXXX       0x00180b0e mono_runtime_invoke + 126 
    23 XXXXXXXXX       0x00184d04 mono_runtime_exec_main + 420 
    24 XXXXXXXXX       0x0018a0f5 mono_runtime_run_main + 725 
    25 XXXXXXXXX       0x0007a0c5 mono_jit_exec + 149 
    26 XXXXXXXXX       0x00218ac4 main + 1988 
    27 XXXXXXXXX       0x000159cd start + 53 
    ================================================================= 
    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. 
    ================================================================= 

退出应用程序到模拟器首页。如果我从模拟器界面(不是来自MonoTouch)再次启动应用程序,它每次都能很好地工作。

  • 当加载应用程序的设备:

它工作正常,在第一次运行,但每隔一段时间(每天3次)的应用程序挂在相同的方式,在模拟器,但一个不同的错误。

 
     2013-04-10 16:03:16.838 XXXXXXXXX[2480:907] -[CALayer BridgeSelector]: unrecognized selector sent to instance 0x2101da0 
     2013-04-10 16:03:24.294 XXXXXXXXX[2480:907] Unhandled managed exception: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[CALayer BridgeSelector]: unrecognized selector sent to instance 0x2101da0 (MonoTouch.Foundation.MonoTouchException) 
      at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 
     at XXX.Mobile.IOS.Application.Main (System.String[] args) [0x00000] in ...../Main.cs:17 
     Stacktrace: 
     Native stacktrace: 
     0 XXXXXXXXX      0x007ff711 mono_handle_native_sigsegv + 244 
     1 XXXXXXXXX      0x0083b8cd sigabrt_signal_handler + 112 
     2 libsystem_c.dylib     0x3a847e93 _sigtramp + 42 
     3 libsystem_c.dylib     0x3a83e123 pthread_kill + 58 
     4 libsystem_c.dylib     0x3a87a973 abort + 94 
     5 XXXXXXXXX      0x0089a230 monotouch_throw_monotouch_exception + 0 
     6 XXXXXXXXX      0x007fd0e9 mono_invoke_unhandled_exception_hook + 92 
     7 XXXXXXXXX      0x007b55e3 mono_thread_abort + 46 
     8 XXXXXXXXX      0x007ff3e7 mono_handle_exception_internal + 2138 
     9 XXXXXXXXX      0x007ff4b5 mono_handle_exception + 12 
     10 XXXXXXXXX      0x0083ab31 mono_arm_throw_exception + 132 
     11 XXXXXXXXX      0x003ba468 throw_exception + 68 
     12 XXXXXXXXX      0x0089a27c monotouch_exception_handler + 0 
     13 XXXXXXXXX      0x0089a32c objc_skip_type + 0 
     14 CoreFoundation      0x3252557f + 614 
     15 libobjc.A.dylib      0x3a3c9a65 + 128 
     16 libc++abi.dylib      0x39e1607b + 78 
     17 libc++abi.dylib      0x39e16114 + 19 
     18 libc++abi.dylib      0x39e17599 cxa_current_exception_type + 0 
     19 libobjc.A.dylib      0x3a3c99d1 objc_exception_rethrow + 12 
     20 CoreFoundation      0x3246bf21 CFRunLoopRunSpecific + 456 
     21 CoreFoundation      0x3246bd49 CFRunLoopRunInMode + 104 
     22 GraphicsServices     0x360202eb GSEventRunModal + 74 
     23 UIKit        0x34381301 UIApplicationMain + 1120 
     24 XXXXXXXXX      0x0013950c wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string_intptr_intptr + 240 
     25 XXXXXXXXX      0x00674f70 XXX_Mobile_IOS_Application_Main_string__ + 152 
     26 XXXXXXXXX      0x00384db0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200 
     27 XXXXXXXXX      0x007b7b7f mono_jit_runtime_invoke + 1054 
     28 XXXXXXXXX      0x008315ab mono_runtime_invoke + 90 
     29 XXXXXXXXX      0x00834457 mono_runtime_exec_main + 306 
     30 XXXXXXXXX      0x008346ab mono_runtime_run_main + 482 
     31 XXXXXXXXX      0x007d35db mono_jit_exec + 94 
     32 XXXXXXXXX      0x00888584 main + 2220 
     33 XXXXXXXXX      0x000143e4 start + 40 
    ================================================================= 
    Got a SIGABRT while executing native code. This usually indicates 
    a fatal error in the mono runtime or one of the native libraries 
    used by your application. 
    ================================================================= 

我不知道它是否是Monotouch上的GC错误,或者我做错了什么。我在某处读过发送给实例的无效选择器已解决。 我试图把按钮事件处理程序中的断点,但它永远不会达到这一点。

来自论坛的其他帖子建议将变量设置为全局(不是一个好的编程习惯),但那也行不通。

我的配置:

 
    Xamarin Studio 
    Version 4.0.3 (build 13) 
    Runtime: 
     Mono 2.10.12 (mono-2-10/c9b270d) 
     GTK 2.24.16 
     GTK# (2.12.0.0) 
     Package version: 210120000 
    Apple Developer Tools 
    Xcode 4.6.1 (2067) 
    Build 4H512 
    Xamarin.Mac 
    Xamarin.Mac: Not Installed 
    Xamarin.iOS 
    Version: 6.2.2.8 (Business Edition) 
    Build date: 2013-02-04 17:10:37-0400 
    Build Information 
    Release ID: 400030013 
    Git revision: fae7c2bde0e8d51943fbd6afa22d7d2bb7a1192f 
    Build date: 2013-03-21 19:16:39+0000 
    Xamarin addins: 906a1edff23bcfd0ab7518463620a8ee506eaea2 
    Operating System 
    Mac OS X 10.8.3 
谢谢您的时间

奥维迪乌

+0

更新:我看到这发生在模拟器只在DEBUGER模式。在发布模式下,模拟器每次都能正常工作。我认为这是Monotouch的问题。对于设备问题依然存在。 – Ovidiu 2013-04-11 10:25:48

回答

0

具有相同问题的人:

我观察到,Xamarin.IOS的较新版本的GC更侵略性。

我尝试了所有与我的代码上面但没有任何工作。

我认为GC并不保留Table委托方法中声明的变量。任何在此处声明的按钮都由GC过早采取。也许这是表格单元出队的错误。

无论如何,我从Project Options中禁用了SGEN建筑选项。据说那里是实验性的。

这解决了我的问题,我不知道这是最好的解决方案,但我没有任何想法。不能调试这些内存/分配问题令人沮丧。

我已经检查了仪器与禁用SGen的内存分配和内存不像以前一样多地取消分配。

我不会将此标记为已解决,因为我的解决方案是解决方法。 SGen不应该这样工作。

最好的问候,

奥维迪乌

0

我只是在打这个问题以及与奥维迪乌救了我调试了几个小时;这对我来说也是一个GC问题。如果其他人遇到这种情况 - 我通过在类中定义UIBUtton而不是函数来避免GC。

+0

但是如果你需要每个表行上的UIBUTTON实例,你怎么能这样做呢? – Ovidiu 2013-04-26 08:55:34