2013-04-10 67 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