2

UIImagePickerController在 Unity 应用程序中使用。当用户按下“完成”时,它偶尔会冻结。它最常发生在 3GS 上——大约每三次——但我也偶尔会在 iPhone 5 上死机。这个错误出现在 iOS 4.3 到 7.0 上。我无法确定与冻结相关的因素。当我得到这个冻结时,我也没有收到内存警告。

日志中没有错误,也没有任何崩溃日志。该应用程序继续UIImagePickerController正常运行。控制台中有很多看起来相关的消息,例如“拒绝文件写入数据/private/var/mobile/Media/PhotoData”,但它们偶尔会在出现冻结和一切正常时出现好吧。

这是我显示选择器的方式:

- (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 中,这样的错误已经被修复了。

4

1 回答 1

1

有一个解决方法:您可以在 UnityAppController.mm 中将 CFRunLoopRunInMode 静音,如下所示:

- (void)repaintDisplayLink
{
    [_displayLink setPaused: YES];
    {
        static const CFStringRef kTrackingRunLoopMode = CFStringRef(UITrackingRunLoopMode);
        if (![EtceteraManager picking])
        {
            while (CFRunLoopRunInMode(kTrackingRunLoopMode, kInputProcessingTime, TRUE) == kCFRunLoopRunHandledSource)
                ;
        }
    }
}
于 2013-10-29T09:30:42.203 回答