Modify button image/label/css VERY slow

, ,

Hello all,
Long story short I’m developing a touch interface in C which runs on a Raspberry Pi CM4 - not a supercomputer but more than powerful enough for this problem I would hope.

The interface is very simple - a grid of 50 buttons that get modified (label, image, colour, style) either individually or all together to display different functions.

However, the modification of the buttons takes a visibly loooong time, between 1-5ms per button per change - so if you modify the button image, button label and button CSS in one hit it can take a very long time (multiplied by 50 buttons) to update the screen.

I’ve done a fair bit of timestamping in the code and found that the gtk button/pixbuf functions are taking almost all of the time:

Call                             Time (ms) approximate
gtk_button_set_image             1ms
gtk_button_set_label             0.5
gdk_pixbuf_scale                 0.5 
gdk_pixbuf_new_subpixbuf         0.4
gtk_css_provider_load_from_data  0.3
gtk_image_new_from_pixbuf        0.15

So the question is - am I doing something wrong / missing something or is there a way to speed this up?

Even just stopping GTK from re-drawing anything while we’re updating all the buttons would be a visual improvement.

This code runs plenty quick enough on my Linux development machine, so I’m not ruling out that it’s some issue with the Pi - but I find it hard to believe a 4-core 1.5GHz machine with nothing else to do can’t re-draw a simple UI in a frame or two.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.