If the user taps the CardTextField and then pops back from the view controller the expectation is that the CardTextField will be removed from memory because the view controller (or storyboard) should have held the only strong reference to the text field.
Instead the CardTextField remains in memory because a strong reference is retained by the UIKeyboardImpl.
The only way to release this is for the user to tap a different text field which causes the UIKeyboardImpl to release its reference to CardTextField.
This leak can cause a crash if the user inputs their card number and their expiry month, then taps backspace until the month is cleared but the cursor is still in the month field. Then pop back on the navigation controller, re-enter the screen with the CardTextField and tap in the text field. See the gif below for the exact steps to reproduce:
If the user taps the CardTextField and then pops back from the view controller the expectation is that the CardTextField will be removed from memory because the view controller (or storyboard) should have held the only strong reference to the text field.
Instead the CardTextField remains in memory because a strong reference is retained by the UIKeyboardImpl.
The only way to release this is for the user to tap a different text field which causes the UIKeyboardImpl to release its reference to CardTextField.
This leak can cause a crash if the user inputs their card number and their expiry month, then taps backspace until the month is cleared but the cursor is still in the month field. Then pop back on the navigation controller, re-enter the screen with the CardTextField and tap in the text field. See the gif below for the exact steps to reproduce:
Here is the sample project to reproduce: CaishenBug.zip