ios - CGContextDrawPDFPage 字体渲染代码中偶尔崩溃

标签 ios crash

我有一个 PDF 阅读器应用程序,它在 UIScrollView 中显示多个带有 PDF 层的 UIViewController。

我遇到的是当用户滑动 ScrollView 时偶尔会崩溃。 Fabric 总是指向看起来像字体渲染器的代码部分。奇怪的是,即使用户滑动到之前崩溃的同一个 PDF 页面,这种情况有时也会发生。也没有与 PDF 相关的泄漏或过度释放的对象崩溃。

有什么想法可能导致这种情况吗?谢谢

这是一个崩溃示例:

#3. Crashed: com.apple.root.default-qos
0  libFontParser.dylib            0x2467fef8 TType1Font::GetGlyphsPerCharacters(unsigned short const*, unsigned short*, unsigned int&, bool) const + 211
1  libFontParser.dylib            0x2466e45d TFPFont::GetXHeightAndCapHeightByAverageGlyphHeights(FPFontInfo&) const + 72
2  libFontParser.dylib            0x2466e45d TFPFont::GetXHeightAndCapHeightByAverageGlyphHeights(FPFontInfo&) const + 72
3  libFontParser.dylib            0x2466d4c7 TFPFont::FillFontInfo(TFPFontInfo&) const + 762
4  libFontParser.dylib            0x2466d149 TFPFont::GetFontInfo() const + 108
5  libFontParser.dylib            0x2466d0c9 FPFontIsMonospaced + 8
6  CoreGraphics                   0x2386cf31 get_font_info + 208
7  CoreGraphics                   0x2381bbe9 get_font_info + 36
8  CoreGraphics                   0x2381bc1d CGFontGetUnitsPerEm + 8
9  CoreGraphics                   0x237f0d53 get_glyph_bounding_box + 22
10 CoreGraphics                   0x237f0a57 draw_glyph_bitmaps + 642
11 CoreGraphics                   0x237efeb3 ripc_DrawGlyphs + 1074
12 CoreGraphics                   0x2381b7f7 draw_glyphs + 834
13 CoreGraphics                   0x2377b811 simple_draw + 220
14 CoreGraphics                   0x2377b59f CGPDFTextLayoutDrawGlyphs + 74
15 CoreGraphics                   0x236de265 op_Tj + 48
16 CoreGraphics                   0x238b02f9 pdf_scanner_handle_xname + 72
17 CoreGraphics                   0x238afe6d CGPDFScannerScan + 384
18 CoreGraphics                   0x238b6f83 CGPDFDrawingContextDrawPage + 390
19 CoreGraphics                   0x236d411f pdf_page_draw_in_context + 86
20 CoreGraphics                   0x235e8c37 CGContextDrawPDFPage + 38
21 ------                         0x256635 -[----- drawLayer:inContext:] (------.m:107)
22 QuartzCore                     0x24bfc325 -[CALayer drawInContext:] + 228
23 QuartzCore                     0x24ce7017 tiled_layer_render(_CAImageProvider*, unsigned int, unsigned int, unsigned int, unsigned int, void*) + 1454
24 QuartzCore                     0x24c2ab99 CAImageProviderThread(unsigned int*, bool) + 472
25 libdispatch.dylib              0x2211f6a1 _dispatch_root_queue_drain + 1572
26 libdispatch.dylib              0x2211f07b _dispatch_worker_thread3 + 94
27 libsystem_pthread.dylib        0x222b2e0d _pthread_wqthread + 1024
28 libsystem_pthread.dylib        0x222b29fc start_wqthread + 8

最佳答案

似乎有一个解决办法。如前所述,当用户滑动时,我们的应用程序会同时绘制多个 PDF。

事实证明,将所有实例的 PDF 绘图代码(所有 CGContext.. 调用)从 drawLayer:(CALayer*)layer inContext:(CGContextRef)context 共享串行队列解决了该问题。

关于ios - CGContextDrawPDFPage 字体渲染代码中偶尔崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39328542/

相关文章:

ios - 如何通过手机APP购买实体商品?付款必须使用 CREDITS 而不是现金

iphone - iOS UIImageView 没有动画

android - 是否可以在 iOS 应用程序和 Android 应用程序之间轻松共享数据?

ios - 导航栏中的自定义 View 按钮有不需要的上边距

c++ - 本地定义的Double数组使程序崩溃

crash - VxWorks 互斥信号量被崩溃的 TASK 锁定

android - 当我尝试从EditText捕获时,Android App崩溃

ios - 将 Cancel UIButton 添加到导航 Controller

php - Aptana Studio 3-浏览自定义工作区目录崩溃程序

twitter - Amazon Web Service 微型实例 - 服务器崩溃