Drawing text outside canvas' bounds is expensive on the Web #48516
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
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.
The text was updated successfully, but these errors were encountered: