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

TTTAttributedLabel crash when calculating size for some content #32

Closed
robinspeijer opened this issue Jan 8, 2020 · 1 comment · Fixed by #34
Closed

TTTAttributedLabel crash when calculating size for some content #32

robinspeijer opened this issue Jan 8, 2020 · 1 comment · Fixed by #34
Assignees
Labels
Milestone

Comments

@robinspeijer
Copy link
Contributor

Steps to reproduce:

  • Browse any reddit content on iOS 13.3
  • At some point, the app crashes with the following stacktrace:
Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00000001b298dec4 in __pthread_kill ()
#1	0x00000001b28ad724 in pthread_kill$VARIANT$armv81 ()
#2	0x00000001b27fd844 in abort ()
#3	0x00000001b29567d4 in abort_message ()
#4	0x00000001b29569c4 in demangling_terminate_handler() ()
#5	0x00000001b28be258 in _objc_terminate() ()
#6	0x00000001b2963304 in std::__terminate(void (*)()) ()
#7	0x00000001b2962c58 in __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) ()
#8	0x00000001b2962c18 in __cxa_throw ()
#9	0x00000001b28be0d0 in objc_exception_throw ()
#10	0x00000001b2a9a5a8 in -[NSObject(NSObject) doesNotRecognizeSelector:] ()
#11	0x00000001b2b9aaf4 in ___forwarding___ ()
#12	0x00000001b2b9ca7c in _CF_forwarding_prep_0 ()
#13	0x00000001b3895b60 in TAttributes::HandleUnderlineAttribute(void const*, TAttributes::AttributeHandlerContext*) ()
#14	0x00000001b6135600 in -[NSAttributeDictionary __apply:context:] ()
#15	0x00000001b38951b0 in TAttributes::ParseAttributes(__CFDictionary const*, __CTFont const*, void const*&, TInlineVector<std::__1::function<void (TAttributes&)>, 30ul>&, std::__1::pair<bool, LigatureSetting>*) ()
#16	0x00000001b38949ec in TAttributes::ApplyFont(__CFDictionary const*, __CTFont const*, void const**) ()
#17	0x00000001b389482c in TAttributes::TAttributes(__CFDictionary const*) ()
#18	0x00000001b383e74c in TTypesetterAttrString::Initialize(__CFAttributedString const*) ()
#19	0x00000001b383e5c8 in TTypesetterAttrString::TTypesetterAttrString(__CFAttributedString const*, __CFDictionary const*) ()
#20	0x00000001b383a98c in TCFRef<CTFramesetterAttrString*> TCFBase_NEW<CTFramesetterAttrString, __CFAttributedString const*&>(__CFAttributedString const*&) ()
#21	0x00000001b383a8c4 in CTFramesetterCreateWithAttributedString ()
#22	0x00000001017af9c0 in -[TTTAttributedLabel framesetter] at /Users/robin/Development/Awkward/beam/TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.m:407
#23	0x00000001017b7d30 in -[TTTAttributedLabel sizeThatFits:] at /Users/robin/Development/Awkward/beam/TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.m:1333
#24	0x00000001017b7efc in -[TTTAttributedLabel intrinsicContentSize] at /Users/robin/Development/Awkward/beam/TTTAttributedLabel/TTTAttributedLabel/TTTAttributedLabel.m:1350
#25	0x00000001b6fc80d4 in -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] ()
#26	0x00000001b6fc7dbc in -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] ()
#27	0x00000001b6fd19bc in -[UIView(AdditionalLayoutSupport) _updateSystemConstraints] ()
#28	0x00000001b6fd0750 in -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] ()
#29	0x00000001b6fd0c1c in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#30	0x00000001b6fd0b00 in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#31	0x00000001b2e6e06c in -[NSISEngine withBehaviors:performModifications:] ()
#32	0x00000001b6fd0e3c in -[UIView(AdditionalLayoutSupport) _recursiveUpdateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#33	0x00000001b6fd0b00 in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#34	0x00000001b6fd12f8 in __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke ()
#35	0x00000001b6fd0f30 in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] ()
#36	0x00000001b6fcb8bc in -[UIView(AdditionalLayoutSupport) _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] ()
#37	0x00000001b6d7f574 in -[UITableViewCell systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:] ()
#38	0x00000001b6df60d4 in -[UITableView _heightForCell:atIndexPath:] ()
#39	0x00000001b6dde428 in __53-[UITableView _configureCellForDisplay:forIndexPath:]_block_invoke ()
#40	0x00000001b7091e68 in +[UIView(Animation) performWithoutAnimation:] ()
#41	0x00000001b6ddd938 in -[UITableView _configureCellForDisplay:forIndexPath:] ()
#42	0x00000001b6deeca0 in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] ()
#43	0x00000001b6dbc2c4 in -[UITableView _updateVisibleCellsNow:] ()
#44	0x00000001b6dcf3dc in -[UITableView _visibleCellsUsingPresentationValues:] ()
#45	0x00000001009c6e84 in StreamViewController.updateGifPlayingState() at /Users/robin/Development/Awkward/beam/Beam/UI/Subreddits/Posts Stream/StreamViewController.swift:890
#46	0x00000001009df8d8 in StreamViewController.scrollViewDidScroll(_:) at /Users/robin/Development/Awkward/beam/Beam/UI/Subreddits/Posts Stream/StreamViewController.swift:913
#47	0x00000001009dfda4 in @objc StreamViewController.scrollViewDidScroll(_:) ()
#48	0x00000001b702fc60 in -[UIScrollView _notifyDidScroll] ()
#49	0x00000001b6dbcff8 in -[UITableView _notifyDidScroll] ()
#50	0x00000001b7019e70 in -[UIScrollView setContentOffset:] ()
#51	0x00000001b6ddbafc in -[UITableView setContentOffset:] ()
#52	0x00000001b70195a0 in _UIScrollViewAdjustForOverlayInsetsChangeIfNecessary ()
#53	0x00000001b7034a3c in -[UIScrollView setSafeAreaInsets:] ()
#54	0x00000001b65e4658 in -[UIViewController _updateViewSafeAreaInsetsAndEagerlyUpdateContentScrollView:] ()
#55	0x00000001b65e4d9c in -[UIViewController _setContentOverlayInsets:andLeftMargin:rightMargin:] ()
#56	0x00000001b65e674c in __121-[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:]_block_invoke ()
#57	0x00000001b65e6558 in -[UIViewController __updateContentOverlayInsetsWithOurRect:inBoundsOfAncestorViewController:viaImmediateChildOfAncestor:] ()
#58	0x00000001b65e57b0 in -[UIViewController _updateContentOverlayInsetsFromParentIfNecessary] ()
#59	0x00000001b65e5008 in -[UIViewController _updateContentOverlayInsetsForSelfAndChildren] ()
#60	0x00000001b65f1944 in -[UIViewController _updateLayoutForStatusBarAndInterfaceOrientation] ()
#61	0x00000001b65f64e4 in -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] ()
#62	0x00000001b70961a8 in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#63	0x00000001b7095f88 in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#64	0x00000001b708a334 in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke ()
#65	0x00000001b708a21c in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
#66	0x00000001b7098b24 in -[UIView(Internal) _addSubview:positioned:relativeTo:] ()
#67	0x00000001b7058c88 in -[UINavigationTransitionView transition:fromView:toView:] ()
#68	0x00000001b6562290 in -[UINavigationController _startTransition:fromViewController:toViewController:] ()
#69	0x00000001b65626f4 in -[UINavigationController _startDeferredTransitionIfNeeded:] ()
#70	0x00000001b6563a34 in -[UINavigationController __viewWillLayoutSubviews] ()
#71	0x00000001b6546eb8 in -[UILayoutContainerView layoutSubviews] ()
#72	0x00000001b709f3d0 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#73	0x00000001b96027dc in -[CALayer layoutSublayers] ()
#74	0x00000001b9608958 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#75	0x00000001b9613578 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#76	0x00000001b955bf1c in CA::Context::commit_transaction(CA::Transaction*, double) ()
#77	0x00000001b9585c08 in CA::Transaction::commit() ()
#78	0x00000001b6c32b08 in _afterCACommitHandler ()
#79	0x00000001b2b13e68 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#80	0x00000001b2b0ed54 in __CFRunLoopDoObservers ()
#81	0x00000001b2b0f320 in __CFRunLoopRun ()
#82	0x00000001b2b0eadc in CFRunLoopRunSpecific ()
#83	0x00000001bca94328 in GSEventRunModal ()
#84	0x00000001b6c09ae0 in UIApplicationMain ()
#85	0x00000001008897d8 in main at /Users/robin/Development/Awkward/beam/Beam/AppDelegate.swift:37
#86	0x00000001b2998360 in start ()
@robinspeijer robinspeijer self-assigned this Jan 8, 2020
@robinspeijer robinspeijer added this to the 2.7 milestone Jan 8, 2020
@robinspeijer
Copy link
Contributor Author

robinspeijer commented Jan 9, 2020

This problem has to do with an unexpected value for NSUnderlineStyleAttributeName in the NSAttributedString in TTTAttributedLabel. Instead of a number, it was assigned an empty array value. With NSUnderlineStyle being an optionset in Swift, it didn't raise any suspicion.

This should be fixed by #34

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

Successfully merging a pull request may close this issue.

1 participant