Re: gtk_main_iteration under broadway

I see. Sorry to ruffle your feathers :) Until now, I was under the
impression that this was the way things are done - as you note, it's
what's recommended to us evil Perl users. I've done some parts
threaded already, but I've found implementations on different
platforms ( eg Windows ) kinda temperamental. Anyway, thanks for the
response and explanation.


On Mon, Aug 1, 2016 at 7:16 PM, Emmanuele Bassi <ebassi gmail com> wrote:

On 29 July 2016 at 04:48, Daniel Kasak <d j kasak dk gmail com> 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
use cases.

 ... ( 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 []

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