Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 436655

Summary: [GTK3] Layout problem makes a group invisible
Product: [Eclipse Project] Platform Reporter: Marc-André Laperle <malaperle>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: akurtakov, bernd.hufmann, ericwill
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugzilla.gnome.org/show_bug.cgi?id=662915
https://git.eclipse.org/r/#/c/55819/
Whiteboard:
Bug Depends on:    
Bug Blocks: 441566, 474628    
Attachments:
Description Flags
Code snippet
none
Spelling preferences GTK3
none
gtk frame patch none

Description Marc-André Laperle CLA 2014-06-05 01:52:57 EDT
Using Eclipse 4.4 I20140603-2300
Ubuntu 12.04 with GTK 3.4.2 and Ubuntu 14.04 using GTK 3.10.8 (SWT_GTK3=1)

I am attaching a code snippet but here is the summary of what the code does:
1. Have a Shell with a composite containing two groups on top of each other with a tree in the bottom one.
2. Explicitly call layout() on the composite
3. The bottom group is not displayed with GTK3 but works with GTK2.

When the shell is resized, it gets drawn properly. If the call to layout() is removed, it is drawn properly with both GTK2 and GTK3. We have a couple of Shells that behave similarly.

In the console, there are very interesting GTK errors:

(SWT:5170): Gtk-CRITICAL **: gtk_widget_get_preferred_height_for_width: assertion `width >= 0' failed

(SWT:5170): Gtk-CRITICAL **: gtk_widget_get_preferred_height_for_width: assertion `width >= 0' failed

(SWT:5170): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -5 and height 32756
Comment 1 Marc-André Laperle CLA 2014-06-05 01:54:37 EDT
Created attachment 243962 [details]
Code snippet
Comment 2 Marc-André Laperle CLA 2014-06-05 15:41:38 EDT
Created attachment 244016 [details]
Spelling preferences GTK3

It looks like the spelling preference page is affected by a similar issue.
Comment 3 Marc-André Laperle CLA 2014-06-12 00:27:16 EDT
I can also reproduce the issue on Fedora 20.
Comment 4 Alexander Kurtakov CLA 2014-07-29 09:54:28 EDT
(In reply to Marc-Andre Laperle from comment #3)
> I can also reproduce the issue on Fedora 20.

Can you reproduce the problem on fully uptodate Fedora 20? I was working on the problem but after last updates it magically doesn't happen anymore.
Comment 5 Marc-André Laperle CLA 2014-07-29 10:59:22 EDT
I'll try tonight. If that's the case, it would be useful to know which commit fixed this so that it can be backported to Ubuntu LTS.
Comment 6 Marc-André Laperle CLA 2014-07-29 21:12:38 EDT
I works now after the upgrades. Now if I open the spelling preference page and I resize the window horizontally, it shrinks to 1 pixel wide. I'm pretty sure this didn't happen before the updates since I did test the spelling preference page on Fedora too and I would've seen this.

I also tried compiling both matching versions of glib (2.38.2) and gtk (3.10.9) on Ubuntu and I still can reproduce the bug *most* of the time. Maybe something else is at play.
Comment 7 Alexander Kurtakov CLA 2014-07-30 03:44:55 EDT
Running with GTK_DEBUG=geometry the output of the snippet is:
gtk_widget_size_allocate:   GtkWindow 0 0 200 200
gtk_widget_size_allocate:   GtkWindow 0 0 200 200
gtk_widget_size_allocate:   GtkWindow 0 0 200 200
gtk_widget_size_allocate:   GtkWindow 0 0 1 1
gtk_widget_size_allocate:     GtkBox 0 0 1200 675
gtk_widget_size_allocate:       GtkScrolledWindow 0 0 1200 675
gtk_widget_size_allocate:         SwtFixed 0 0 1200 675
gtk_widget_size_allocate:             SwtFixed 0 0 0 0
gtk_widget_size_allocate:               GtkFrame 0 0 56 22
gtk_widget_size_allocate:                 SwtFixed 1 21 54 1
gtk_widget_size_allocate:                 GtkLabel 4 0 48 21
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 0 0
gtk_widget_size_allocate:               GtkFrame 0 0 2 2
gtk_widget_size_allocate:                 SwtFixed 1 1 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 0 0 1 1
gtk_widget_size_allocate:             SwtFixed 5 5 0 86
gtk_widget_size_allocate:               GtkFrame 0 0 1 86
gtk_widget_size_allocate:                 SwtFixed 1 1 1 84

(SWT:8404): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to underallocate SwtFixed's child GtkFrame 0x7f6948455130. Allocation is 1x86, but minimum required size is 56x22.
gtk_widget_size_allocate:                 GtkLabel 4 -32616 -5 32617

(SWT:8404): Gtk-CRITICAL **: gtk_widget_get_preferred_height_for_width: assertion 'width >= 0' failed

(SWT:8404): Gtk-CRITICAL **: gtk_widget_get_preferred_height_for_width: assertion 'width >= 0' failed

(SWT:8404): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to underallocate GtkFrame's child GtkLabel 0x7f6948204480. Allocation is -5x32617, but minimum required size is 48x21.

(SWT:8404): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -5 and height 32617
gtk_widget_size_allocate:             SwtFixed 5 96 0 0
gtk_widget_size_allocate:               GtkFrame 0 0 2 2
gtk_widget_size_allocate:   GtkWindow 0 0 1200 675
gtk_widget_size_allocate:     GtkBox 0 0 1200 675
gtk_widget_size_allocate:       GtkScrolledWindow 0 0 1200 675
gtk_widget_size_allocate:         SwtFixed 0 0 1200 675
gtk_widget_size_allocate:           SwtFixed 0 0 0 0
gtk_widget_size_allocate:             SwtFixed 5 96 0 0
gtk_widget_size_allocate:               GtkFrame 0 0 2 2
gtk_widget_size_allocate:     GtkBox 0 0 1200 675
gtk_widget_size_allocate:     GtkBox 0 0 1200 675
gtk_widget_size_allocate:           SwtFixed 0 0 1200 675
gtk_widget_size_allocate:             SwtFixed 5 96 0 0
gtk_widget_size_allocate:           SwtFixed 0 0 1200 675

It looks like SwtFixed doesn't play well with GtkFrame label.
Comment 8 Alexander Kurtakov CLA 2014-07-30 03:56:02 EDT
Adding reference to gtk bug as it looks related.
Comment 9 Marc-André Laperle CLA 2014-08-01 00:52:23 EDT
I haven't been able to reproduce the bug that is referenced. But I have managed to make a patch for GTK that fixes the SWT snippet. See attachment. I do not have a GTK-only code snippet to reproduce it though so the patch itself is not that useful yet.
Comment 10 Marc-André Laperle CLA 2014-08-01 00:53:23 EDT
Created attachment 245623 [details]
gtk frame patch
Comment 11 Leo Ufimtsev CLA 2015-01-30 13:30:41 EST
Reproducible with current master on gtk3.
 
Oddly, if I launch with SWT_GTK3=1 && GTK_DEBUG=geometry the issue doesn't occur.
Comment 12 Marc-André Laperle CLA 2015-09-13 22:35:30 EDT
I've made a snippet using GTK only and opened a bug with the patch:
https://bugzilla.gnome.org/show_bug.cgi?id=754976
Comment 13 Marc-André Laperle CLA 2015-09-13 23:28:24 EDT
https://git.eclipse.org/r/#/c/55819/
Comment 14 Eric Williams CLA 2015-09-18 10:29:51 EDT
Is this a duplicate of bug 470129?
Comment 15 Marc-André Laperle CLA 2015-09-18 10:44:10 EDT
(In reply to Eric Williams from comment #14)
> Is this a duplicate of bug 470129?

Yes, at this point, we're fairly sure they are the same.

*** This bug has been marked as a duplicate of bug 470129 ***