Hang when opening share sheet

When I compile my app with Xcode 14, the app fails to open share sheets. The app just hangs on the call to present( the UIActivityViewController, and eventually crashes with a memory error.

I do not see this behavior when I compile with Xcode 13.4, or if I run the app on an iOS 15 device. It is just when compiled with Xcode 14 and run on an iOS 16 device.

I tried creating a dedicated view controller with nothing other than a button letting the user present a share sheet. I stripped out everything in the view controller and app delegate other than what is needed to show that view controller. I still see the behavior. But I do not see this when I create a standalone app.

I am looking for differences in build settings and Info.plist that might trigger this. Is there something else I should look for?

This is the main thread while the app is hung, before it just crashes:

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x000000019f4f0378 in -[UIButtonLegacyVisualProvider updateConstraints] ()
#1	0x000000019f4f02f8 in -[UIButton updateConstraints] ()
#2	0x000000019f4778bc in -[UIView(AdditionalLayoutSupport) _sendUpdateConstraintsIfNecessaryForSecondPass:] ()
#3	0x000000019f47767c in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#4	0x000000019f477598 in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] ()
#5	0x00000001b7e685d8 in -[NSISEngine withBehaviors:performModifications:] ()
#6	0x000000019f477378 in __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke ()
#7	0x000000019f41e204 in -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] ()
#8	0x000000019f41def4 in -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] ()
#9	0x000000019f4549ec in -[UIView(AdditionalLayoutSupport) _systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:hasIntentionallyCollapsedHeight:] ()
#10	0x000000019f94e6c0 in -[_UIButtonBarItemLayout minimumLayoutWidthGivenMinimumSpaceWidth:] ()
#11	0x000000019f94ed70 in -[_UIButtonBarItemGroupLayout recalculateLayoutWidthsGivenItemSpaceWidth:] ()
#12	0x000000019f9476c0 in -[_UIButtonBar _widthInfoForLayout:] ()
#13	0x000000019f988330 in -[_UINavigationBarContentViewLayout _buttonBarLayoutInfo] ()
#14	0x000000019f98868c in -[_UINavigationBarContentViewLayout layoutSubviews] ()
#15	0x000000019f398414 in -[_UINavigationBarContentView layoutSubviews] ()
#16	0x000000019f395a58 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#17	0x000000019e8baa60 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#18	0x000000019f45a94c in -[UIView(Hierarchy) layoutBelowIfNeeded] ()
#19	0x000000019f52595c in -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] ()
#20	0x000000019f5256a8 in -[UINavigationController _positionNavigationBarHidden:edge:] ()
#21	0x000000019f5254c0 in -[UINavigationController __viewWillLayoutSubviews] ()
#22	0x000000019f5253f4 in -[UILayoutContainerView layoutSubviews] ()
#23	0x000000019f395a58 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#24	0x000000019e8baa60 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#25	0x000000019f45a94c in -[UIView(Hierarchy) layoutBelowIfNeeded] ()
#26	0x000000019f45a81c in -[UISheetPresentationController _sheetLayoutInfoLayout:] ()
#27	0x000000019f458600 in -[_UISheetLayoutInfo _layout] ()
#28	0x00000001a015e080 in __54-[UISheetPresentationController _transitionWillBegin:]_block_invoke_3 ()
#29	0x000000019f3c0478 in +[UIView(Animation) performWithoutAnimation:] ()
#30	0x000000019f6c1c08 in __54-[UISheetPresentationController _transitionWillBegin:]_block_invoke_2 ()
#31	0x000000019f6b4af4 in -[_UIViewControllerTransitionCoordinator _applyBlocks:releaseBlocks:] ()
#32	0x000000019f6b49d8 in -[_UIViewControllerTransitionContext __runAlongsideAnimations] ()
#33	0x000000019f6b48e8 in __63+[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:]_block_invoke ()
#34	0x000000019f45a45c in -[UIViewAnimationState _runAlongsideAnimations] ()
#35	0x000000019f459280 in -[UIViewAnimationState pop] ()
#36	0x000000019f458d3c in +[UIViewAnimationState popAnimationState] ()
#37	0x000000019f458b48 in +[UIView _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] ()
#38	0x000000019f42ddd4 in +[UIView(UIViewAnimationWithBlocks) animateWithDuration:delay:options:animations:completion:] ()
#39	0x000000019f80554c in __50-[UITransitionView _startTransition:withDuration:]_block_invoke_2 ()
#40	0x000000019f4d212c in +[UIView(UIViewAnimationWithBlocks) conditionallyAnimate:withAnimation:layout:completion:] ()
#41	0x000000019f62b14c in -[UITransitionView _startTransition:withDuration:] ()
#42	0x000000019f628e7c in -[UITransitionView transition:fromView:toView:removeFromView:] ()
#43	0x000000019f628054 in -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] ()
#44	0x000000019fb199f8 in ___UIViewControllerTransitioningRunCustomTransition_block_invoke_3 ()
#45	0x000000019f57f664 in +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:] ()
#46	0x000000019f627b40 in ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2 ()
#47	0x000000019f571e9c in +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:] ()
#48	0x000000019f571d7c in _UIViewControllerTransitioningRunCustomTransition ()
#49	0x000000019fa8e6b8 in __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 ()
#50	0x000000019f522f30 in -[_UIAfterCACommitBlock run] ()
#51	0x000000019f522e6c in -[_UIAfterCACommitQueue flush] ()
#52	0x00000001045e808c in _dispatch_call_block_and_release ()
#53	0x00000001045e98c4 in _dispatch_client_callout ()
#54	0x00000001045f8428 in _dispatch_main_queue_drain ()
#55	0x00000001045f8080 in _dispatch_main_queue_callback_4CF ()
#56	0x000000019853cac8 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#57	0x0000000198520754 in __CFRunLoopRun ()
#58	0x0000000198524dfc in CFRunLoopRunSpecific ()
#59	0x00000001d23da984 in GSEventRunModal ()
#60	0x000000019f707e7c in -[UIApplication _run] ()
#61	0x000000019f707af4 in UIApplicationMain ()
#62	0x00000001027e9604 in main at /Users/jbrayton/Documents/Unread/working/App/Unread/Supporting Files/main.m:14
#63	0x00000001b9be2de0 in start ()

What is the reason for the crash as found in the crash report?

The crash report said the reason was running out of memory. The app's memory usage would climb by roughly 30MB/second until the app crashed.

I since figured out the source of the problem. I had an Objective-C extension on UIColor that implemented secondaryLabelColor. I do not know why that had the effect it did on share sheets, but removing that extension method fixed it.

Thank you for replying!

John

We're seeing something very similar in our app; still trying to run it down.

John, how on earth did you figure out that your UIColor extension was triggering this behavior? :P

After I was still seeing the behavior when just creating an App Delegate, Scene Delegate, and View Controller that did just about nothing else, I deleted all other code in the app. I could then see the problem was gone. I then put a breakpoint in every method with a dispatch_once_t call. That led me to where my code was being called that I did not expect.

I hope this is somehow helpful, @SeanMcMains!

John

Hang when opening share sheet
 
 
Q