【发布时间】:2013-11-11 10:09:05
【问题描述】:
我有一个应用程序已经过 iOS 6 的广泛测试并且运行良好,而在 iOS 7 上它几乎总是崩溃(但不是 100% 次),主要是 Thread 1: EXC_BAD_ACCESS 错误,没有太多可追踪的。我完全不知道它的下落。我相信我的代码中的某些内容与核心 iOS 方法不兼容。
我能确定的最好的方法是,在注释代码的以下部分后,一切运行良好。
UIGraphicsBeginImageContext(coverView.bounds.size);
[coverView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *coverImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[UIImageJPEGRepresentation(coverImage, 0.8f) writeToFile:coverFilePath atomically:YES];
//Create thumbnail of cover image
CGSize size = CGSizeMake(116.0f, 152.0f);
UIGraphicsBeginImageContext(size);
[coverImage drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)];
coverImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[UIImageJPEGRepresentation(coverImage, 0.8f) writeToFile:coverThumbnailFilePath atomically:YES];
谁能建议我接下来应该去哪里调试?请注意,相同的应用程序在 iOS 6 中运行得非常好,而且这个错误是 iOS 7 特有的。
编辑:附上僵尸堆栈跟踪:到目前为止我无法充分利用它,但可能对专家的眼睛有用:)
提前致谢,
尼基尔
【问题讨论】:
-
你打开异常断点了吗?我认为不是因为您在谈论 main 中的崩溃。打开它们(这里和谷歌上有很多指南),然后你会找到更具体的线路。
-
转到
Breakpoint Navigator,点击加号和Add Exception breakpoint,然后选择Exception on Throw。然后构建并运行并在此处粘贴更具体的日志。然后我们将能够为您提供帮助。 -
我把它们打开了,但它们什么也抓不到
-
请告诉我们
coverThumbnailFilePath。当设置断点On Throw时,您应该在应用程序崩溃时选择行。你做错了什么。应用崩溃时请粘贴日志。这个断点很棒EXC_BAD_ACCESS崩溃了。 -
@TomaszSzulc,我打开了
All Exceptions。仍然没有运气。我将很快发布coverThumbnailFilePath,但令人惊讶的是,即使对前两行(即UIGraphicsBeginImageContext(coverView.bounds.size); [coverView.layer renderInContext:UIGraphicsGetCurrentContext()];)的所有内容都进行了评论,崩溃也会发生......我认为UIGraphics或我对它的使用有问题。