Does the Fyne library redraw all the controls in the container entirely, even if only one button is clicked? #5562
-
I have a machine on an arm64 platform, and the touchscreen it uses and doesn't have a GPU accelerator. I placed 10 buttons with icons and a label in the container of the main screen to display the value of the clicked button, and I found that there was a significant delay. Later, my test revealed that clicking on a certain button would cause all the controls within the entire container to be redrawn. Since an IconButton has at least one icon image and two rectangles to be drawn, it results in at least more than 30 elements to be drawn. Moreover, when the button shows the hover effect and updates the label, it triggers the redrawing of the entire container twice, leading to a large delay. Later, I conducted a simple test and confirmed that when one of the two buttons is clicked, the container containing the label and the two buttons will be redrawn in its entirety. Why isn't it a local redrawing of a single button? Or am I using it incorrectly? Could everyone give me some suggestions? Thank you. The code is as follows: import ( func main() {
}
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
No, Fyne will only draw what has changed. I think your debug lines have been inserted before the change check. You'll see that there is a texture cache which is used until an item updates. If anything on screen changes then we do have to construct a new frame from all of the caches objects. |
Beta Was this translation helpful? Give feedback.
-
@andydotxyz The above is the debug output I added. Every time a button is clicked, four text and eight rectangles are drawn (there are four buttons in total), and all of them enter the DrawArrays stage. That is to say, OpenGL is notified to draw the vertex array, instead of only drawing the button that was clicked. Is it that which specific control is updated is finally completed in the OpenGL stage? |
Beta Was this translation helpful? Give feedback.
-
Ah I see - there is ambiguity in the word draw sorry. There are two stages to get something from code onto the screen with our drivers:
What your debug is showing you is that 2 happens on every changed frame for all items on screen. So what you are seeing as "always drawing" is really just blitting items to the screen which is fast and skipping all the slow parts. |
Beta Was this translation helpful? Give feedback.
-
@andydotxyz My current question is still: Why is it that when I only click on button1 in the first step of the calculation, all four buttons need to be updated instead of just button1 being updated and redrawn? This ultimately leads to the redrawing of all four buttons in the second step, even though OpenGL rendering is quite fast. |
Beta Was this translation helpful? Give feedback.
This is not correct - though as above it depends on your definition of redrawn.
We cache everything after it is drawn so that this can be avoided. What has changed will be redrawn but the rest will remain in cache. This is all then sent to the GPU for the next frame.
There is no "partial frame" so every update is a complete blit to the screen, but as I said before this part is very fast.
On a button tap there are not only 2 refreshes - there are more like 18 as we have a tap animation on the button UI. You can disable that with a build tag as at https://docs.fyne.io/explore/c…