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

ASTableNode + Multiline text + automaticallyAdjustsScrollViewInsets + device rotation = crash #70

Closed
stephenkopylov opened this issue Apr 25, 2017 · 10 comments
Assignees

Comments

@stephenkopylov
Copy link
Contributor

Hi guys!

simulator-screen-shot-25-apr-2017 -7 19 44-pm

So found some problem.
Please check the test project below.
Go to "multiline" screen try to rotate your device/simulator to different orientation and back and you will get crash with:
"*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'"

The problem is somehow related to automaticallyAdjustsScrollViewInsets flag and ASInsetLayoutSpec inside cell.

Prj: https://github.com/stephenkopylov/TextureTableViewOrientation

@jaclync
Copy link

jaclync commented May 10, 2017

has anyone got updates on this issue? I am evaluating whether my team could use Texture to develop a new table view design (we've been using AutoLayout), but this reproducible crash worries me quite a bit.

In my case, I was using ASTableNode in a non-ASViewController subclass. ASCellNode returns layout spec of insets with stack view that changes axis based on orientation.

Stack trace looks like (always an index +1 of bound):

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 8 beyond bounds [0 .. 7]'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000011088bd4b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00000001102f421e objc_exception_throw + 48
	2   CoreFoundation                      0x00000001107bd2eb -[__NSArrayM objectAtIndex:] + 203
	3   UIKit                               0x000000010c899885 -[UITableView _updateVisibleCellsNow:isRecursive:] + 4788
	4   UIKit                               0x000000010c896f49 -[UITableView _setNeedsVisibleCellsUpdate:withFrames:] + 204
	5   UIKit                               0x000000010c8b68af -[UITableView _rectChangedWithNewSize:oldSize:] + 1348
	6   UIKit                               0x000000010c8b7052 -[UITableView setBounds:] + 321
	7   UIKit                               0x000000010c80003d -[UIView(Geometry) _applyISEngineLayoutValuesToBoundsOnly:] + 608
	8   UIKit                               0x000000010c80036a -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 123
	9   UIKit                               0x000000010d1bfd6a -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] + 47
	10  CoreFoundation                      0x000000011081b0b2 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
	11  CoreFoundation                      0x000000011081afcf -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 335
	12  UIKit                               0x000000010c7febe7 -[UIView(Geometry) resizeSubviewsWithOldSize:] + 184
	13  UIKit                               0x000000010d127e76 -[UIView(AdditionalLayoutSupport) _is_layout] + 161
	14  UIKit                               0x000000010c80b5d0 -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 1045
	15  UIKit                               0x000000010c81cab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
	16  QuartzCore                          0x000000010fc52bf8 -[CALayer layoutSublayers] + 146
	17  QuartzCore                          0x000000010fc46440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
	18  UIKit                               0x000000010c80a928 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1509
	19  UIKit                               0x000000010c93a8b1 -[UINavigationController _layoutViewController:] + 1625
	20  UIKit                               0x000000010c9396df -[UINavigationController _layoutTopViewController] + 341
	21  UIKit                               0x000000010c92e55c -[UINavigationController _repositionPaletteWithNavigationBarHidden:duration:shouldUpdateNavigationItems:] + 422
	22  UIKit                               0x000000010c937b6c -[UINavigationController _updateBarsForCurrentInterfaceOrientation] + 77
	23  UIKit                               0x000000010c9579b0 -[UITabBarController _updateLayoutForStatusBarAndInterfaceOrientation] + 83
	24  UIKit                               0x000000010c8fb98e -[UIViewController window:statusBarWillChangeFromHeight:toHeight:windowSizedViewController:] + 2250
	25  UIKit                               0x000000010c8fbd92 -[UIViewController window:statusBarWillChangeFromHeight:toHeight:] + 176
	26  UIKit                               0x000000010c7d49b0 -[UIWindow handleStatusBarChangeFromHeight:toHeight:] + 576
	27  UIKit                               0x000000010c7d8801 +[UIWindow _noteStatusBarHeightChanged:oldHeight:forAutolayoutRootViewsOnly:] + 397
	28  UIKit                               0x000000010c75b4f0 __79-[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:]_block_invoke + 148
	29  UIKit                               0x000000010c8125c0 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 581
	30  UIKit                               0x000000010c812b4a +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:completion:] + 92
	31  UIKit                               0x000000010c75b2a7 -[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:] + 678
	32  UIKit                               0x000000010c75a5fa -[UIApplication _updateCurrentStatusBarViewControllerAppearance] + 433
	33  UIKit                               0x000000010c91cd49 -[UIViewController setNeedsStatusBarAppearanceUpdate] + 204
	34  UIKit                               0x000000010c8f7afe __78-[UIViewController willTransitionToTraitCollection:withTransitionCoordinator:]_block_invoke + 31
	35  UIKit                               0x000000010d29eae8 -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] + 311
	36  UIKit                               0x000000010d29ab2c -[_UIViewControllerTransitionContext __runAlongsideAnimations] + 201
	37  UIKit                               0x000000010cdf0042 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke_2 + 179
	38  UIKit                               0x000000010c81734f +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] + 188
	39  UIKit                               0x000000010cdefe4f __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke + 134
	40  UIKit                               0x000000010c8125c0 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 581
	41  UIKit                               0x000000010c812ad9 +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 105
	42  UIKit                               0x000000010cdefd35 -[_UIWindowRotationAnimationController animateTransition:] + 557
	43  UIKit                               0x000000010c7cc4ca -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 667
	44  UIKit                               0x000000010c7cf2d5 -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 2073
	45  UIKit                               0x000000010c7cfd59 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 726
	46  UIKit                               0x000000010c7ce91f -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 151
	47  UIKit                               0x000000010c7cd596 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 115
	48  UIKit                               0x000000010c7cd420 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 477
	49  CoreFoundation                      0x00000001108295ec __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	50  CoreFoundation                      0x00000001108294eb _CFXRegistrationPost + 427
	51  CoreFoundation                      0x0000000110829252 ___CFXNotificationPost_block_invoke + 50
	52  CoreFoundation                      0x00000001107ec282 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 2018
	53  CoreFoundation                      0x00000001107eb31b _CFXNotificationPost + 667
	54  Foundation                          0x000000010fdba81b -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
	55  UIKit                               0x000000010caf1c49 -[UIDevice setOrientation:animated:] + 290
	56  UIKit                               0x000000010c7754bf __54-[UIApplication _handleDeviceOrientationChangedEvent:]_block_invoke + 87
	57  UIKit                               0x000000010c775438 -[UIApplication _handleDeviceOrientationChangedEvent:] + 124
	58  UIKit                               0x000000010c775281 -[UIApplication handleEvent:withNewEvent:] + 1463
	59  UIKit                               0x000000010c775890 -[UIApplication sendEvent:] + 88
	60  UIKit                               0x000000010c781ff3 _UIApplicationHandleEvent + 406
	61  GraphicsServices                    0x00000001138f8141 _PurpleEventCallback + 747
	62  GraphicsServices                    0x00000001138f7c53 PurpleEventCallback + 35
	63  CoreFoundation                      0x000000011081d3d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
	64  CoreFoundation                      0x000000011081d351 __CFRunLoopDoSource1 + 465
	65  CoreFoundation                      0x0000000110815435 __CFRunLoopRun + 2389
	66  CoreFoundation                      0x0000000110814884 CFRunLoopRunSpecific + 420
	67  GraphicsServices                    0x00000001138f6a6f GSEventRunModal + 161
	68  UIKit                               0x000000010c757c68 UIApplicationMain + 159
	69  Development                         0x0000000107387eef main + 111
	70  libdyld.dylib                       0x000000011190468d start + 1
	71  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

@stephenkopylov
Copy link
Contributor Author

stephenkopylov commented May 10, 2017

@jaclync
This is sad, but this bug makes the lib unusable with multiline text inside tableviews, actually =(
Hope guys pay their attention on it shortly.

@nguyenhuy if it possible, check this issue, please

@mikengyn
Copy link

mikengyn commented May 10, 2017

I get this exact same issue. Any help would be greatly appreciated.

@jaclync
Copy link

jaclync commented May 11, 2017

An interesting observation from playing with ASDKgram example app - the example is using multiple ASTextNode multiline labels and inset/stack layout specs in the photo feed, but it does not crash on rotation. I was wondering if there is certain setup to prevent this crash, just like in the example app.

@stephenkopylov
Copy link
Contributor Author

@jaclync there is some dependence between this crash and UINavigationViewController

@gertjanvg
Copy link

gertjanvg commented May 20, 2017

I have just encountered the same issue. I am also using multiline ASTextNode nodes. I don't know how helpful I can be, but the least I can do is supply my stack trace. Additionally, I first get an exception thrown in ASRunLoopQueue.mm:97. This is Texture 2.3.2.

2017-05-20 21:24:28.531 App[42266:2761944] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 7 beyond bounds [0 .. 6]'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010a5beb0b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00000001081e1141 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010a4f405b -[__NSArrayM objectAtIndex:] + 203
	3   UIKit                               0x000000010899aa10 -[UITableView _updateVisibleCellsNow:isRecursive:] + 4676
	4   UIKit                               0x0000000108998154 -[UITableView _setNeedsVisibleCellsUpdate:withFrames:] + 201
	5   UIKit                               0x00000001089b6f1a -[UITableView _rectChangedWithNewSize:oldSize:] + 1267
	6   UIKit                               0x00000001089b75bd -[UITableView setFrame:] + 319
	7   UIKit                               0x00000001088fef51 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 869
	8   UIKit                               0x00000001088ffe9d -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 268
	9   UIKit                               0x00000001092af179 -[UIScrollView(_UIOldConstraintBasedLayoutSupport) _resizeWithOldSuperviewSize:] + 46
	10  CoreFoundation                      0x000000010a54f652 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
	11  CoreFoundation                      0x000000010a54f56f -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 335
	12  UIKit                               0x00000001088fe87c -[UIView(Geometry) resizeSubviewsWithOldSize:] + 183
	13  UIKit                               0x00000001088fcd86 -[UIView(Geometry) setFrame:] + 1082
	14  UIKit                               0x000000010917daf0 -[_UIQueuingScrollView _boundsDidChangeToSize:] + 561
	15  UIKit                               0x0000000109179a83 -[_UIQueuingScrollView setFrame:] + 220
	16  UIKit                               0x00000001091797c5 -[_UIQueuingScrollView _setFrameAndApplyPageSpacing:] + 148
	17  UIKit                               0x00000001090749e3 -[_UIPageViewControllerContentView layoutSubviews] + 843
	18  UIKit                               0x000000010891c20b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
	19  QuartzCore                          0x000000010b19d904 -[CALayer layoutSublayers] + 146
	20  QuartzCore                          0x000000010b191526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
	21  UIKit                               0x0000000108909fe4 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1108
	22  UIKit                               0x0000000108a3b132 -[UINavigationController _layoutViewController:] + 1614
	23  UIKit                               0x0000000108a39f6e -[UINavigationController _layoutTopViewController] + 338
	24  UIKit                               0x0000000108a2f2ca -[UINavigationController _repositionPaletteWithNavigationBarHidden:duration:shouldUpdateNavigationItems:] + 387
	25  UIKit                               0x0000000108a384a7 -[UINavigationController _updateBarsForCurrentInterfaceOrientation] + 77
	26  UIKit                               0x00000001089fdac5 -[UIViewController window:statusBarWillChangeFromHeight:toHeight:windowSizedViewController:] + 2033
	27  UIKit                               0x00000001089fdeb1 -[UIViewController window:statusBarWillChangeFromHeight:toHeight:] + 160
	28  UIKit                               0x00000001088d50b2 -[UIWindow handleStatusBarChangeFromHeight:toHeight:] + 608
	29  UIKit                               0x00000001088d8e5d +[UIWindow _noteStatusBarHeightChanged:oldHeight:forAutolayoutRootViewsOnly:] + 396
	30  UIKit                               0x000000010885c8e4 __79-[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:]_block_invoke + 142
	31  UIKit                               0x000000010891208a +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 572
	32  UIKit                               0x00000001089125fc +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:completion:] + 86
	33  UIKit                               0x000000010885c6c1 -[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:] + 648
	34  UIKit                               0x000000010885d805 -[UIApplication setStatusBarOrientation:animationParameters:notifySpringBoardAndFence:updateBlock:] + 1759
	35  UIKit                               0x00000001088d03aa __78-[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:]_block_invoke.1167 + 288
	36  UIKit                               0x0000000108ee429f __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke_2 + 152
	37  UIKit                               0x0000000108916c5d +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] + 188
	38  UIKit                               0x0000000108ee40c8 __58-[_UIWindowRotationAnimationController animateTransition:]_block_invoke + 136
	39  UIKit                               0x000000010891208a +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 572
	40  UIKit                               0x000000010891258d +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] + 99
	41  UIKit                               0x0000000108ee3fae -[_UIWindowRotationAnimationController animateTransition:] + 513
	42  UIKit                               0x00000001088cd12a -[UIWindow _rotateToBounds:withAnimator:transitionContext:] + 605
	43  UIKit                               0x00000001088cfdf4 -[UIWindow _rotateWindowToOrientation:updateStatusBar:duration:skipCallbacks:] + 1865
	44  UIKit                               0x00000001088d084b -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 726
	45  UIKit                               0x00000001088cf4ec -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 141
	46  UIKit                               0x00000001088ce1a3 __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 112
	47  UIKit                               0x00000001088ce031 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 485
	48  CoreFoundation                      0x000000010a55dc2c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
	49  CoreFoundation                      0x000000010a55db29 _CFXRegistrationPost + 425
	50  CoreFoundation                      0x000000010a55d892 ___CFXNotificationPost_block_invoke + 50
	51  CoreFoundation                      0x000000010a521162 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
	52  CoreFoundation                      0x000000010a5202c1 _CFXNotificationPost + 673
	53  Foundation                          0x0000000107cafb24 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
	54  UIKit                               0x0000000108bede59 -[UIDevice setOrientation:animated:] + 290
	55  UIKit                               0x00000001088762fa __54-[UIApplication _handleDeviceOrientationChangedEvent:]_block_invoke + 87
	56  UIKit                               0x0000000108876271 -[UIApplication _handleDeviceOrientationChangedEvent:] + 129
	57  UIKit                               0x00000001088760d9 -[UIApplication handleEvent:withNewEvent:] + 1497
	58  UIKit                               0x00000001088766a8 -[UIApplication sendEvent:] + 88
	59  UIKit                               0x0000000108883b71 _UIApplicationHandleEvent + 387
	60  GraphicsServices                    0x000000010f59b15e _PurpleEventCallback + 747
	61  GraphicsServices                    0x000000010f59ac7d PurpleEventCallback + 37
	62  CoreFoundation                      0x000000010a551aa9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
	63  CoreFoundation                      0x000000010a551a21 __CFRunLoopDoSource1 + 465
	64  CoreFoundation                      0x000000010a549ba0 __CFRunLoopRun + 2352
	65  CoreFoundation                      0x000000010a549016 CFRunLoopRunSpecific + 406
	66  GraphicsServices                    0x000000010f599a24 GSEventRunModal + 62
	67  UIKit                               0x00000001088590d4 UIApplicationMain + 159
	68  App                                 0x0000000106fef9e7 main + 55
	69  libdyld.dylib                       0x000000010879e65d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@mikengyn
Copy link

mikengyn commented Jun 1, 2017

Has anyone got any updates regarding this?

PS: I downgraded to 2.2 and the crash doesn't happen anymore.

@dymv
Copy link
Contributor

dymv commented Sep 11, 2017

It seems working fine in 2.4 (at least on my machine)
As far as I can tell, it was addressed by @nguyenhuy in #416 (thanks, man!)

Can anybody confirm that there's no problem anymore?

@mikengyn
Copy link

@dymv confirmed fixed for me as well. Thank you @nguyenhuy 😄

@nguyenhuy
Copy link
Member

Awesome. Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants