UITextFieldDelegate inconsistent behaviour

Originator:alex
Number:rdar://35348940 Date Originated:2017-11-04
Status:Open Resolved:
Product:iOS SDK Product Version:11
Classification:Bug Reproducible:Yes
 
Summary:

In the iOS 11 SDK, the `textFieldDidBeginEditing` delegate method seems to perform inconsistently, which can cause UI components to become unresponsive.

In Time Profiler, `didBecomeFirstResponder` can take up a disproportionately large amount of CPU time causing apps to become unresponsive.

The attached project has a UITextFieldDelegate calling `textField.selectAll` within `textFieldDidBeginEditing`. There may be similar inconsistent behaviour when calling other methods within `textFieldDidBeginEditing`, but `selectAll` seems to demonstrate this most clearly and consistently. 

The project has two UITextField components for ease of demonstration — the same issue would be seen with just one UITextField component, and a UIButton to call `resignFirstResponder`. The issue will still occur if selection actions are disabled with `canPerformActions`.

Steps to Reproduce:
1. Build and run project (Simulator or Device).
2. Alternate taps between two UITextField components - Text A and Text B.

Expected Results:
On every tap, the full text of each component is selected.

Actual Results:
1. On the first (and every odd) tap of a text field, all text is selected, as expected.
2. On the second (and every even) tap of that text field, all text is selected briefly, before being deselected.
3. About 1 in 5 taps, selection will completely fail as the text field has become temporarily unresponsive.

Version/Build:
iOS 11 SDK
Confirmed on iOS 9.3 - iOS 11.1 using Simulator
Confirmed on iOS 11.0 - iOS 11.2 Beta 1 using iPhone 6 Plus, iPhone SE

Configuration:
Xcode 9.1, 9.2 Beta 1

Comments

I've also created a bug for this in Apples Bug Reporter: 37235692

I am experiencing the exact same behaviour on iOS 11.2.5 (Xcode 9.2 (9C40b)).

Have you found a workaround yet?

Unfortunately we haven't.

Attached project: https://github.com/strongapp/Radars/tree/master/35348940


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!