2014-12-19 43 views
5

我与我之前的移植应用到arm64 achitecture这是正在运行就好了一个PDF导出方法挣扎。UIGraphicsBeginPDFPage()随机崩溃在64位器件(CGPDFSecurityManagerCreateDecryptor())

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

当该方法尝试创建一个新的pdf页面到文档(在第一个pdf被整合到新的pdf之后),该应用程序在UIGraphicsBeginPDFPage()上出现EXC_BAD_ACCESS警告;打电话。

它只是一些PDF文件,并不是所有的只有64台设备发生。

下面是其中显示了CGPDFSecurityManagerCreateDecryptor()调用,我找不到它做什么的堆栈跟踪。

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() 

如果你有关于这个崩溃的任何想法,您的帮助将不胜感激,在1天内乱投医解决这一问题,并beggening怀疑,如果它不是一个错误的UIKit ...

感谢

+0

我在同一个函数中看到相同的崩溃,但是使用了不同的堆栈跟踪。尽管我没有写出有问题的软件,但我可以验证它是否正在使用PDF文档并在OS X 10.10上运行,因此它的64位 – HairOfTheDog

回答

1

我不得不在64设备上的CGPDFSecurityManagerCreateDecryptor方法碰撞只用下面的代码:

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

CGPDFSecurityManagerCreateDecryptor WO在结束上下文时会被调用。当我在发布文档和提供者之前结束上下文时,崩溃消失了。

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

我一直在挣扎与此相同的问题太多,虽然比尔的回答给我的线索,我不得不做不同的那么一点点。在我的情况有一些被复制到目标PDF,所以我不能只是简单CGPDFDocumentRelease之前移动UIGraphicsEndContext源PDF文件数量可变的。该代码结构看起来大致是这样的:

UIGraphicsBeginPDFContextToFile(...); 
// ... 
for each attachment pdf { 
    srcPdf = CGPDFDocumentCreateWithURL(...); // open source PDF 
    // ... 
    UIGraphicsBeginPDFPageWithInfo(...); // new page in target PDF, this randomly crashes 
    // ... 
    CGPDFDocumentRelease(srcPdf); // close source PDF 
} 
// ... 
UIGraphicsEndPDFContext(); 

所以不是我试图捕捉引用它使用的所有来源的PDF文件和目标PDF的休息后,释放所有这些完成后,在代码中要晚得多。这是一种丑恶的,因为它移动的责任远,并拥有所有的记忆,直到最后,而不是每一个被渲染后释放...但它确实出现了工作!这很难说明确,因为它是一次随机崩溃,但我从未见过它,而且我一直在仔细研究它,试图让它再次发生。

pdfRefs = [[NSPointerArray alloc] init]; 
UIGraphicsBeginPDFContextToFile(...); 
// ... 
for each attachment pdf { 
    srcPdf = CGPDFDocumentCreateWithURL(...); // open source PDF 
    // ... 
    UIGraphicsBeginPDFPageWithInfo(...); // new page in target PDF, this randomly crashes 
    // ... 
    [pdfRefs addPointer:srcPdf]; // store for later closing 
} 
// ... 
UIGraphicsEndPDFContext(); 
for each srcPdf in pdfRefs { 
    CGPDFDocumentRelease(srcPdf); // close it here 
}