ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.86k stars 1.7k forks source link

Performance optimization for long text input #16

Open matthewyan opened 8 years ago

matthewyan commented 8 years ago

文本超过5K,输入文字就比较卡

  1. 输入响应很慢
  2. 光标跟输入位置对应不起来,有时候甚至看不到输入的内容在哪
ibireme commented 8 years ago

这个控件没有实现局部刷新,所以目前只适用于少量文本的输入和展示,不适用于大量文本的输入、大量富文本的编辑。 这个稍后我会在 readme 里更新说明。

matthewyan commented 8 years ago

富文本的编辑对长文本的需求应该还是比较大的 :)

ibireme commented 8 years ago

如果可能,在以后会尝试进行优化吧。

chrisze commented 8 years ago

Hi Yaoyuan,

Just came across your awesome library. I would like to second that support for long text input would be great. Today if I add about 32 KB of text, the app ends up using over 200 MB of memory, and things slow down dramatically (sometimes text starts to disappear and XPC warnings come up in the console). I don't know much about CoreText, but is there some fundamental architectural reason why supporting large documents is particularly difficult? What kind of changes would be needed to add support for it in YYTextView?

I know Apple struggled with it themselves when they've re-written UITextView on top of TextKit in iOS 7. At the time, UITextView would consume just as much memory, but they seem to have fixed it in iOS 8 and above.

Best Regards, -Christoph

ibireme commented 8 years ago

It needs to split and cache text and text layout results, text view's contents needs to be split and draw with the mechanism similar to UITableView. I may need to rewrite the entire text view to implement these features.

Lessica commented 8 years ago

长文本的编辑可能用 TableView 会比较好一点…… 比如锤子便签和 WeicoNote。

HePingLaoSan commented 7 years ago

长文本确实会有性能问题。。。