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

Some debug methods / asserts cause issues when triggered off the main thread. #240

Closed
appleguy opened this issue May 5, 2017 · 4 comments

Comments

@appleguy
Copy link
Member

appleguy commented May 5, 2017

For example, the layout warning in calculateSizeThatFits can trigger a crash for an unrelated reason to what it is trying to inform the user about:

2017-05-04 22:17:03.174 Sample[88326:3536944] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method must be called on the main thread'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010afc8b0b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010a6bd141 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010afcccf2 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x0000000107d5d3b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   Sample                              0x000000010779cf88 -[ASDisplayNode view] + 920
	5   Sample                              0x000000010779d256 -[ASDisplayNode layer] + 198
	6   Sample                              0x00000001077cdc14 ASDisplayNodeFindFirstSupernode + 84
	7   Sample                              0x00000001077cde07 ASDisplayNodeFindFirstSupernodeOfClass + 119
	8   Sample                              0x00000001077c1d6a -[ASDisplayNode propertiesForDebugDescription] + 5594
	9   Sample                              0x00000001077c2c46 -[ASDisplayNode debugDescription] + 54
	10  Sample                              0x00000001077c5079 -[ASDisplayNode(Debugging) _recursiveDescriptionHelperWithIndent:] + 105
	11  Sample                              0x00000001077c5005 -[ASDisplayNode(Debugging) displayNodeRecursiveDescription] + 53
	12  Sample                              0x00000001077a1ac3 -[ASDisplayNode calculateSizeThatFits:] + 835
	13  Sample                              0x00000001077a072e -[ASDisplayNode calculateLayoutThatFits:] + 958
	14  Sample                              0x00000001077a01b1 -[ASDisplayNode calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 577
	15  Sample                              0x00000001077c413f -[ASDisplayNode(ASLayoutElement) layoutThatFits:parentSize:] + 2511
	16  Sample                              0x0000000107868648 _ZL16crossChildLayoutRK22ASStackLayoutSpecChildRK22ASStackLayoutSpecStyledddd6CGSize + 440
	17  Sample                              0x000000010786845d ___ZL43layoutItemsAlongUnconstrainedStackDimensionRNSt3__16vectorI21ASStackLayoutSpecItemNS_9allocatorIS1_EEEERK22ASStackLayoutSpecStylebRK11ASSizeRange6CGSizeb_block_invoke + 557
	18  Sample                              0x0000000107868155 _ZL21dispatchApplyIfNeededmbU13block_pointerFvmE + 181
	19  Sample                              0x0000000107864a83 _ZL43layoutItemsAlongUnconstrainedStackDimensionRNSt3__16vectorI21ASStackLayoutSpecItemNS_9allocatorIS1_EEEERK22ASStackLayoutSpecStylebRK11ASSizeRange6CGSizeb + 371
	20  Sample                              0x0000000107863c62 _ZN25ASStackUnpositionedLayout7computeERKNSt3__16vectorI22ASStackLayoutSpecChildNS0_9allocatorIS2_EEEERK22ASStackLayoutSpecStyleRK11ASSizeRangeb + 738
	21  Sample                              0x000000010785d79a -[ASStackLayoutSpec calculateLayoutThatFits:] + 522
	22  Sample                              0x000000010780d40f -[ASLayoutSpec calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 463
	23  Sample                              0x000000010780d1b4 -[ASLayoutSpec layoutThatFits:parentSize:] + 356
	24  Sample                              0x00000001077ed120 -[ASInsetLayoutSpec calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 1920
	25  Sample                              0x000000010780d1b4 -[ASLayoutSpec layoutThatFits:parentSize:] + 356
	26  Sample                              0x000000010780cfb9 -[ASLayoutSpec layoutThatFits:] + 137
	27  Sample                              0x00000001077a1074 -[ASDisplayNode calculateLayoutThatFits:] + 3332
	28  Sample                              0x00000001077a01b1 -[ASDisplayNode calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 577
	29  Sample                              0x00000001077c413f -[ASDisplayNode(ASLayoutElement) layoutThatFits:parentSize:] + 2511
	30  Sample                              0x00000001077c3769 -[ASDisplayNode(ASLayoutElement) measureWithSizeRange:] + 137
	31  Sample                              0x00000001077c36cf -[ASDisplayNode(ASLayoutElement) layoutThatFits:] + 111
	32  Sample                              0x0000000107769a9a -[ASDataController _layoutNode:withConstrainedSize:] + 938
	33  Sample                              0x000000010776aa9b __57-[ASDataController _allocateNodesFromElements:andLayout:]_block_invoke + 1211
	34  Sample                              0x0000000107775700 ___ZL15ASDispatchApplymPU28objcproto17OS_dispatch_queue8NSObjectmU13block_pointerFvmE_block_invoke + 80
	35  libdispatch.dylib                   0x000000010c39c4a6 _dispatch_call_block_and_release + 12
	36  libdispatch.dylib                   0x000000010c3c505c _dispatch_client_callout + 8
	37  libdispatch.dylib                   0x000000010c3a4f58 _dispatch_queue_override_invoke + 1716
	38  libdispatch.dylib                   0x000000010c3a6ec4 _dispatch_root_queue_drain + 634
	39  libdispatch.dylib                   0x000000010c3a6bef _dispatch_worker_thread3 + 123
	40  libsystem_pthread.dylib             0x000000010c75c616 _pthread_wqthread + 1299
	41  libsystem_pthread.dylib             0x000000010c75c0f1 start_wqthread + 13

@appleguy
Copy link
Member Author

appleguy commented May 5, 2017

Here's an additional / different backtrace causing this issue:

2017-05-05 14:02:52.387 Sample[2125:46778] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This method must be called on the main thread'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010fa35b0b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x000000010f131141 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010fa39cf2 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010c73b3b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   Sample                              0x000000010c22ce53 -[ASResponderChainEnumerator initWithResponder:] + 275
	5   Sample                              0x000000010c22d13f -[UIResponder(ASResponderChainEnumerator) asdk_responderChainEnumerator] + 63
	6   Sample                              0x000000010c19e8f8 -[ASDisplayNode propertiesForDebugDescription] + 1384
	7   Sample                              0x000000010c1a0876 -[ASDisplayNode debugDescription] + 54
	8   Sample                              0x000000010c1a2ca9 -[ASDisplayNode(Debugging) _recursiveDescriptionHelperWithIndent:] + 105
	9   Sample                              0x000000010c1a2c35 -[ASDisplayNode(Debugging) displayNodeRecursiveDescription] + 53
	10  Sample                              0x000000010c17f6c3 -[ASDisplayNode calculateSizeThatFits:] + 835
	11  Sample                              0x000000010c17e32e -[ASDisplayNode calculateLayoutThatFits:] + 958
	12  Sample                              0x000000010c17ddb1 -[ASDisplayNode calculateLayoutThatFits:restrictedToSize:relativeToParentSize:] + 577
	13  Sample                              0x000000010c1a1d6f -[ASDisplayNode(ASLayoutElement) layoutThatFits:parentSize:] + 2511
	14  Sample                              0x000000010c246568 _ZL16crossChildLayoutRK22ASStackLayoutSpecChildRK22ASStackLayoutSpecStyledddd6CGSize + 440

@maicki
Copy link
Contributor

maicki commented May 17, 2017

@appleguy I think this is fixed with #246 now right?

@Adlai-Holler
Copy link
Member

I believe so. @appleguy Feel free to reopen if needed.

@appleguy
Copy link
Member Author

appleguy commented Jul 27, 2017 via email

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

No branches or pull requests

3 participants