我遇到了一个奇怪的应用程序崩溃。我将问题缩小到一个特定的可视组件。当我使用此组件多次来回导航到屏幕时,应用程序崩溃了。奇怪的是,相同的组件不会导致另一个屏幕崩溃。问题是,在调试中运行时,应用程序不会抛出任何错误。我唯一看到的是设备记录中的崩溃报告。
我不确定此处应提供此组件的代码。因此,我将用一般的词语描述它的作用。大多数布局都是在我在运行时加载的xib文件中编码的。这个xib文件有多个控件,而UIScrollView是主要的容器之一。在运行时,我在这个滚动视图中添加了更多的UIViews。我还在这些添加的UIViews的主CALayer上执行一些自定义绘图。
如果有人可以帮助我缩小问题的范围,那将是创造。另外,如果在调试期间问题没有引发任何异常,我怎样才能获得更精确的报告?
UPDATE1:
我做了进一步的调查,我认为问题可以缩小到可能不正确的处理。这里描述了非常相似的情况(答案下的第一个评论)。 https://stackoverflow.com/a/5359686/3507404
UPDATE2:
碰巧崩溃与CALayerDelegate有关。我在这里将问题缩小到简单的例子。 CALayerDelegate disposing issue
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3b9731f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x3b9dd792 pthread_kill + 54
2 libsystem_c.dylib 0x3b923fd8 abort + 72
3 MyApp 0x00568df4 mono_handle_native_sigsegv (mini-exceptions.c:2335)
4 MyApp 0x00571dd8 mono_sigsegv_signal_handler (mini.c:6744)
5 libsystem_platform.dylib 0x3b9d7f90 _sigtramp + 40
6 UIKit 0x3302635c -[UIView(Hierarchy) subviews] + 352
7 UIKit 0x331432d4 -[UIView(Hierarchy) _willRemoveSubviewWantingAutolayout:] + 44
8 UIKit 0x332c2056 __UIViewWillBeRemovedFromSuperview + 198
9 UIKit 0x33028af0 -[UIView(Hierarchy) removeFromSuperview] + 56
10 UIKit 0x3302b3b6 -[UIView dealloc] + 374
11 MyApp 0x005fb940 invoke_objc_method_implementation (monotouch-glue.m:1341)
12 MyApp 0x005fb998 monotouch_dealloc_trampoline (monotouch-glue.m:1383)
13 MyApp 0x005fb940 invoke_objc_method_implementation (monotouch-glue.m:1341)
14 MyApp 0x005fb780 monotouch_release_trampoline (monotouch-glue.m:1370)
15 MyApp 0x005fb4bc monotouch_release_managed_ref (monotouch-glue.m:1296)
16 MyApp 0x000f0fa0 (wrapper managed-to-native) MonoTouch.Foundation.NSObject:monotouch_release_managed_ref + 88
17 MyApp 0x000c6228 MonoTouch.Foundation.NSObject:ReleaseManagedRef (.pmcs-compat.NSObject.cs:197)
18 MyApp 0x000c658c MonoTouch.Foundation.NSObject/NSObject_Disposer:Drain (.pmcs-compat.NSObject2.cs:1320)
19 MyApp 0x00234d48 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
20 MyApp 0x00573eb4 mono_jit_runtime_invoke (mini.c:6610)
21 MyApp 0x005b00f2 mono_runtime_invoke (object.c:2827)
22 MyApp 0x005379f6 native_to_managed_trampoline_MonoTouch_Foundation_NSObject_NSObject_Disposer_Drain (registrar.m:135)
23 Foundation 0x311f7c6e __NSThreadPerformPerform + 382
24 CoreFoundation 0x307d9208 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
25 CoreFoundation 0x307d86d6 __CFRunLoopDoSources0 + 202
26 CoreFoundation 0x307d6eca __CFRunLoopRun + 618
27 CoreFoundation 0x30741eba CFRunLoopRunSpecific + 518
28 CoreFoundation 0x30741c9e CFRunLoopRunInMode + 102
29 GraphicsServices 0x3566865e GSEventRunModal + 134
30 UIKit 0x3308e148 UIApplicationMain + 1132
31 MyApp 0x000f6454 (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain + 268
32 MyApp 0x000d2468 MonoTouch.UIKit.UIApplication:Main (.pmcs-compat.UIApplication.cs:75)
33 MyApp 0x00059144 KarmaMobile.iOS.Application:Main (Main.cs:46)
34 MyApp 0x00234d48 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
35 MyApp 0x00573eb4 mono_jit_runtime_invoke (mini.c:6610)
36 MyApp 0x005b00f2 mono_runtime_invoke (object.c:2827)
37 MyApp 0x005b3c78 mono_runtime_exec_main (object.c:4052)
38 MyApp 0x005b3ac8 mono_runtime_run_main (object.c:3678)
39 MyApp 0x0056250c mono_jit_exec (driver.g.c:1009)
40 MyApp 0x005e69a0 main (main.m:489)
41 libdyld.dylib 0x3b8bdab4 start + 0