During fast and continuous text input my fps drop down to ~zero (iPhone5S).
I've tracked down bottleneck in AnimatedTextField.swift:
@objc fileprivate func textFieldDidChange() {
if let text = text {
var cursorPosition: Int?
if let selectedRange = self.selectedTextRange {
cursorPosition = self.offset(from: self.beginningOfDocument, to: selectedRange.start)
}
attributedText = NSAttributedString(string: text, attributes: textAttributes)
if let cursorPosition = cursorPosition, let newPosition = self.position(from: self.beginningOfDocument, offset: cursorPosition) {
self.selectedTextRange = self.textRange(from: newPosition, to: newPosition)
}
}
textInputDelegate?.textInputDidChange(textInput: self)
}
During fast and continuous text input my fps drop down to ~zero (iPhone5S). I've tracked down bottleneck in AnimatedTextField.swift:
I reduced code to:
and there is no any visual changes for text, but freezes are gone.
Could you please verify if this part of code doing anything necessary?