使用 CGPDFDocument 呈现 PDF 的自定义 ScrollView 随机崩溃应用程序
Custom ScrollView to render PDF using CGPDFDocument crashes app randomly
我正在使用自定义 UIScrollView 呈现 PDF 文档,但最近这使应用程序随机崩溃 - 有时在呈现 PDF 后崩溃,有时在关闭 UIViewController 后崩溃,其中此自定义 ScrollView 是一个子视图。我无法确定崩溃的任何具体模式。在识别崩溃或任何解决方法建议方面需要帮助。
critical: Stacktrace:
critical: at <unknown> <0xffffffff>
critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (intptr,intptr,intptr) <0x00012>
critical: at CoreAnimation.CALayerDelegate.Dispose (bool) [0x00015] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/CoreAnimation/CALayerDelegate.cs:47
critical: at Foundation.NSObject.Finalize () [0x00000] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/Foundation/NSObject2.cs:129
critical: at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) [0x0001f] in <75fdc35757ef4b00a24457129d1dc3e2>:0
critical:
Native stacktrace:
critical: 0 myappname 0x00533b6f mono_handle_native_crash + 239
critical: 1 myappname 0x0053ff25 mono_sigsegv_signal_handler + 293
critical: 2 libsystem_platform.dylib 0x0d4e2e5b _sigtramp + 43
critical: 3 ??? 0xffffffff 0x0 + 4294967295
critical: 4 myappname 0x006fccfb xamarin_dyn_objc_msgSend + 43
critical: 5 ??? 0x23b0cdd8 0x0 + 598789592
critical: 6 ??? 0x28ba4e5c 0x0 + 683298396
critical: 7 ??? 0x22a23b08 0x0 + 581057288
critical: 8 ??? 0x22a23091 0x0 + 581054609
critical: 9 myappname 0x005afbec mono_gc_run_finalize + 812
critical: 10 myappname 0x006203f3 sgen_client_run_finalize + 19
critical: 11 myappname 0x006889e9 sgen_gc_invoke_finalizers + 249
critical: 12 myappname 0x005b179a finalizer_thread + 762
critical: 13 myappname 0x0064e4f5 start_wrapper + 661
critical: 14 libsystem_pthread.dylib 0x0d4f3047 _pthread_body + 184
critical: 15 libsystem_pthread.dylib 0x0d4f2f8f _pthread_body + 0
critical: 16 libsystem_pthread.dylib 0x0d4f284a thread_start + 34
critical:
=================================================================
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.
=================================================================
好的,我能够按如下方式解决问题
未在自定义 UIView 中重写 DrawLayer 方法。相反,它在自定义 CALayerDelegate 中被覆盖,然后 UIView 层的委托被设置为该自定义 CALayerDelegate。在多次重新阅读以下段落并检查任何此类委托设置代码的代码后,我能够解决我的问题。
In addition, the view always assigns itself as the delegate of its
layer object. At this point, the view owns its layer and the
relationship between the view and layer must not change. You must also
not assign the same view as the delegate of any other layer object.
Changing the ownership or delegate relationships of the view will
cause drawing problems and potential crashes in your application.
我删除了那个委托设置代码,我再也看不到崩溃了。
我正在使用自定义 UIScrollView 呈现 PDF 文档,但最近这使应用程序随机崩溃 - 有时在呈现 PDF 后崩溃,有时在关闭 UIViewController 后崩溃,其中此自定义 ScrollView 是一个子视图。我无法确定崩溃的任何具体模式。在识别崩溃或任何解决方法建议方面需要帮助。
critical: Stacktrace:
critical: at <unknown> <0xffffffff>
critical: at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (intptr,intptr,intptr) <0x00012>
critical: at CoreAnimation.CALayerDelegate.Dispose (bool) [0x00015] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/CoreAnimation/CALayerDelegate.cs:47
critical: at Foundation.NSObject.Finalize () [0x00000] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/Foundation/NSObject2.cs:129
critical: at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) [0x0001f] in <75fdc35757ef4b00a24457129d1dc3e2>:0
critical:
Native stacktrace:
critical: 0 myappname 0x00533b6f mono_handle_native_crash + 239
critical: 1 myappname 0x0053ff25 mono_sigsegv_signal_handler + 293
critical: 2 libsystem_platform.dylib 0x0d4e2e5b _sigtramp + 43
critical: 3 ??? 0xffffffff 0x0 + 4294967295
critical: 4 myappname 0x006fccfb xamarin_dyn_objc_msgSend + 43
critical: 5 ??? 0x23b0cdd8 0x0 + 598789592
critical: 6 ??? 0x28ba4e5c 0x0 + 683298396
critical: 7 ??? 0x22a23b08 0x0 + 581057288
critical: 8 ??? 0x22a23091 0x0 + 581054609
critical: 9 myappname 0x005afbec mono_gc_run_finalize + 812
critical: 10 myappname 0x006203f3 sgen_client_run_finalize + 19
critical: 11 myappname 0x006889e9 sgen_gc_invoke_finalizers + 249
critical: 12 myappname 0x005b179a finalizer_thread + 762
critical: 13 myappname 0x0064e4f5 start_wrapper + 661
critical: 14 libsystem_pthread.dylib 0x0d4f3047 _pthread_body + 184
critical: 15 libsystem_pthread.dylib 0x0d4f2f8f _pthread_body + 0
critical: 16 libsystem_pthread.dylib 0x0d4f284a thread_start + 34
critical:
=================================================================
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.
=================================================================
好的,我能够按如下方式解决问题
未在自定义 UIView 中重写 DrawLayer 方法。相反,它在自定义 CALayerDelegate 中被覆盖,然后 UIView 层的委托被设置为该自定义 CALayerDelegate。在多次重新阅读以下段落并检查任何此类委托设置代码的代码后,我能够解决我的问题。
In addition, the view always assigns itself as the delegate of its layer object. At this point, the view owns its layer and the relationship between the view and layer must not change. You must also not assign the same view as the delegate of any other layer object. Changing the ownership or delegate relationships of the view will cause drawing problems and potential crashes in your application.
我删除了那个委托设置代码,我再也看不到崩溃了。