problame / CSNotificationView

Drop-in, semi-translucent and blurring notification view.
MIT License
900 stars 152 forks source link

Crashes with Key-Value-Observing #32

Closed problame closed 10 years ago

problame commented 10 years ago

There are crashes related to CSNotificationView being reported to me since 0.4 (commit 54ea0817f8158ccdb54ffd4fd7f87f42397dc991).

There is EXC_BAD_ACCESS KERN_PROTECTION_FAILURE after the following to methods are called over and over again - with some UIKit stuff in between:


0   CoreFoundation                 0x0000000189e749f4 -[NSArray isEqualToArray:] + 48
1   CoreFoundation                 0x0000000189e749b8 -[NSArray isEqual:] + 96
2   CoreFoundation                 0x0000000189e749b8 -[NSArray isEqual:] + 96
3   UIKit                          0x000000018d026d20 -[UINavigationBar _setItems:transition:] + 128
4   UIKit                          0x000000018d1f281c -[UINavigationController _updateNavigationBarItems:] + 160
5   UIKit                          0x000000018cf80058 -[UINavigationController loadView] + 288
6   UIKit                          0x000000018ceec488 -[UIViewController loadViewIfRequired] + 88
7   UIKit                          0x000000018ceec3f4 -[UIViewController view] + 32

8   MYAPP                            0x00000001001508c8 -[CSNotificationView hiddenFrame] (CSNotificationView.m:416)
9   MYAPP                            0x000000010014f654 -[CSNotificationView observeValueForKeyPath:ofObject:change:context:] (CSNotificationView.m:237)
10  Foundation                     0x000000018a9cddf4 NSKeyValueNotifyObserver + 340
11  Foundation                     0x000000018a9cd924 NSKeyValueDidChange + 432
12  Foundation                     0x000000018a9b6544 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 116
13  UIKit                          0x000000018cf8376c -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 428
14  UIKit                          0x000000018cf8355c -[UINavigationController _positionNavigationBarHidden:edge:] + 152
15  UIKit                          0x000000018cf800a4 -[UINavigationController loadView] + 364
16  UIKit                          0x000000018ceec488 -[UIViewController loadViewIfRequired] + 88
17  UIKit                          0x000000018ceec3f4 -[UIViewController view] + 32

18  MYAPP                            0x00000001001508c8 -[CSNotificationView hiddenFrame] (CSNotificationView.m:416)
19  MYAPP                            0x000000010014f654 -[CSNotificationView observeValueForKeyPath:ofObject:change:context:] (CSNotificationView.m:237)
20  Foundation                     0x000000018a9cddf4 NSKeyValueNotifyObserver + 340
21  Foundation                     0x000000018a9cd924 NSKeyValueDidChange + 432
22  Foundation                     0x000000018a9b6544 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 116
23  UIKit                          0x000000018cf8376c -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 428
24  UIKit                          0x000000018cf8355c -[UINavigationController _positionNavigationBarHidden:edge:] + 152
25  UIKit                          0x000000018cf800a4 -[UINavigationController loadView] + 364
26  UIKit                          0x000000018ceec488 -[UIViewController loadViewIfRequired] + 88
27  UIKit                          0x000000018ceec3f4 -[UIViewController view] + 32
...

These crashes appear mostly when the app logic wants to present a CSNotificationView but the app's views etc. are not fully initialized yet.

I think that's why we see such a repeating schema of -[UIViewController view] being called.

In addition, this has something to to with KVO (hence: the calls to -[CSNotificationView observeValueForKeyPath:ofObject:change:context:] )

Do you have any idea what could be behind all this?