Bug 533815 - [GTK 3.22] Starting Eclipse prints GTK warnings on standard error
Summary: [GTK 3.22] Starting Eclipse prints GTK warnings on standard error
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: 4.8 M7   Edit
Assignee: Simeon Andreev CLA
QA Contact: Eric Williams CLA
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2018-04-19 08:47 EDT by Simeon Andreev CLA
Modified: 2018-05-08 10:37 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2018-04-19 08:47:35 EDT
Errors are:

(Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
(Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)
(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)


To reproduce start Eclipse from a console.


E.g. seen with:

Eclipse SDK
Version: Photon (4.8)
Build id: I20180304-0800

RHEL 7.4
gtk3-devel-3.22.10-4.el7.x86_64
Comment 1 Simeon Andreev CLA 2018-04-19 08:54:11 EDT
(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)
(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)

Those 2 come from the status line:

Thread [main] (Suspended (breakpoint at line 1046 in Control))	
	ProgressBar(Control).resizeHandle(int, int) line: 1046	
	ProgressBar(Control).setBounds(int, int, int, int, boolean, boolean) line: 1126	
	ProgressBar(Control).setBounds(Rectangle) line: 952	
	StackLayout.layout(Composite, boolean) line: 123	
	ProgressIndicator(Composite).updateLayout(boolean) line: 1763	
	ProgressIndicator(Composite).setBounds(int, int, int, int, boolean, boolean) line: 1549	
	ProgressIndicator(Control).setBounds(int, int, int, int) line: 992	
	GridLayout.layout(Composite, boolean, int, int, int, int, boolean) line: 693	
	GridLayout.layout(Composite, boolean) line: 197	
	Composite.updateLayout(boolean) line: 1763	
	Composite.setBounds(int, int, int, int, boolean, boolean) line: 1549	
	Composite(Control).setBounds(int, int, int, int) line: 992	
	StatusLine$StatusLineLayout.layout(Composite, boolean) line: 249	
	StatusLine(Composite).updateLayout(boolean) line: 1763	
	StatusLine(Composite).setBounds(int, int, int, int, boolean, boolean) line: 1549	
	StatusLine(Control).setBounds(int, int, int, int) line: 992	
	TrimBarLayout.tileLine(TrimBarLayout$TrimLine, Rectangle) line: 274	
	TrimBarLayout.layout(Composite, boolean) line: 245	
	Composite.updateLayout(boolean) line: 1763	
	Shell(Composite).updateLayout(boolean) line: 1769	
	Shell(Composite).setLayoutDeferred(boolean) line: 1608	
	Display.runDeferredLayouts() line: 4947	
	Display.readAndDispatch() line: 4488	
	PartRenderingEngine$5.run() line: 1150	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 1039	
	E4Workbench.createAndRunUI(MApplicationElement) line: 153	
	Workbench.lambda$3(Display, WorkbenchAdvisor, int[]) line: 681	
	1195403585.run() line: not available	
	Realm.runWithDefault(Realm, Runnable) line: 336	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 595	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 148	
	IDEApplication.start(IApplicationContext) line: 152	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 134	
	EclipseAppLauncher.start(Object) line: 104	
	EclipseStarter.run(Object) line: 388	
	EclipseStarter.run(String[], Runnable) line: 243	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 498	
	Main.invokeFramework(String[], URL[]) line: 656	
	Main.basicRun(String[]) line: 592	
	Main.run(String[]) line: 1498	
	Main.main(String[]) line: 1471

In particular, org.eclipse.jface.action.StatusLine.StatusLineLayout.layout(Composite, boolean) will set bounds from (0, 0) to (0, 13) for the progress bar, since its not visible. This then translates to width=1 and height=13. After the OS.swt_fixed_resize call goes through, the error is printed. I don't see different SWT behaviour on GTK 3.14, so maybe the warning is new.
Comment 2 Simeon Andreev CLA 2018-04-19 09:04:16 EDT
I noticed org.eclipse.swt.widgets.ProgressBar.resizeCalculationsGTK3(long, int, int):

This should be fixing bug 486068; the commit message states it should fix this warning, which confuses me somewhat.
Comment 3 Simeon Andreev CLA 2018-04-19 09:07:29 EDT
Hi Eric,

could you take a look here? If I remove ProgressBar.resizeCalculationsGTK3 these warnings on start-up go away:

(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)
(Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1, extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)

This comes from:

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=02caa3d3e3329b6e6fb4a2bd1918747a3ca3ba20

Looking at the commit message, shouldn't the commit fix such warnings instead of introduce them?

Best regards and thanks,
Simeon
Comment 4 Eric Williams CLA 2018-04-19 09:52:43 EDT
(In reply to Simeon Andreev from comment #3)
> Hi Eric,
> 
> could you take a look here? If I remove ProgressBar.resizeCalculationsGTK3
> these warnings on start-up go away:
> 
> (Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1,
> extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)
> (Eclipse:17130): Gtk-WARNING **: Negative content width -1 (allocation 1,
> extents 1x1) while allocating gadget (node trough, owner GtkProgressBar)
> 
> This comes from:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=02caa3d3e3329b6e6fb4a2bd1918747a3ca3ba20
> 
> Looking at the commit message, shouldn't the commit fix such warnings
> instead of introduce them?
> 
> Best regards and thanks,
> Simeon

ProgressBar is exempt from these sizing calculations, as the minimum size for ProgressBars in GTK is huge (something like 200-300px wide). Allowing this size for a ProgressBar breaks all sorts of cases in SWT, like the little ProgressBar at in the bottom right corner of the IDE. For this reason I decided the two warnings are worth living with, given the alternative visual problems.
Comment 5 Simeon Andreev CLA 2018-04-19 10:09:26 EDT
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java
index 391795ef80..640999101c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java  
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ProgressBar.java  
@@ -189,6 +189,7 @@ long /*int*/ gtk_realize (long /*int*/ widget) {
  */
 @Override
 Point resizeCalculationsGTK3 (long /*int*/ widget, int width, int height) {
+       width = Math.max(2, width);
        return new Point (width, height);
 }
 
This avoids the warnings as well, though it isn't very great. WDYT? I don't think its meaningful to change clients such as JFace StatusLine.
Comment 6 Eclipse Genie CLA 2018-04-19 10:28:18 EDT
New Gerrit change created: https://git.eclipse.org/r/121419
Comment 7 Simeon Andreev CLA 2018-04-20 06:38:26 EDT
(Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?
(Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?

Those are caused by org.eclipse.swt.widgets.Shell.forceResize(int, int):

void forceResize (int width, int height) {
	...
        if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) gtk_widget_get_preferred_size (vboxHandle, requisition);
	GTK.gtk_widget_size_allocate (vboxHandle, allocation);
	...
}

For whatever reason, GTK wants the client code to not only ask the minimum size of the shell but also the natural size. I've updated the patch; with this, there are no warnings printed on standard error on start.
Comment 9 Eric Williams CLA 2018-04-20 09:17:22 EDT
(In reply to Simeon Andreev from comment #7)
> (Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870
> without calling gtk_widget_get_preferred_width/height(). How does the code
> know the size to allocate?
> (Eclipse:17130): Gtk-WARNING **: Allocating size to GtkBox 0x7ffff0610870
> without calling gtk_widget_get_preferred_width/height(). How does the code
> know the size to allocate?
> 
> Those are caused by org.eclipse.swt.widgets.Shell.forceResize(int, int):
> 
> void forceResize (int width, int height) {
> 	...
>         if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0))
> gtk_widget_get_preferred_size (vboxHandle, requisition);
> 	GTK.gtk_widget_size_allocate (vboxHandle, allocation);
> 	...
> }
> 
> For whatever reason, GTK wants the client code to not only ask the minimum
> size of the shell but also the natural size. I've updated the patch; with
> this, there are no warnings printed on standard error on start.

Excellent investigation, thank you very much for the fix.


(In reply to Eclipse Genie from comment #8)
> Gerrit change https://git.eclipse.org/r/121419 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=f705132b505acb5a99a954ce2a4d6a4e82245e41

Patch is in master now.
Comment 10 Eric Williams CLA 2018-05-08 10:36:48 EDT
Verified in I20180507-2205.
Comment 11 Eric Williams CLA 2018-05-08 10:37:55 EDT
Verified in I20180507-2205.