Re: gtk_main_iteration under broadway
- Date: Mon, 1 Aug 2016 10:16:47 +0100
- From: Emmanuele Bassi <ebassi@xxxxxxxxx>
- Subject: Re: gtk_main_iteration under broadway
On 29 July 2016 at 04:48, Daniel Kasak <d.j.kasak.dk@xxxxxxxxx> wrote:
> Hi all.
> I've got some convenience functions that update a progress bar for long
> running operations. I do:
> Gtk3::main_iteration() while ( Gtk3::events_pending() );
Stop. I know this kind of behaviour is peddled and cargo culted on
gtk-perl-list because "hey, it works in my abominable 2500 lines
single file Perl program that I have to use for work and nobody will
ever bother to read or change", but it's a really stupid thing to do,
that goes against the design of GTK+.
Either you move your blocking code inside a thread and update the UI
using Glib::idle_add(), like any sensible person would; or you stop
using synchronous operations blocking the main loop, and then try to
"catch up" at the end so that your UI doesn't continuously lock up.
Those two functions are a crutch that expose design and implementation
issues in your code, or in the library code you're using. Stop hurting
The only reason why those two functions haven't been deprecated — and
I swear I'll deprecate them before we get into GTK+ 4 — is because
they were used in the test suite, i.e. for controlled, non-interactive
> ... ( in Perl ) after updating the progress bar, so that the window's
> contents are updated while my code continues to run. This works great in X
> and wayland. However in broadway, I quite often see CPU usage in broadwayd
> rise to 100%, and my application hang, immediately after the above line of
You're doing a busy loop.
> Is this known to be not safe under broadway?
That construct is known to be unsafe *everywhere*. The only reason why
you don't get into a busy loop just as often is that you're getting
another process involved (the X server on X11, the Wayland compositor
on Wayland) and that introduces a potential lag between the "events
pending" and the "main iteration" steps of the loop.
You're doing something broken. Stop doing it.
[@] ebassi [@gmail.com]
gtk-list mailing list