本文介绍了UIGraphicsBeginPDFPage()在64位设备上随机崩溃(CGPDFSecurityManagerCreateDecryptor())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使用pdf导出方法,该方法运行得很好,直到我将应用程序移植到arm64架构。

I'm struggling with a pdf export method that's was running just fine until I ported the app to the arm64 achitecture.

Bacisally,该方法打开现有PDF ,它会创建一个新的pdf文件,并在添加更多内容页面之前将第一个pdf的内容绘制到新创建的文件中。

Bacisally, the method opens an existing PDF, it creates a new pdf file, and draws the content of the first pdf into the newly created one before adding more content pages.

当方法尝试创建新内容页面时pdf页面到文档(在第一个pdf集成到新的pdf之后)应用程序崩溃,并在UIGraphicsBeginPDFPage()上发出EXC_BAD_ACCESS警告;电话。

When the method tries to create a new pdf page to the document (after the first pdf was integrated to the new pdf) the app crashes with a EXC_BAD_ACCESS warning on UIGraphicsBeginPDFPage(); call .

它只发生在一些PDF文件上,而不是全部,只发生在64位设备上。

It only happens with some PDF files, not all and only on 64 bit devices.

这里是显示CGPDFSecurityManagerCreateDecryptor()调用的stacktrace,我无法找到它的作用。

Here's the stacktrace which shows the CGPDFSecurityManagerCreateDecryptor () call which I couldn't find what it does.

Thread 14Queue : NSOperationQueue 0x14f6dd3a0 :: NSOperation 0x17504a470 (serial)
#0     0x00000001838aeee4 in CGPDFSecurityManagerCreateDecryptor ()
#1     0x00000001838d1004 in pdf_filter_chain_create ()
#2     0x0000000183831e00 in CGPDFStreamCreateFilterChain ()
#3     0x000000018383226c in chain_get_bytes ()
#4     0x0000000183b5e0ac in unpackImageRow ()
#5     0x0000000183b5dfd4 in PDFImageEmitData ()
#6     0x0000000183b5f684 in emit_image ()
#7     0x0000000183b5ef9c in PDFImageEmitDefinition ()
#8     0x0000000183464584 in __CFSetApplyFunction_block_invoke ()
#9     0x00000001834643bc in CFBasicHashApply ()
#10     0x00000001834642e4 in CFSetApplyFunction ()
#11     0x0000000183b5fa9c in PDFImageSetEmitDefinitions ()
#12     0x0000000183b590c0 in emit_page_resources(PDFDocument*) ()
#13     0x0000000183b5904c in PDFDocumentEndPage ()
#14     0x0000000183b57cf0 in pdf_EndPage ()
#15     0x0000000187fda904 in UIGraphicsBeginPDFPageWithInfo ()
#16     0x00000001002093e8 in -[ExportTools renderPdfContentToContext:forPlanVersion:]
#17     0x00000001001fba60 in -[ExportTools generatePdfReportWithOptions:]
#18     0x00000001000f7eb4 in -[DetailViewController generatePdfAndShowModalOpenWithAppWithOptions:]
#19     0x00000001835883c0 in __invoking___ ()
#20     0x0000000183486138 in -[NSInvocation invoke] ()
#21     0x000000018443ba20 in -[NSInvocationOperation main] ()
#22     0x000000018437c61c in -[__NSOperationInternal _start:] ()
#23     0x000000018443e26c in __NSOQSchedule_f ()
#24     0x000000010105cdf0 in _dispatch_client_callout ()
#25     0x0000000101067854 in _dispatch_queue_drain ()
#26     0x0000000101060120 in _dispatch_queue_invoke ()
#27     0x000000010106975c in _dispatch_root_queue_drain ()
#28     0x000000010106af18 in _dispatch_worker_thread3 ()
#29     0x00000001945012e4 in _pthread_wqthread ()

如果您对此次崩溃有任何疑问,我们将非常感谢您的帮助,有一天会尝试一切来解决这个问题并且想知道它是不是UIKit错误......

If you have any idea about this crash, your help would be greatly appreciated, been one day trying everything to fix this and beggening to wonder if it's not a UIKit bug...

谢谢

推荐答案

我在64台设备上的CGPDFSecurityManagerCreateDecryptor方法崩溃时只使用以下代码:

I had a crash on the CGPDFSecurityManagerCreateDecryptor method on 64-devices only with the following code:

CGPDFDocumentRelease(pdf);
CGDataProviderRelease(provider);
UIGraphicsEndPDFContext();

结束上下文时会调用CGPDFSecurityManagerCreateDecryptor。当我在释放文档和提供者之前结束上下文时,崩溃就消失了。

CGPDFSecurityManagerCreateDecryptor would get called when ending the context. The crash went away when I ended the context BEFORE releasing the document and provider.

UIGraphicsEndPDFContext();
CGPDFDocumentRelease(pdf);
CGDataProviderRelease(provider);

这篇关于UIGraphicsBeginPDFPage()在64位设备上随机崩溃(CGPDFSecurityManagerCreateDecryptor())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 00:36