UIImagePickerController快速滚动崩溃,比照片应用程序慢 [英] UIImagePickerController crashes on rapid scrolling, slower than photos app

查看:263
本文介绍了UIImagePickerController快速滚动崩溃,比照片应用程序慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数时候,我的图片选择器工作完美(iOS 4.2.1)。但是,如果我通过我的相机卷大约300张照片,非常快速地上下滚动约4-6次,我得到了一个崩溃。这不会发生在相同的iPhone 3Gs上的照片应用程序。此外,我注意到股票照片应用程序比我的图片选择器滚动得更加流畅。

Most of the time, my image picker works perfectly (iOS 4.2.1). However, if I scroll very rapidly up and down about 4-6 times through my camera roll of about 300 photos, I get a crash. This never happens with the "photos" app on the same iPhone 3Gs. Also, I'm noticing that the stock "photos" app scrolls much more smoothly than my image picker.

有没有人注意到这种行为?我会感兴趣的,如果其他人可以尝试这在自己的应用程序,看看他们是否崩溃。我不认为它与其他对象徘徊在我的iPhone上的内存相关,因为它是一个简单的应用程序,这发生在我刚开始应用程序。它也似乎与发送到其他发布对象的消息或viewdidunload中其他对象的过度释放相关,这基于我的崩溃日志以及模拟器对模拟内存警告做出良好响应的事实。我认为这可能是一个错误在UIImagePickerController的内部实现...

Has anyone else noticed this behavior? I'd be interested if others could attempt this in their own apps and see if they crash. I don't think it's related to other objects hogging memory on my iPhone because it's a simple app, and this happens right after I start the app. It also doesn't seem to be related to messages sent to other released objects or overreleasing of other objects in viewdidunload, based on my crash logs and the fact that the simulator responds well to simulated memory warnings. I think it might be a bug in the internal implementation of the UIImagePickerController...

这是我如何启动选择器。我做了这个多种方式(包括设置一个保留属性的UIImagePickerController在我的标题和释放dealloc)。这似乎是最好的方式(最少崩溃):

This is how I start the picker. I've done this multiple ways (including setting a retain property for the UIImagePickerController in my header and releasing on dealloc). This seems to be the best way (crashes least):

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.allowsEditing = YES;         
[self presentModalViewController:picker animated:YES];
[picker release];

这是崩溃的线程(我得到了各种异常类型):

This is the crashed thread (I get various exception types):

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0xfffffffff4faafa4
Crashed Thread:  8
...
Thread 8 Crashed:
0   CoreFoundation      0x000494ea -[__NSArrayM replaceObjectAtIndex:withObject:] + 98
1   PhotoLibrary        0x00008e0f -[PLImageTable _segmentAtIndex:] + 527
2   PhotoLibrary        0x00008a21 -[PLImageTable _mappedImageDataAtIndex:] + 221
3   PhotoLibrary        0x0000893f -[PLImageTable dataForEntryAtIndex:] + 15
4   PhotoLibrary        0x000087e7 PLThumbnailManagerImageDataAtIndex + 35
5   PhotoLibrary        0x00008413 -[PLThumbnailManager _dataForPhoto:format:width:height:bytesPerRow:dataWidth:dataHeight:imageDataOffset:imageDataFormat:preheat:] + 299
6   PhotoLibrary        0x000b6c13 __-[PLThumbnailManager preheatImageDataForImages:withFormat:]_block_invoke_1 + 159
7   libSystem.B.dylib   0x000d6680 _dispatch_call_block_and_release + 20
8   libSystem.B.dylib   0x000d6ba0 _dispatch_worker_thread2 + 128
9   libSystem.B.dylib   0x0007b251 _pthread_wqthread + 265


推荐答案

我想出了一个修复,大大提高了图像选择器的滚动性能,完全消除崩溃。不幸的是,我不知道它为什么工作。

I figured out a fix that vastly improves the scrolling performance of the image picker and completely eliminates crashes. Unfortunately, I don't know why it works.

在上面的代码中,更改:

In the above code, change:

picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

到:

picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

这篇关于UIImagePickerController快速滚动崩溃,比照片应用程序慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆