After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767136 - opening pdf results in a gtk-warning (How does the code know the size to allocate)
opening pdf results in a gtk-warning (How does the code know the size to allo...
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
3.20.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-06-02 07:05 UTC by OneStep
Modified: 2018-05-02 17:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ev-test.c (test program) (2.36 KB, text/x-csrc)
2017-02-11 18:57 UTC, Jason Crain
Details

Description OneStep 2016-06-02 07:05:19 UTC
xdg-open file.pdf results in the following warning in the terminal:

(evince:3240): Gtk-WARNING **: Allocating size to EvSidebar 0x564f7b84c330 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
Comment 1 kgizdov 2016-07-04 12:34:42 UTC
Just saw this error on my Arch x64 with Gnome 3.20. This also happens with `gvfs-open`.

I also want to add that this also happens when the document is opened from Nautilus or other UI programs. The resulting bad behaviour is that Evince is drawn incorrectly sometimes and buttons become unclickable until the window is manually resized.
Comment 2 Jason Crain 2017-02-11 18:46:37 UTC
I've tried to track down the source of this warning message and I think it's a bug in GTK.  It's something to do with the way evince hides the sidebar until a document is loaded.  The sidebar is implemented as a GtkPaned which contains a GtkScrolledWindow.  Hiding and showing the scrolled window this way causes the warning message.
Comment 3 Jason Crain 2017-02-11 18:57:57 UTC
Created attachment 345532 [details]
ev-test.c (test program)

The attached program basically reproduces what evince does.  It creates a window with a GtkPaned containing a GtkScrolledWindow and the scrolled window initially hidden.  A document loading in the background is simulated by g_idle_add.  The scrolled window is shown after "document loading" completes in the g_idle callback, and then the warning message is displayed.

This compiles with "gcc -o ev-test ev-test.c $(pkg-config --libs --cflags gtk+-3.0)".  I've tested with gtk 3.22.7 on Debian and with the git master; both produce the warning.
Comment 4 Timm Bäder 2017-02-11 19:58:26 UTC
GtkPaned calls gtk_paned_calc_position in its ::size-allocate implementation (gtk_paned_allocate), which eventually calls gtk_widget_set_child_visible on the now-visible first child, aka. priv->child1. In GtkScrolledWindow's ::realize implementation, it calls gtk_scrolled_window_sync_use_indicators, which then creates the indicators and adds them to the scrolledwindow, via gtk_widget_set_parent. That calls gtk_widget_queue_resize on the parent widget if both parent and child are visible.

I.e. this is the old "queue_resize during size-allocate" problem. For which we don't have a real solution. The  g_warning call should probably be in a #ifdef G_ENABLE_CONSISTENCY_CHECKS instead of just G_ENABLE_DEBUG.

Full backtrace of the offending queue_resize call:

  • #0 _g_log_abort.lto_priv.924
    at /home/baedert/Source/gnome/glib/glib/gmessages.c line 546
  • #1 g_log_writer_default
    at /home/baedert/Source/gnome/glib/glib/gmessages.c line 2613
  • #2 g_log_structured_array
    at /home/baedert/Source/gnome/glib/glib/gmessages.c line 1933
  • #3 g_log_structured
    at /home/baedert/Source/gnome/glib/glib/gmessages.c line 1760
  • #4 gtk_widget_queue_resize_internal
    at gtkwidget.c line 5133
  • #5 gtk_widget_queue_resize
    at gtkwidget.c line 5184
  • #6 gtk_widget_set_parent
    at gtkwidget.c line 8459
  • #7 setup_indicator
    at gtkscrolledwindow.c line 4097
  • #8 gtk_scrolled_window_sync_use_indicators
    at gtkscrolledwindow.c line 4167
  • #9 gtk_scrolled_window_realize
    at gtkscrolledwindow.c line 4226
  • #10 g_cclosure_marshal_VOID__VOIDv
    at /home/baedert/Source/gnome/glib/gobject/gmarshal.c line 905
  • #11 g_type_class_meta_marshalv
    at /home/baedert/Source/gnome/glib/gobject/gclosure.c line 1024
  • #12 _g_closure_invoke_va
    at /home/baedert/Source/gnome/glib/gobject/gclosure.c line 867
  • #13 g_signal_emit_valist
    at /home/baedert/Source/gnome/glib/gobject/gsignal.c line 3300
  • #14 g_signal_emit
    at /home/baedert/Source/gnome/glib/gobject/gsignal.c line 3447
  • #15 gtk_widget_realize
    at gtkwidget.c line 4858
  • #16 gtk_widget_map
    at gtkwidget.c line 4393
  • #17 gtk_widget_set_child_visible
    at gtkwidget.c line 9275
  • #18 gtk_paned_set_child_visible
    at gtkpaned.c line 1208
  • #19 gtk_paned_calc_position
    at gtkpaned.c line 2338
  • #20 gtk_paned_allocate
    at gtkpaned.c line 1301
  • #21 gtk_css_custom_gadget_allocate
    at gtkcsscustomgadget.c line 160
  • #22 gtk_css_gadget_allocate
    at gtkcssgadget.c line 784
  • #23 gtk_paned_size_allocate
    at gtkpaned.c line 1248
  • #24 gtk_widget_size_allocate_with_baseline
    at gtkwidget.c line 5492
  • #25 gtk_widget_size_allocate
    at gtkwidget.c line 5565
  • #26 gtk_window_size_allocate
    at gtkwindow.c line 7387
  • #27 gtk_application_window_real_size_allocate
    at gtkapplicationwindow.c line 626

(Rest of the bt omitted)
Comment 5 Daniel Boles 2017-07-06 17:25:05 UTC
(In reply to Timm Bäder from comment #4)
> I.e. this is the old "queue_resize during size-allocate" problem. For which
> we don't have a real solution. The  g_warning call should probably be in a
> #ifdef G_ENABLE_CONSISTENCY_CHECKS instead of just G_ENABLE_DEBUG.

Are most reports of this warning from benign use cases, rather than people getting things wrong?

If so, it would be nice not to have it yelling at me every time my program starts. :) Though I can't remember what the sequence was, need to do another bt, but IIRC I could not see anything actually wrong or any way around it in my case.
Comment 6 Timm Bäder 2017-07-06 18:13:27 UTC
(In reply to Daniel Boles from comment #5)
> (In reply to Timm Bäder from comment #4)
> > I.e. this is the old "queue_resize during size-allocate" problem. For which
> > we don't have a real solution. The  g_warning call should probably be in a
> > #ifdef G_ENABLE_CONSISTENCY_CHECKS instead of just G_ENABLE_DEBUG.
> 
> Are most reports of this warning from benign use cases, rather than people
> getting things wrong?

I don't have any statistical data on that of course, but I know a few cases where the warning is justified and causes actual problems.


> If so, it would be nice not to have it yelling at me every time my program
> starts. :) Though I can't remember what the sequence was, need to do another
> bt, but IIRC I could not see anything actually wrong or any way around it in
> my case.

Yes, it's done in quite a few widgets in gtk+.
Comment 7 Rick Richardson 2017-09-07 21:11:36 UTC
I do everything from the command line. There are about 30 terminals going.  I wish this could be cleaned up and no warnings emitted:


$ evince flutterby.pdf 

(evince:446): Gtk-WARNING **: Allocating size to EvSidebar 0x56278c8724f0 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
$
Comment 8 Egmont Koblinger 2018-02-10 22:27:05 UTC
(In reply to Timm Bäder from comment #4)

> The  g_warning call should probably be in a
> #ifdef G_ENABLE_CONSISTENCY_CHECKS instead of just G_ENABLE_DEBUG.

Yes, please! :)

See also bug 769566 comment 9 onwards for one particular case that erroneously leads to this warning. I don't know if Evince is also doing the same, or it's a different story.
Comment 9 Timm Bäder 2018-03-17 12:17:28 UTC
I've pushed https://gitlab.gnome.org/GNOME/gtk/commit/eb01ba8573bec47e02c8fc4eaf10e2f7cff522dd in the meantime.
Comment 10 GNOME Infrastructure Team 2018-05-02 17:12:19 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/632.