【发布时间】:2014-03-26 02:48:36
【问题描述】:
我一直在处理我的 iPhone 应用程序中的一个有害的崩溃错误,该错误在从 App Store 下载的版本中始终可以重现,但在调试版本中完全没有。我已经提出了一种解决方法,它通过在 UIViewController 动画期间排除关键的绘图代码来工作。
- 崩溃日志表明 CGPathAddLineToPoint 中存在断言失败。
- 应用程序使用绘图函数 CGContextMoveToPoint、CGContextAddLineToPoint 和 CGContextStrokePath。还使用了函数 CGPathCreateMutable、CGPathAddLines 和 CGContextAddPath,但即使在(应该)避免调用它们的配置中,应用仍然会崩溃。
- 当 UIViewController 正在呈现(动画)时,当在视图上绘制线条时,崩溃总是会发生。否则,绘图工作没有问题。
- 我已在调试版本中确认,绘制的每条线的每个点都是真实的,并且在视图的边界内。
- 尝试绘图时,应用程序在 iOS7 上立即崩溃。在 iOS5 和 iOS6 上,应用在崩溃前停止响应 30 秒,留下一个“未知”崩溃日志,没有任何信息。
- 我能在网络上找到与此问题类似的唯一案例是 OS X 应用程序中的 CGPathAddLineToPoint 中的 CGFloatIsValid 断言失败(包括发布到 Apple 支持论坛的 iPhoto 崩溃日志)。
我不能多说,因为该应用从不会崩溃,甚至在调试版本中也不会发出警告。有没有其他人遇到过这个错误?有没有更好的方法来解决这个问题?
您可以在发布版本on the App Store 中查看实际的解决方法。您可以看到,当计算器处于 2D 模式时,当您按下 [Graph] 按钮时,图形上的线条绘制会延迟到动画完成后。
崩溃日志的重要部分(来自运行 iOS 7.0.3 的 iPhone 5S,应用 armv7):
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3a5e11fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x3a648a4f pthread_kill + 55
2 libsystem_c.dylib 0x3a592029 abort + 73
3 libsystem_c.dylib 0x3a571c67 __assert_rtn + 179
4 CoreGraphics 0x2fd566f5 CGPathAddLineToPoint + 149
5 (My App) 0x001464cd 0xd7000 + 455885
6 UIKit 0x324d4dd5 -[UIView(CALayerDelegate) drawLayer:inContext:] + 369
7 QuartzCore 0x3210aa75 -[CALayer drawInContext:] + 97
8 QuartzCore 0x320f4241 CABackingStoreUpdate_ + 1857
9 QuartzCore 0x321ce2e9 ___ZN2CA5Layer8display_Ev_block_invoke + 49
10 QuartzCore 0x320f3af1 x_blame_allocations + 81
11 QuartzCore 0x320f37a3 CA::Layer::display_() + 1115
12 QuartzCore 0x320d7365 CA::Layer::display_if_needed(CA::Transaction*) + 205
13 QuartzCore 0x320d6ffd CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 21
14 QuartzCore 0x320d6a09 CA::Context::commit_transaction(CA::Transaction*) + 225
15 QuartzCore 0x320d681b CA::Transaction::commit() + 311
16 QuartzCore 0x320d0549 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 53
17 CoreFoundation 0x2fc9bf67 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 19
18 CoreFoundation 0x2fc998f3 __CFRunLoopDoObservers + 283
19 CoreFoundation 0x2fc99c3f __CFRunLoopRun + 735
20 CoreFoundation 0x2fc0446d CFRunLoopRunSpecific + 521
21 CoreFoundation 0x2fc0424f CFRunLoopRunInMode + 103
22 GraphicsServices 0x349382e7 GSEventRunModal + 135
23 UIKit 0x324b9841 UIApplicationMain + 1133
24 (My App) 0x000de723 0xd7000 + 30499
25 (My App) 0x000dde0c 0xd7000 + 28172
【问题讨论】:
-
它在断言中崩溃了。断言消息是什么?它应该在程序的标准错误中。
-
崩溃日志中没有断言失败的描述。还有其他一些地方信息会被记录到吗?
-
我在 iOS PhoneGap + jQuery Mobile 应用上升级到 Xcode 5.1.1 后也遇到了类似的问题:stackoverflow.com/questions/23413205/…
-
我们遇到了同样的神秘崩溃,当您添加不包含任何点的路径时,在某些架构下看起来 CGPathAddLineToPoint 会阻塞。如果之前拯救了我们。
标签: ios objective-c crash