prolificinteractive / Caishen

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

Memory Leak and Crash with iOS17 #158

Open K-d-y opened 1 year ago

K-d-y commented 1 year ago

Similar problem to the one solved earlier. Playable only on iOS 17. When closing and deinit the screen where CardTextField is located - strong references to CardTextField remain, which leads to application crash.

If user touches CardTextField, enters card number, month, year and CVV, then closes the screen - CardTextField is not released from memory, causing a crash. When entering only the card number, sometimes the crash does not occur.

image

The CardTextField remains in memory because a strong reference to it is stored in the UIKeyboardImpl.

jigs4444 commented 11 months ago

Anyone who is looking for temporary solution , write didDisappear function in the viewcontroller where you are using this cardTextField

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        view.endEditing(true)
        view.subviews.forEach { view in
            guard let cardTextfield = view as? CardTextField {
                return
            }
            cardTextfield.removeFromSuperview()
        }
    }