UPDATE: Appears to be fixed in iOS 15.2 beta 3!
On iOS 15+, modifying the appearance of the navigation bar, including modifying a view controller's navigationItem
, will append redundant UIGestureRecognizer
s to the Back button. When the number of gesture recognizers gets into the thousands, tapping on the Back button can lock up the main thread for many seconds, which can result in the application being killed by the watchdog timer.
- Run this project on an iOS 15 device or simulator.
- Tap the "Go" button to advance to the test view controller.
- Tap the "Change Title 100 Times" button and the "Change Right Bar Item 100 Times" button many times.
- (Optional) Tap the "Print Gesture Recognizers to Console" to see the myriad duplicate gesture recognizers in Xcode debug out.
- Tap the "Back" button
- Gesture recognizer count remaining stable. Back button responsive. (This is what happens if you run the project on iOS 14.)
- Gesture recognizer count climbs continuously on each change. If the total number is high enough (thousands), the Back button responds very slowly.
- Reproduced on iOS 15.1 as well as iOS 15.2 beta.