UIImagePickerController偶尔冻结 [英] UIImagePickerController occasionally freezing up
问题描述
我在Unity应用程序中使用UIImagePickerController
.用户按下完成"时,它有时会冻结.它最经常在3GS上发生-大约每三次-但我偶尔在iPhone 5上也死机.此错误在iOS上从4.3到7.0出现.我无法确定与冻结有关的因素.冻结时我也没有收到内存警告.
I use UIImagePickerController
in an Unity app. It occasionally freezes when the user presses "done". It happens most often on 3GS — about every third time — but I also had an occasional freeze on iPhone 5. This bug appears on iOS from 4.3 to 7.0. I wasn't able to determine what factors correlate with the freeze. I don't get a memory warning when I get this freeze either.
日志中没有错误,也没有崩溃日志.该应用程序继续像往常一样在UIImagePickerController
之后运行.控制台中似乎有很多相关的消息,例如"deny file-write-data/private/var/mobile/Media/PhotoData",但是当出现冻结或一切正常时,所有这些消息有时都会出现好吧.
There are no errors in the log, no crashlog whatsoever. The app continues to run behind UIImagePickerController
as normal. There are a lot of messages in the console that seem related, like "deny file-write-data /private/var/mobile/Media/PhotoData", but all of them can occasionally appear both when freeze is present and when everything is working alright.
这是我显示选择器的方式:
Here's how I show the picker:
- (void)showPicker:(UIImagePickerControllerSourceType)type
{
imgPicker = [[[CustomPhotoPicker alloc] init] autorelease];
imgPicker.delegate = self;
imgPicker.sourceType = type;
imgPicker.allowsEditing = _pickerAllowsEditing;
// wrap and show the modal
[self showViewControllerModallyInWrapper:imgPicker];
}
这是委托方法:
- (void)imagePickerController:(UIImagePickerController*)imgPicker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
NSLog( @"imagePickerController didFinishPickingMediaWithInfo");
// If the freeze is present, this method isn't called
}
- (void)imagePickerController:(UIImagePickerController *)imgPicker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSLog( @"imagePickerController didFinishPickingImage");
// Tried to use deprecated callback. If the freeze is present, this method isn't called either.
}
我认为这是UIImagePickerController
内部的一个错误,但是没有使用Unity的iOS开发人员都没有遇到过此问题,并且我认为如果在4.3中存在此错误,则该错误已经得到修复.
I would decide that it's a bug inside the UIImagePickerController
, but none of iOS developers that don't use Unity ever encountered this problem, and I would suppose that such a bug would already be fixed if it was present in 4.3.
推荐答案
有一个解决方法:您可以在UnityAppController.mm中将CFRunLoopRunInMode静音,如下所示:
Thre're are a workaround: u can mute CFRunLoopRunInMode in UnityAppController.mm, like this:
- (void)repaintDisplayLink
{
[_displayLink setPaused: YES];
{
static const CFStringRef kTrackingRunLoopMode = CFStringRef(UITrackingRunLoopMode);
if (![EtceteraManager picking])
{
while (CFRunLoopRunInMode(kTrackingRunLoopMode, kInputProcessingTime, TRUE) == kCFRunLoopRunHandledSource)
;
}
}
}
这篇关于UIImagePickerController偶尔冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!