prolificinteractive / Caishen

A Payment Card UI & Validator for iOS
MIT License
766 stars 119 forks source link

Memory Leak and Crash #151

Open classic-chris opened 5 years ago

classic-chris commented 5 years ago

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.

retained_textfield

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:

crash_steps

Here is the sample project to reproduce: CaishenBug.zip

classic-chris commented 5 years ago

Pull request opened here addressing this issue.