Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Custom ScrollView to render PDF using CGPDFDocument crashes app randomly

ilightilight USUniversity ✭✭

critical: Stacktrace:

critical: at <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
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


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.

I am rendering PDF documents using a custom UIScrollView but lately this has been crashing the app randomly - sometimes crashes after PDF is rendered, sometimes after dismissing the UIViewController in which this custom ScrollView is a subview. I am unable to make any specific pattern about the crash. Need help in identifying the crash or any workaround suggestions.


  • ilightilight USUniversity ✭✭

    Ok, I was able to fix the issue as follows

    The DrawLayer method wasn't overridden in the custom UIView. Instead, it was overridden in a custom CALayerDelegate and then the UIView's layer's delegate was being set to that custom CALayerDelegate. After going through this thread, and re-reading this

    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.

    I removed that delegate setting code and I don't see the crash anymore.

Sign In or Register to comment.