Closed latteier closed 7 years ago
I should say that I'm using the master branch of Classy from git.
Seems to happen when I use the "iPhone 4s", "iPhone 5", and "iPad 2" simulators, but not "iPhone 5s", "iPhone 6 Plus", or "iPhone 6".
I get a similar EXC_ACCESS error on line 118
while (currentItem.cas_parent != nil || currentItem.cas_alternativeParent != nil) {
It happens when I tap the "Cancel" button on a UIActionSheet
. Changing the line to:
while (currentItem.cas_parent != nil) {
makes the error go away. Only on iOS8
The same issue affect Classy 0.2.4 on iOS7/8 version.
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x00000001956580b4 objc_retain + 20
1 App 0x0000000100215f70 -[CASStyleSelector matchesAncestorsOfItem:traverse:] (CASStyleSelector.m:122)
2 App 0x00000001002158f4 -[CASStyleSelector shouldSelectItem:] (CASStyleSelector.m:79)
3 App 0x0000000100216778 -[CASStyler styleItem:] (CASStyler.m:63)
4 App 0x000000010021f820 -[UIView(CASAdditions) cas_updateStyling] (UIView+CASAdditions.m:69)
5 App 0x000000010021f528 -[UIView(CASAdditions) cas_didMoveToWindow] (UIView+CASAdditions.m:25)
6 UIKit 0x00000001897895cc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1464
7 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
8 UIKit 0x0000000189807810 -[UIControl _didMoveFromWindow:toWindow:] + 60
9 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
10 UIKit 0x00000001897aa954 -[UIScrollView _didMoveFromWindow:toWindow:] + 68
11 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
12 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
13 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
14 UIKit 0x00000001897892e4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 720
15 UIKit 0x00000001897889b4 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 144
16 Foundation 0x0000000185e36368 -[NSISEngine withBehaviors:performModifications:] + 176
17 UIKit 0x0000000189788874 -[UIView(Hierarchy) _postMovedFromSuperview:] + 452
18 UIKit 0x0000000189794330 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1724
19 UIKit 0x000000018987fe3c -[UITransitionView transition:fromView:toView:removeFromView:] + 1228
20 UIKit 0x000000018987f434 -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] + 984
21 UIKit 0x000000018987eb74 __101-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:]_block_invoke_2 + 1356
22 UIKit 0x000000018980f388 _applyBlockToCFArrayCopiedToStack + 356
23 UIKit 0x0000000189780e4c _afterCACommitHandler + 532
24 CoreFoundation 0x0000000184fc2388 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
25 CoreFoundation 0x0000000184fbf314 __CFRunLoopDoObservers + 360
26 CoreFoundation 0x0000000184fbf6f4 __CFRunLoopRun + 836
27 CoreFoundation 0x0000000184eed664 CFRunLoopRunSpecific + 396
28 GraphicsServices 0x000000018e0275a4 GSEventRunModal + 168
29 UIKit 0x00000001897f2984 UIApplicationMain + 1488
30 App 0x0000000100072f28 main (main.m:17)
31 libdyld.dylib 0x0000000195caea08 start + 4
It appears to me that the crash is caused by cas_alternativeParent
(lldb) po [currentItem cas_alternativeParent]
0x00007ff4aae9ef60
That said, I'm not sure how it got into this state.
OK, I think I know what happened for me.
The currentItem is a view that comes from another view controller. That view controller sets the cas_alternativeParent on the view to itself. Then I add the view to my view hierarchy. The view controller goes away because the cas_alternativeParent is a weak property. Later when trying to style the view there's a bad reference to its original view controller.
Has anyone found a fix? If so please submit a PR and I will try merge into master. thanks!
It's unclear with a good fix is.
The issue is that cas_alternativeParent isn't safe. If the view controller that it refers to goes away then it becomes a bad reference.
What I did to deal with it was to manually set my view's cas_alternativeParent to nil when I know that its original view controller is going away.
Im seeing this only when a user dismisses a UIAlertView. The implementation of this has changed in iOS8. the offending controller seems to be _UIAlertShimPresentingViewController.
If I switch to the new UIAlertController the issue goes away. The issue does not occur on iOS 7
Current crash logs reports that issue is only for iOS 7 devices.
Hi guys, the issue exists on iOS 7 & 8. I just fixed it, hope it will be merged into master. The root of the problems begin with OBJC_ASSOCIATION_ASSIGN, it equals the "unsafe_unretained", we should use the "weak". Below link is my patch codes.
https://www.dropbox.com/s/dkmzp8x4ymxdjz4/Classy-ios8-patch.zip?dl=0
@iMoreApps can you create a pull request for your changes? This would be very helpful
EDIT: did it for you
Thanks mikeger.
@latteier , a solution was merged into Classy. Can you close this issue?
Glad to hear that it's fixed.
I'm sometimes getting a crash with Classy
Not sure what other information you need.
line 122 of CAStyleSelector.m is higlighted