菜鸟教程小白 发表于 2022-12-12 20:50:36

ios - 涉及 CGPathAddLineToPoint 的不可重现的崩溃错误


                                            <p><p>我一直在处理我的 iPhone 应用程序中的一个有害的崩溃错误,该错误在从 App Store 下载的版本中始终可以重现,但在调试版本中完全没有。我已经提出了一种解决方法,它通过在 UIViewController 动画期间排除关键的绘图代码来工作。</p>

<ul>
<li>崩溃日志表明 CGPathAddLineToPoint 中存在断言失败。</li>
<li>应用程序使用绘图函数 CGContextMoveToPoint、CGContextAddLineToPoint 和 CGContextStrokePath。还使用了函数 CGPathCreateMutable、CGPathAddLines 和 CGContextAddPath,但即使在(应该)避免调用它们的配置中,应用仍然会崩溃。</li>
<li>当 UIViewController 正在呈现(动画)时,当在 View 上绘制线条时,崩溃总是会发生。否则,绘图工作没有问题。</li>
<li>我已经在调试版本中确认,绘制的每条线的每个点都是真实的,并且在 View 的边界内。</li>
<li>尝试绘图时,应用程序在 iOS7 上立即崩溃。在 iOS5 和 iOS6 上,应用在崩溃前停止响应 30 秒,留下一个“未知”崩溃日志,没有任何信息。</li>
<li>我能在网络上找到的与此问题类似的唯一案例是 OS X 应用中的 CGPathAddLineToPoint 中的 CGFloatIsValid 断言失败(包括发布到 Apple 支持论坛的 iPhoto 崩溃日志)。</li>
</ul>

<p>我不能说更多,因为该应用从不会崩溃,甚至在调试版本中也不会发出警告。有没有其他人遇到过这个错误?有没有更好的方法来解决这个问题?</p>

<p>您可以在发行版 <a href="http://itunes.apple.com/app/id474209552" rel="noreferrer noopener nofollow">on the App Store</a> 中查看实际的解决方法.您可以看到,当计算器处于 2D 模式时,当您按下 按钮时,图形上的线条绘制会延迟到动画完成后。</p>

<p>崩溃日志的重要部分(来自运行 iOS 7.0.3 的 iPhone 5S,应用 armv7):</p>

<pre><code>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 - + 369
7   QuartzCore                      0x3210aa75 - + 97
8   QuartzCore                      0x320f4241 CABackingStoreUpdate_ + 1857
9   QuartzCore                      0x321ce2e9 ___ZN2CA5Layer8display_Ev_block_invoke + 49
10QuartzCore                      0x320f3af1 x_blame_allocations + 81
11QuartzCore                      0x320f37a3 CA::Layer::display_() + 1115
12QuartzCore                      0x320d7365 CA::Layer::display_if_needed(CA::Transaction*) + 205
13QuartzCore                      0x320d6ffd CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 21
14QuartzCore                      0x320d6a09 CA::Context::commit_transaction(CA::Transaction*) + 225
15QuartzCore                      0x320d681b CA::Transaction::commit() + 311
16QuartzCore                      0x320d0549 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 53
17CoreFoundation                  0x2fc9bf67 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 19
18CoreFoundation                  0x2fc998f3 __CFRunLoopDoObservers + 283
19CoreFoundation                  0x2fc99c3f __CFRunLoopRun + 735
20CoreFoundation                  0x2fc0446d CFRunLoopRunSpecific + 521
21CoreFoundation                  0x2fc0424f CFRunLoopRunInMode + 103
22GraphicsServices                0x349382e7 GSEventRunModal + 135
23UIKit                           0x324b9841 UIApplicationMain + 1133
24(My App)                        0x000de723 0xd7000 + 30499
25(My App)                        0x000dde0c 0xd7000 + 28172
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>几件事:</p>

<p>尝试在您在应用商店中提交版本的机器上打开崩溃日志。该版本应该包含包含符号文件的存档,您需要符号化崩溃日志。</p>

<p>如果你只是在你的 ViewController 被动画到屏幕上时向路径添加行时崩溃,为什么不将代码添加到调用 <code>presentViewController:animated:completion:</code> 的完成 block 中调用启用绘图的方法。设置您的 ViewController ,以便在首次显示时禁用绘图,并通过完成 block 中的方法调用启用。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 涉及 CGPathAddLineToPoint 的不可重现的崩溃错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/22650582/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/22650582/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 涉及 CGPathAddLineToPoint 的不可重现的崩溃错误