Re: A simple GtkSpinner is very costly in CPU cycles



On Wed, Mar 21, 2018 at 10:17 AM, Emmanuele Bassi <ebassi gmail com> wrote:

On 20 March 2018 at 14:06, Kian Karas <kian karas dev gmail com> wrote:

Hi smart people

I just introduced animation, in the form of a GtkSpinner, to my
application
for the first time. When the spinner is animating, the application takes
up
45 % of the CPU resources (the application is otherwise idle at 0-2,6 %).
The CPU is a single core ARM Cortex-A7 running at 528 MHz (maximum).

This seems like a lot of MIPS for rotating an image of approximately 20x20
px.


The rotation is performed through CSS, in order to be stylable by themes;
this means that the CSS state has to be invalidated in order to recompute
the next frame, and this is there the cost lies.

Of course, 45% is a pretty big chunk of a core, so it's indeed problematic
on single core, low performance devices. It's going to be the case for
every animation involving CSS, though, so you may elect to either disable
animations on your platform, or use a static placeholder image. There's
also the option of using a theme that does not have as many states for the
spinner animation, thus causing fewer invalidations.

I'm new to GTK (and CSS). Thus, I don't know the option you mention in
above last sentence. Do you know of a source where I can learn about doing
that? I mean, is there are tutorial touching on the spinner animation?

It's for an embedded system, so I do not need support for different themes.
Thus, unless I can figure out how to do above, I'll just make my own
progress indication using slower update of a GtkImage (cycling through
different images).

We are actively working to fix the issue on GTK 4, but changing the CSS
subsystem has the potential of breaking GTK 3 applications, so it's not on
the roadmap, outside of low impact optimizations.

Ciao,
 Emmanuele.

--
https://www.bassi.io
[@] ebassi [@gmail.com]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]