Gtk4 widgets dissappear/appear at random on X11

I experience an strange issue with a gtk4 panned window, where one pane contents is at random disappearing and showing again when moving the pane divider, updating anything (typing into a entry) or adjusting the window size.

I noted this seams only to happen on X11 and not when running the app on Wayland.

See this screen shot video as an illustration:

Hi,

Would be nice to provide a minimal reproducible example, so we can investigate.

Hi, thanks for your suggestion. I may try….

I could provide a trivial example window (canvas left, notebook right), but likely not happening then as in a trivial context. And not sure how much of actions/updates I need to add to reproduce it…

But I do see a ton of those mysterious “trying to snapshot GtkNotebook 0x… without a current allocation” Warnings. What is that meaning, sounds like some bogus data management?!?

Happens at random when anything if been forced to be refreshed as of changes. (from gtk main, but triggered by other GUI callbacks)

On Wayland it only gets blanc briefly but comes back I noted.

Never had any issue with Gtk3 with the same context and program “logic”.

Ah, could be indeed part of the issue. Are you using a custom widget?

The drawing sequence was deeply reworked between gtk3 and gtk4: now there is a measure step, then an allocate, and finally an asynchronous snapshot.

Have you manually implemented one or all of these virtual methods?
Do you emit any of the queue_resize, queue_allocate or queue_draw events?

One possible problem is that a size change got notified between the last “allocate” step and before the “snapshot” step.

Yes one: I use queue_draw for elements within my canvas/drawing area when they need to move/update or change. And for example a change of a value on “left side” will trigger a redraw or queue_draw to refresh the image for example.


Solution:

I found out what caused this…

a) when I did not run my GtkDrawingAreaDrawFunc (or skipped it) the issue did NOT occur any more.

For a test I put this bail out code into it, so after 20 updated it stops do anything and no weird behavior any more:

    static int once=0;
    if (++once > 20) return;
    g_message("CDF #%d", once);

b) I realized I did triggered from within my drawing_function also the update of few gtk_entries what caused to call gtk_entry_set_text()…. this seamed to be not a good idea to do any more!

c) Instead I safe guarded/delayed this action via “only” issuing a g_idle_add to do that task when ever is possible later:

            g_idle_add (GSourceFunc(update_view_panel_idle_callback), this);

And this fixed the strange behavior!

1 Like

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