Bug 531685 - [GTK] Resizing first column to zero size crashes JVM
Summary: [GTK] Resizing first column to zero size crashes JVM
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 573637 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-02-26 11:01 EST by Simeon Andreev CLA
Modified: 2021-05-19 11:21 EDT (History)
4 users (show)

See Also:


Attachments
Snippet to reproduce the problem with. (3.30 KB, text/x-java)
2018-02-26 11:01 EST, Simeon Andreev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Andreev CLA 2018-02-26 11:01:43 EST
Created attachment 272881 [details]
Snippet to reproduce the problem with.

Steps to reproduce:

1. Run attached snippet.
2. Resize first column to e.g. 0 width.
3. Observe that the width can be reduced below the minimum of 50px specified with ColumnWeightData.
4. Observe *crash* when the width reaches 0.


The minimum width also doesn't work with SWT_GTK3=0. There, once 0 width is reached, the column *vanishes*. I've not found a way to restore the column after this.


This feels very awkward. In our product we have some tables where columns should have minimum weight.

While based on Eclipse 3.8 we did this with a control resize listener, setting another size if a too-low value was specified. While not optimal, at least this worked. With Eclipse 4.7.x this no longer works, so we looked for alternatives.

The alternative we found is using ColumnWeightData, which sounds great, but doesn't work.

So not only are we not able to provide the minimum width for the column, we are unable to prevent the *crash* once the column is narrowed too much...


Environment:

Eclipse SDK
Version: Photon (4.8)
Build id: I20171217-2000

RHEL 7.2
GTK 3.14
Comment 1 Simeon Andreev CLA 2018-02-26 11:03:32 EST
After some debugging, I realized that org.eclipse.jface.layout.TreeColumnLayout.updateColumnData(Widget) *replaces* the ColumnWeightData with a ColumnPixelData.

This was very surprising to say the least... This is coming from Bug 178280.
Comment 2 Lars Vogel CLA 2018-02-26 11:11:16 EST
(In reply to Simeon Andreev from comment #1)
> This was very surprising to say the least... 

+1
Comment 3 Simeon Andreev CLA 2018-02-27 03:39:21 EST
OK, I tried to ensure that a ColumnWeightData layout data is not touched by TreeColumnLayout.updateColumnData.

Unfortunately, this doesn't seem to be the only problem. From debugging and experimenting with the data types for TreeColumnLayout, here is what I see (GTK 3.14 and GTK 3.22):


1. The layouts will set widths on SWT level, which will not set width with GTK API.
    1.a) I don't think this can work. I'm guessing there is missing test coverage for e.g. org.eclipse.swt.widgets.TreeColumn.setWidth(int). For example something like, call method, check actual width of column header element.
    1.b) GTK does what it does when I'm resizing the element. The layout will then set some widths that are never propagated to the actual GTK element.

2. The layouts ColumnWeightData and ColumnPixelData cause a lot of repaints resulting in flickering on column re-size.

3. The layouts ColumnWeightData and ColumnPixelData results in invisible rolls until mouse-over, i.e. the repaints themselves look to be incomplete. In the snippet, I tried layouts:
    3.a) layout.setColumnData(pro, new ColumnWeightData(1, 50, true))
    3.b) layout.setColumnData(pro, new ColumnPixelData(50, true, true))

4. org.eclipse.swt.widgets.Tree.createColumn(TreeColumn, int) calls org.eclipse.swt.internal.gtk.GTK.gtk_tree_view_column_set_min_width(long, int) with 0 minimum width.
    4.a) Resizing to 0 width can cause a crash, see below.
    4.b) No idea if this should be looked into or if the minimum width should be a positive number.

Gtk:ERROR:gtkcellrenderer.c:1787:gtk_cell_renderer_get_aligned_area: assertion failed: (aligned_area->x >= cell_area->x && aligned_area->x <= cell_area->x + cell_area->width) (same on GTK 3.14 and GTK 3.22)


All in all, fixing the layouts is beyond my knowledge. Unless I invest some of my free time, its also beyond my schedule. I'm not sure how to go about fixing this bug in particular, I assume fixing ColumnWeightData is the way to go.


Though disappointing, we will likely resort to using internal SWT API in our product, to set the minimum width on GTK level:

GTK.gtk_tree_view_column_set_min_width(column.handle, 50); // internal API, min 50px width

This really is all we want here, and seems to do the job.
Comment 4 Eclipse Genie CLA 2020-06-22 17:50:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Andrey Loskutov CLA 2021-05-19 08:47:28 EDT
*** Bug 573637 has been marked as a duplicate of this bug. ***
Comment 6 Andrey Loskutov CLA 2021-05-19 08:48:01 EDT
Still there, see steps in bug 573637.
Comment 7 Andrey Loskutov CLA 2021-05-19 10:49:08 EDT
RHEL bug opened: https://bugzilla.redhat.com/show_bug.cgi?id=1962215

Question is: if we can provide some kind of workaround in SWT to avoid that (as long as the bug is still not fixed in GTK)? 

Automatically set minimal column size via GTK.gtk_tree_view_column_set_min_width(column.handle, 50); on first column?

Simeon, Alex, Paul: WDYT?
Comment 8 Simeon Andreev CLA 2021-05-19 11:21:04 EDT
(In reply to Andrey Loskutov from comment #7)
> RHEL bug opened: https://bugzilla.redhat.com/show_bug.cgi?id=1962215
> 
> Question is: if we can provide some kind of workaround in SWT to avoid that
> (as long as the bug is still not fixed in GTK)? 
> 
> Automatically set minimal column size via
> GTK.gtk_tree_view_column_set_min_width(column.handle, 50); on first column?
> 
> Simeon, Alex, Paul: WDYT?

50 is definitely a no go IMO. Maybe 1, so the user "doesn't notice" there is a limit. I think a limit of 1 might be acceptable if we merge it early on to get feedback before e.g. 4.21 is released; I don't know if its a safe change.