SwiftUI gestures break when contained in a UIHostingController that had a layout pass in a UIKit animated transition

Number:rdar://FB11354058 Date Originated:08/23/2022
Status:Open Resolved:Open
Product:SwiftUI Framework Product Version:iOS 15/16
Classification:Application Slow/Unresponsive Reproducible:Yes
When a newly instantiated UIHostingController is animated as part of a UIViewControllerAnimatedTransitioning within a UINavigationController that has a call to view.layoutIfNeeded() on the UIHostingController's view, SwiftUI gestures strop being processed, resulting in an unresponsive application. 

Notably, gestures for embedded UIKit UIViews are still processed correctly; the only gestures that break are those implemented in SwiftUI, e.g. the tap gesture of a Button. There is an attached project that minimally reproduces this issue. 

This issue reproduces on iOS 15 and iOS 16 Beta 6.

From poking around under the hood, it appears that when this occurs the `SwiftUI.EventBindingManager` never goes into the `isActive = true` state when the touches begin, and the `SwiftUI.UIKitGestureRecognizer` does not transition to the `ended` state on `UIGestureRecognizer.touchesEnded(…)`. A mitigation for this behavior is removing and re-adding the UIHostingController's view to the view hierarchy.


Here is an example project that reproduces the issue https://github.com/erichoracek/BrokenGesturesFeedback

By eric.horacek at Aug. 23, 2022, 11:38 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!