UICollectionView with UIContextMenuInteraction and no UIMultiSelectInteraction causes main thread hang on long press

Number:rdar://FB9834734 Date Originated:06/01/2022
Status:Open Resolved:
Product:iOS - UIKit Product Version:15.0+
Classification: Reproducible:Yes
Due to FB9833896 (https://openradar.appspot.com/FB9833896), the only way to disable UICollectionView's one-finger band selection gesture is to manually remove UIMultiSelectInteraction from the list of enabled interactions of the collection view.

When the collection view delegate implements `contextMenuConfigurationForItemAt`, an UIContextMenuInteraction is added automatically to the collection view. When long pressing on any of its items, UIContextMenuInteraction often calls `UICollectionView.indexPathForItem(at:)` with a CGPoint that has `CGFLOAT_MAX` set as its coordinates. This causes the main thread to freeze/hang as the collection view is trying to find elements available in such a huge rectangle.

This seems to be caused by -[_UIClickPresentationInteraction locationInView:] erratically returning `(x: CGFLOAT_MAX, y: CGFLOAT_MAX)` as the touch point location. This seems to be caused by the fact that _UIClickPresentationInteraction has an `initialLocation` set to that point and the lack of an `activeDriver` in `_UIClickPresentationHandler` at the time of tapping.


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!