WIP/discussion: Pre-render clipped texts#6233
WIP/discussion: Pre-render clipped texts#6233MaxGyver83 wants to merge 3 commits intofyne-io:developfrom
Conversation
|
This same discussion could be applied to List/Table etc with similar reuse dynamics. However I'm not convinced it will make a difference...if you have 5 visible rows and want to scroll past 20 we currently: Render 5 and then 20 as we scroll. If you render the next one as well it becomes: Render 6 and then 20 as we scroll. So I'm not sure it resolves the issue you describe. |
|
I see. I have pushed a better solution: The new commit adds a low priority queue. After the first paint event, a new function checks for all text objects if they are clipped and not yet cached. If so, they are pushed to the low priority queue. Then, when the process idles, it pre-renders texts from the queue. This results in quite smooth scrolling. (Probably, pre-rendering finishes faster in combination with #6236.)
What do you think about this? Is it too complicated? If you think it's useful, it probably can be further improved:
|
|
This is a very compelling improvement now. |
@andydotxyz , @redawl: This is how it looks on the develop branch, currently:
|
|
Now, $ average DrawStringFiltered.log
717 numbers, average: 1661.3585285913528 µs |
Add a new low-priority queue for functions and push the pre-rendering of clipped texts to this queue (only once). Process queue when idle.
7f86e45 to
5beb1b7
Compare
|
IMO this is a lot of complexity, while we know there is still room to improve raw performance |



Description:
Dragging (scrolling) isn't smooth in Fyne apps with a lot of text on Android.
I have visualized how long
*driver.handlePaintcalls take while dragging up a large RichText widget (generated from about 35 kB of Markdown). Test app: https://gist.github.com/MaxGyver83/1022b44649df8ac4b69dce6a352f0e28The green areas show when my finger touches the screen (for dragging).
When new lines become visible,
painter.DrawStringis called for every new line and takes about 6 ms per line. A paint call shouldn't take more than 16 ms. Thus, with 3 new lines this goal can't be reached and dragging begins to stutter. (Dragging back in the other direction works better because then all texts are already cached.)It would be cool if we could speed up
DrawStringitself. But I don't know how.My next best idea is to pre-render (=draw strings into textures) during idle times. This PR tries to do this. When text is below the clip area (but not to far away),
p.createTextTextureis called which check if the text is already cached, and if not, it creates such a texture usingfyne.Do. AFAIU, this happens between*driver.handlePaintcalls when there is some free time left, reading fromd.queudFuncs.Out():Unfortunately, this fix doesn't work as expected. Dragging feels different now but still not good.
Here is a visualization:
Do you have any ideas how this could be improved (or what to try instead)?
(This PR is work-in-progress and mainly for discussion.)
Checklist:
Where applicable: