UIImagePickerController crashes on rapid scrolling, slower than photos app
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.
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...
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 dataF开发者_StackOverfloworEntryAtIndex:] + 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;
to:
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
精彩评论