Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autolayout crash in iOS8 #100

Closed
ealeksandrov opened this issue Feb 25, 2015 · 19 comments
Closed

Autolayout crash in iOS8 #100

ealeksandrov opened this issue Feb 25, 2015 · 19 comments
Labels

Comments

@ealeksandrov
Copy link
Owner

To reproduce:

  1. Enable autolayout on IntroPage.xib
  2. Run demo project, select showIntroWithCustomViewFromNib
  3. Recieve crash:
2015-02-25 22:21:25.829 EAIntroView[5215:1435025] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c1f4f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010be8dbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010c0dff33 -[__NSArrayM objectAtIndex:] + 227
    3   UIKit                               0x000000010c87b5b1 _UIViewTopDownSubtreeTraversal + 193
    4   UIKit                               0x000000010ceacee6 -[UIView(UIConstraintBasedLayout_EngineDelegate) _invalidateSystemLayoutSizeFittingSizeAtEngineDelegateLevel] + 128
    5   Foundation                          0x000000010ba319bf -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 915
    6   Foundation                          0x000000010bbbb0f8 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
    7   Foundation                          0x000000010ba2611a -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 220
    8   UIKit                               0x000000010cea9de5 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
    9   Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    10  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    11  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    12  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    13  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    14  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    15  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    16  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    17  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    18  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    19  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    20  UIKit                               0x000000010c8a568b -[UIScrollView _switchToLayoutEngine:] + 69
    21  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    22  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    23  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    24  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    25  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    26  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    27  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    28  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    29  UIKit                               0x000000010cea9671 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 404
    30  UIKit                               0x000000010ce9e591 -[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 127
    31  UIKit                               0x000000010c8984a5 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 207
    32  UIKit                               0x000000010c891112 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
    33  UIKit                               0x000000010c891086 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
    34  UIKit                               0x000000010c89af4b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1604
    35  UIKit                               0x000000010cabfe84 -[UILayoutContainerView addSubview:] + 75
    36  EAIntroView                         0x000000010b93e14a -[EAIntroView showInView:animateDuration:withInitialPageIndex:] + 362
    37  EAIntroView                         0x000000010b93dfc9 -[EAIntroView showInView:animateDuration:] + 121
    38  EAIntroView                         0x000000010b9303a7 -[ViewController showIntroWithCustomViewFromNib] + 1879
    39  EAIntroView                         0x000000010b9326a4 -[ViewController tableView:didSelectRowAtIndexPath:] + 340
    40  UIKit                               0x000000010c90c393 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1293
    41  UIKit                               0x000000010c90c4d4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
    42  UIKit                               0x000000010c847331 _applyBlockToCFArrayCopiedToStack + 314
    43  UIKit                               0x000000010c8471ab _afterCACommitHandler + 516
    44  CoreFoundation                      0x000000010c129dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    45  CoreFoundation                      0x000000010c129d20 __CFRunLoopDoObservers + 368
    46  CoreFoundation                      0x000000010c11fb53 __CFRunLoopRun + 1123
    47  CoreFoundation                      0x000000010c11f486 CFRunLoopRunSpecific + 470
    48  GraphicsServices                    0x00000001106f59f0 GSEventRunModal + 161
    49  UIKit                               0x000000010c824420 UIApplicationMain + 1282
    50  EAIntroView                         0x000000010b932843 main + 115
    51  libdyld.dylib                       0x000000010e9c7145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Related: http://stackoverflow.com/questions/25878621/nsrangeexception-on-ios-8
Solution from SO:

Turning AutoLayout off for all of my XIBs solved the issue.

But: If you'll launch and close different intro example before opening autolaouyt one - it will work perfectly without crashing.

@hbthlw
Copy link

hbthlw commented Mar 7, 2015

same problem with you

@hkellaway
Copy link

same issue encountered

@panzerdp
Copy link

panzerdp commented Mar 9, 2015

same problem here with version 2.7.0.

@zmillman
Copy link

Ditto.

Removing the skip button with [[intro skipButton] removeFromSuperview]; at least makes the application not crash.

@davecom
Copy link

davecom commented Apr 14, 2015

Does anybody have a temporary workaround/fix? I tried removing the skip button and that appeared to have no effect.

@hkellaway
Copy link

@davecom unless you need whatever functionality 2.7 introduced, use 2.6

@davecom
Copy link

davecom commented Apr 14, 2015

Thanks, yes I downgraded to 2.6.4 and have resolved the crashing issue. However, I was using the bgColor functionality in 2.7... alas!

@ealeksandrov
Copy link
Owner Author

I found the cause of this issue, now working on bugfix.

@panzerdp
Copy link

@ealeksandrov thanks!

@mohitngm
Copy link

mohitngm commented May 7, 2015

Hi @ealeksandrov any update on this issue causing crash in iOS 8.3. its happening in release build for me not on debug build.

@ealeksandrov
Copy link
Owner Author

It related with addSubview: override on ScrollVIew subclass. Working on ways to fix it.

@igostavro
Copy link

Hi guys,

Any update on a fix?

@mohitngm
Copy link

@igostavro .. till then you can use pod 'EAIntroView', '~> 2.6.4' and

if want to use bgColor use bgImage

EAIntroPage *page1 = [EAIntroPage page];
as page1.bgImage = [UIColor imageFromColor:[UIColor redColor]];

+ (UIImage *)imageFromColor:(UIColor *)color
{
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

@igostavro
Copy link

Way ahead of you:-) Thanks!

@Omarj
Copy link

Omarj commented Jun 3, 2015

@ealeksandrov @mohitngm any update ?

@Reedyuk
Copy link

Reedyuk commented Jun 7, 2015

I'm also looking for an update on this too

@flywww
Copy link

flywww commented Jun 9, 2015

Waiting for update

@Omarj
Copy link

Omarj commented Jun 9, 2015

@ealeksandrov app crash when this method get called

+ (instancetype)pageWithCustomView:(UIView *)customV {
    EAIntroPage *newPage = [[self alloc] init];
    newPage.customView = customV;
    newPage.bgColor = customV.backgroundColor;
    return newPage;
}

and if u choose showIntroWithCustomPages first the other option will work with no problem.

try to showIntroWithCustomPages --then--> showIntroWithCustomView

@ealeksandrov
Copy link
Owner Author

Good news, everyone!

🎉

I finally found a root cause of this issue: EARestrictedScrollView.m#L54-56

Autolayout somehow uses subview property and overriding it - breaks things. This depends on many other things, as many contributors shared above, but fixing subviews deals it for me in 100% of cases.

I will merge all changes and push new version of EARestrictedScrollView. After this, EAIntroView will be updated and pushed on Cocoapods as well.

ealeksandrov added a commit to ealeksandrov/EARestrictedScrollView that referenced this issue Jun 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests