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

Drawing text outside canvas' bounds is expensive on the Web #48516

Closed
yjbanov opened this issue Jan 9, 2020 · 3 comments · Fixed by flutter/engine#17621
Closed

Drawing text outside canvas' bounds is expensive on the Web #48516

yjbanov opened this issue Jan 9, 2020 · 3 comments · Fixed by flutter/engine#17621
Assignees
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) c: rendering UI glitches reported at the engine/skia rendering level customer: webeap e: web_html HTML rendering backend for Web engine flutter/engine repository. See also e: labels. perf: energy Performance issues related to energy use (power, watts) perf: speed Performance issues related to (mostly rendering) speed platform-web Web applications specifically
Milestone

Comments

@yjbanov
Copy link
Contributor

yjbanov commented Jan 9, 2020

On the Web we draw all text in the picture irrespective of whether it is within the visible canvas bounds or not. A picture can contain a lot of text but clipped to a smaller scrollable region, which is typically at most no bigger than the screen (can be bigger in a windowed or multi-monitor situations but even there there's some upper bound).

This gets expensive quickly, particularly when text is rendered using HTML <p> tags. We have reports where scrolling a picture with lots of text costs hundreds of milliseconds per frame.

Solution

Since we layout text ahead of time we know the exact rectangle occupied by it. We also keep a transform and clip stack. We can use this information to determine whether the text is visible and skip drawing it if it's not.

@yjbanov yjbanov added engine flutter/engine repository. See also e: labels. c: performance Relates to speed or footprint issues (see "perf:" labels) platform-web Web applications specifically customer: webeap perf: speed Performance issues related to (mostly rendering) speed perf: energy Performance issues related to energy use (power, watts) e: web_html HTML rendering backend for Web labels Jan 9, 2020
@yjbanov yjbanov added this to the Near-term Goals milestone Jan 9, 2020
@yjbanov yjbanov added the c: rendering UI glitches reported at the engine/skia rendering level label Jan 9, 2020
@ferhatb
Copy link
Contributor

ferhatb commented Jan 9, 2020

Is there more info on structure? Is it a single picture or multiple?

@yjbanov
Copy link
Contributor Author

yjbanov commented Jan 9, 2020

Multiple pictures but each picture's bounds is orders of magnitude smaller than the amount of text content, and so drawing most of the text is wasteful.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) c: rendering UI glitches reported at the engine/skia rendering level customer: webeap e: web_html HTML rendering backend for Web engine flutter/engine repository. See also e: labels. perf: energy Performance issues related to energy use (power, watts) perf: speed Performance issues related to (mostly rendering) speed platform-web Web applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants