Trying to snapshot XYZ without a current allocation


How do I fix these warnings about trying to snapshot XYZ without a current allocation?

By what I read this is caused because while preparing to render the frame, some widget didn’t allocate its size. Is there’s something that I could do, some function I could call in the widget (AdwBin) triggering this warning to prevent this?

Besides the warning I get a wrong render too, i.e. the widget renders nothing, then I do the action again the it backs to normality.

I can try to port the code for a minimal reproducible example, but just asking first to known if there’s something that can be done once I know the actions I do to trigger the warning and what widget is triggering the warning.

P.S.: I’m not changing the UI in a different thread, just in a signal from an event controller.

It’s definitely not related to AdwBin - that widget is dead simple.

What’s the signal you’re using? That sounds like you invalidate allocation while or after the widget is already allocated.

There’s a GtkPaned with two GtkStack, one on each pane, when I call set_visible_child on one of the GtkStack’s I get this.

The signal I use is: “key_pressed” from a GtkEventControllerKey attached to the application window.

The project is in written in Crystal using the GTK4 bindings I’m writing, but I’ll take some time today or tomorrow to create a C minimal one-file example that reproduce the issue, since I can always reproduce it.

You probably want to use a shortcut instead of a key controller, but ok - while set_visible_child does invalidate allocation, this use should be fine.

A reproducer would help, yes.

I think it’s not possible to do what I want with shortcuts, the action I need works exactly like the Alt+Tab for changing between windows in gnome, but in my case is to change between open views and is Ctrl+Tab (that I know conflicts with default GTK Ctrl+Tab used to change focus).

Anyway, I’ll update this soon with a reproducible example.

Ah, I see. Ctrl+tab is problematic - AdwTabView in libadwaita has the same issue atm, as you usually want ctrl+tab for switching tabs but gtk grabs it. Makes sense then.

To give some context, the project is this one, that I’m porting to GTK4 using the new Crystal bindings since the GTK3 bindings for Crystal lack a lot of features and leaks memory.

The UI is like Tilix, made to work with split views and very easy to navigate between splits views (or at least I use it that way), but each split views have their own stack of documents opened. All this is already implemented in the GTK3 version, but as the GTK3 version had a lot of workarounds due to GTK3 bindings limitations and I’m now basically rewriting everything in the GTK4 port (that use the new bindings I’m creating too)

The code that show the issue is in a Tijolo branch, but doesn’t make sense ask anyone to download Crystal, etc… just to test and help me… so instead of spending time writing this I should had writing the minimal C code example :stuck_out_tongue:

Initially I failed to reproduce the issue in the minimal C version, but then I realized that I missed one thing from the minimal example… so I went into the main code, commented out the part I didn’t add on minimal example and the warning dissapear :tada:


  • The AdwBin really have nothing to do with this as expected, but one of its (gran)children.
  • I have a overlay on top of all the GtkPaned and GtkStack, this overlay is used to show a widget listing the available views (like Alt+Tab on desktop).
  • The overlay widget is a GtkBox with a GtkTreeView.

At the first key press event I do:

  • Clear and repopulate the model used by the GtkTreeView
  • Set the GtkBox (parent of the GtkTreeView) as visible, in this order.

So I think the GtkTreeView doesn’t proper allocate its size, I also noticed that if I set “headers-visible” property of GtkTreeView to false it get’s the dimensions of 0x0 pixels and is not rendered at all.

The GtkTreeView have a single column, a GtkTreeViewColumn with "sizing" property set to "autosize".

So the question is:

How to have a GtkTreeview with auto size columns centered in a overlay?

Is there a way to tell, "Hey GtkTreeView, I updated your models, could you please compute your size? or something?

After I removed the overlays the warning didn’t show anymore. Is there any problem in updating the UI during key event propagation?