Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve text rendering performance #990

Merged
merged 9 commits into from
Dec 23, 2021

Conversation

temper357
Copy link
Contributor

@temper357 temper357 commented Dec 16, 2021

Closes #970

优化点

  • 当容器的 overflow: hidden/clip 时,对容器内的文本按容器的内容尺寸进行截断,提升会溢出的长文本的渲染性能。
  • text 未设置 line-height 时 paragraph 不需要进行二次 layout,提升这种 case 下文本渲染性能。
  • 去除 KrakenRenderParagraph 中与 Flutter RichText 富文本有关的 PlaceholderSpan 相关无用逻辑。

性能数据

构造一个包含 3000 个字符的容器且样式为 overflow: hidden, whiteSpace: nowrap, backgroundColor: green的测试用例。

image

下表记录了优化前后一帧渲染总时间(包含 layout + paint)的 5 次数据的平均值:

渲染时间(ms)
优化前 5.136
优化后 0.840

优化后渲染总时间提升约 84%。

@temper357 temper357 changed the title [WIP] feat: improve text rendering performance feat: improve text rendering performance Dec 21, 2021
@andycall andycall merged commit d17f6fa into main Dec 23, 2021
@andycall andycall deleted the feat/improve-text-performance branch December 23, 2021 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

优化文本内容排版和绘制性能
3 participants