UIActionSheet плохой доступ, UIPresentationController зомби

При тестировании приложения в iOS 8 ActionSheet продолжает вылетать из-за плохого доступа. (Xcode 6 beta 2, симулятор iOS 8)

Здесь есть связанное сообщение: Сбой UIActionSheet в iOS8beta

Инструменты действительно ловят зомби, связанного с UIPresentationController. Не уверен, что читаю правильно, но кажется, что счетчик удержаний упал с 6 до -1.

Вот полный журнал:

Event Type  ∆ RefCt RefCt   Timestamp   Responsible Library Responsible Caller
0   Malloc  +1  1   00:14.487.023   UIKit   UINibDecoderDecodeObjectForValue
1   Retain  +1  2   00:14.493.979   UIKit   -[UIRuntimeConnection initWithCoder:]
2   Retain  +1  3   00:14.494.009   UIKit   -[UIRuntimeConnection initWithCoder:]
3   Retain  +1  4   00:14.494.069   UIKit   UINibDecoderDecodeObjectForValue
4   Retain  +1  5   00:14.494.089   UIKit   UINibDecoderDecodeObjectForValue
5   Retain  +1  6   00:14.494.190   Foundation  _NSSetUsingKeyValueSetter
6   Retain  +1  7   00:14.494.257   UIKit   -[UINib instantiateWithOwner:options:]
7   Release -1  6   00:14.494.395   UIKit   -[UIRuntimeConnection dealloc]
8   Release -1  5   00:14.494.414   UIKit   -[UIRuntimeConnection dealloc]
    Release (2) -2      00:14.494.435   UIKit   -[UINibDecoder finishDecoding]
10  Release -1  3   00:14.494.458   UIKit   -[UINibDecoder finishDecoding]
12  Retain  +1  3   00:14.496.105   Vit Calc    -[RBCViewController actionSheet:clickedButtonAtIndex:]
    Retain/Release (2)          00:14.496.275   UIKit   -[_UIFullscreenPresentationController _setPresentedViewController:]
14  Retain  +1  5   00:14.510.866   UIKit   -[UIViewController setChildModalViewController:]
15  Retain  +1  6   00:14.510.886   UIKit   -[UIApplication _addViewControllerForLockingStatusBarTintColor:]
    Retain/Release (2)          00:14.511.042   UIKit   -[UIPresentationController runTransitionForCurrentState]
17  Retain  +1  8   00:14.511.112   libsystem_sim_blocks.dylib  _Block_object_assign
18  Retain  +1  9   00:14.511.135   libsystem_sim_blocks.dylib  _Block_object_assign
19  Release -1  8   00:14.511.152   UIKit   -[UIActionSheet _indexTapped:]
20  Release -1  7   00:14.514.081   GraphicsServices    GSEventRunModal
21  Release -1  6   00:14.514.098   UIKit   -[UIStoryboardScene dealloc]
22  Retain  +1  7   00:14.556.304   UIKit   -[UIPeripheralHost(UIKitInternal) _beginPinningInputViewsOnBehalfOfResponder:]
23  Retain  +1  8   00:14.564.411   UIKit   -[UIViewController _setPresentedStatusBarViewController:]
24  Release -1  7   00:14.564.660   UIKit   __destroy_helper_block_1444
25  Release -1  6   00:14.564.715   UIKit   -[UIPeripheralHost(UIKitInternal) _stopPinningInputViewsOnBehalfOfResponder:]
26  Release -1  5   00:14.564.721   UIKit   __destroy_helper_block_382
    Retain/Release (2)          00:14.581.427   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
    Retain/Release (2)          00:14.595.199   Foundation  +[NSConcreteNotification newTempNotificationWithName:object:userInfo:]
    Retain/Release (4)          00:14.607.299   UIKit   -[UIResponder becomeFirstResponder]
34  Retain  +1  5   00:16.014.292   UIKit   -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
    Retain/Release (2)          00:16.014.324   UIKit   -[UIPresentationController runTransitionForCurrentState]
36  Retain  +1  7   00:16.014.399   libsystem_sim_blocks.dylib  _Block_object_assign
37  Release -1  6   00:16.014.430   UIKit   -[UIViewController _dismissViewControllerWithAnimationController:interactionController:completion:]
38  Release -1  5   00:16.036.310   UIKit   -[UIViewController _setPresentedStatusBarViewController:]
39  Release -1  4   00:16.036.802   UIKit   __destroy_helper_block_382
42  Retain  +1  5   00:16.546.187   UIKit   -[UIViewController _didFinishDismissTransition]
43  Retain  +1  6   00:16.546.190   UIKit   -[UIApplication _removeViewControllerForLockingStatusBarTintColor:]
44  Release -1  5   00:16.546.190   UIKit   -[UIApplication _removeViewControllerForLockingStatusBarTintColor:]
45  Release -1  4   00:16.546.191   UIKit   -[UIApplication _removeViewControllerForLockingStatusBarTintColor:]
46  Release -1  3   00:16.546.192   UIKit   -[UIViewController setChildModalViewController:]
47  Release -1  2   00:16.546.195   UIKit   -[UIViewController _didFinishDismissTransition]
50  Zombie      -1  00:18.518.590   UIKit   -[UIPresentationController runTransitionForCurrentState]

50 Zombie -1 00: 18.518.590 UIKit - [UIPresentationController runTransitionForCurrentState]

Краткая версия (отфильтровано)

Event Type  ∆ RefCt RefCt   Timestamp   Responsible Library Responsible Caller
    Retain/Release (2)          00:14.496.275   UIKit   -[_UIFullscreenPresentationController _setPresentedViewController:]
1   Retain  +1  7   00:14.511.042   UIKit   -[UIPresentationController runTransitionForCurrentState]
2   Retain  +1  8   00:14.564.411   UIKit   -[UIViewController _setPresentedStatusBarViewController:]
3   Retain  +1  6   00:16.014.324   UIKit   -[UIPresentationController runTransitionForCurrentState]
4   Release -1  5   00:16.036.310   UIKit   -[UIViewController _setPresentedStatusBarViewController:]
6   Zombie      -1  00:18.518.590   UIKit   -[UIPresentationController runTransitionForCurrentState]

В короткой версии кажется, что Retain на самом деле делает наоборот:

1   Retain  +1  7   00:14.511.042   UIKit   -[UIPresentationController runTransitionForCurrentState]
3   Retain  +1  6   00:16.014.324   UIKit   -[UIPresentationController runTransitionForCurrentState]

Я пытался воспроизвести это в новом проекте, но не смог.

Кроме того, похоже, это происходит только тогда, когда мой делегат UIActionSheet установлен (на себя).

На этом этапе я просто хочу отправить Apple более краткий отчет об ошибке, поэтому я просто пытаюсь определить проблему.


ОБНОВЛЕНИЕ


Могу воспроизвести.

Это происходит, когда UIActionSheet инициализируется другим методом, чем тот, который его представляет. И его делегат представляет другой ViewController.

Например:

@implementation RBCViewController
{
    UIActionSheet *actionSheet;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self createActionSheet];
}

- (void)createActionSheet
{
    actionSheet = [[UIActionSheet alloc]init];
}

- (IBAction)showActionSheet:(UIButton *)sender {

    // Add buttons, assign delegate here

    [actionSheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // Present another ViewContoller here.
    // This will fail with 'Bad Access' on the second time
}

person bauerMusic    schedule 05.07.2014    source источник
comment
То же самое происходит с бета-версией 3   -  person Ekra    schedule 13.07.2014
comment
@Dont_Peep Да. Я не стал упоминать об этом, но использую Xcode 6 Beta 3. Я сообщил в Apple, и меня попросили предоставить дополнительную информацию, которую я обновил. Мне потребовалось время, чтобы выделить это из большого проекта.   -  person bauerMusic    schedule 13.07.2014


Ответы (1)


Я была такая же проблема. Решение состоит в том, чтобы освобождать ваш UIActionSheet после каждого использования, поскольку он будет удерживать UIWindow, который он использовал для представления себя (который имеет указатель unsafe_unreolated на модальный VC, который вы представили).

Будущие читатели: будьте осторожны, это может перестать быть правдой, когда выйдет iOS8.

person Javache    schedule 06.08.2014
comment
Хороший звонок! Придется следить за грядущими изменениями. - person bauerMusic; 07.08.2014