Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major than [message #1665661] |
Wed, 11 March 2015 10:32 |
Eclipse User |
|
|
|
Hello,
we started using Nattable in our application a few months ago.
After the Nattable update to version 1.2.0 we started encountering a StackOverflowError:
!ENTRY org.eclipse.ui 4 0 2015-03-10 15:47:24.290
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.StackOverflowError
at java.util.HashMap.hash(Unknown Source)
at java.util.HashMap.getEntry(Unknown Source)
at java.util.HashMap.get(Unknown Source)
at org.eclipse.nebula.widgets.nattable.layer.SizeConfig.getAggregateSize(SizeConfig.java:252)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getStartXOfColumnPosition(DataLayer.java:446)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:32)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
...
This happens on all kinds of tables (e.g.: view tables without cell editors and editable tables with cell editors) but only when the "Control Panel/Display text scaling" is major than 100% (e.g.: high resolution displays).
Another problem is that sometimes the end of the table is not correctly rendered:
We think that the two problems are connected, but we are not sure about it.
This is how we create Nattables:
[see: createTable.java attachment]
And this is a sample "configuration class" used to configure Nattables:
[see: MyListTableConfig.java attachment]
Could You help us?
Thanks!
|
|
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1670670 is a reply to message #1668231] |
Fri, 13 March 2015 09:37 |
Eclipse User |
|
|
|
No, it doesn't appear.
We also tried copying the "Everything but the kitchen sink" example in our application but we can't reproduce the issue (we applied our nattable theme, added some ConfigLabelAccumulators, put it in a section, ...).
In the end, I think that the issue is caused by some wrong configuration (layers order? nattable configuration?) even though everything was working on version 1.1.0.
I'll investigate and I'll tell You if I understand the cause.
Thank You for Your assistance!
Bye!
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1682506 is a reply to message #1670730] |
Tue, 17 March 2015 19:19 |
Thorsten Schlathölter Messages: 312 Registered: February 2012 Location: Düsseldorf |
Senior Member |
|
|
Hi,
any news on this? We encountered the same problem.
As the stack trace shows, the problem is localed in this method:
protected static final int findColumnPosition(int xOffset,
int columnOffset, ILayer layer, int x, int totalWidth,
int columnCount) {
double size = (double) (totalWidth - xOffset)
/ (columnCount - columnOffset);
int columnPosition = columnOffset + (int) ((x - xOffset) / size);
int startX = layer.getStartXOfColumnPosition(columnPosition);
int endX = startX + layer.getColumnWidthByPosition(columnPosition);
if (x < startX) {
return findColumnPosition(xOffset, columnOffset, layer, x, startX,
columnPosition);
} else if (x >= endX) {
return findColumnPosition(endX, columnPosition + 1, layer, x,
totalWidth, columnCount);
} else {
return columnPosition;
}
}
In our case at some point we reach the case where
Then the method is called recursively with:
columnOffset = columnPosition+1
In the called method this leads to:
columnOffset-columnCount = 0
Which results in an infinite size because of division by zero.
I have checked the conversions and found that the ConfigureScalingResult which is called results in a dpi of 120 whereas the GUIHelper method uses the dpiFactor of 1.25 for conversion.
public static int convertHorizontalPixelToDpi(int pixel) {
return Float.valueOf(pixel * getDpiFactor(getDpiX())).intValue();
}
I tried to put in a dpi of 125 in the ConfigureScalingCommand. This solves the problem. I know it is just a hack but I did not yet find out where the actual "miscalculation" takes place and exactly why.
I have solved the problem by calling the following command right after creation of the table.
table.getLayer().doCommand(new ConfigureScalingCommand(
new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().x;
dpi = (int)(GUIHelper.getDpiFactor(dpi)*100);
}
});
}
},
new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().y;
dpi = (int)(GUIHelper.getDpiFactor(dpi)*100);
}
});
}
}));
|
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1683914 is a reply to message #1683886] |
Wed, 18 March 2015 07:58 |
Eclipse User |
|
|
|
Hi,
no, we didn't create any custom layer and we don't know if some overrided method could deal with the ConfigureScalingCommand.
However the initial rendering is correct. The issue appears when the user does other actions like column resizing.
We agree with Thorsten about the cause of the issue.
About the "special size configuration" we can say that:
- we define some fixed column width (e.g.: bodyDataLayer.setDefaultColumnWidthByPosition(COLUMN_POSIZION, 70)), but removing them we still have the issue;
- the nattable parent is a section placed in a ScrolledComposite.
|
|
|
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1684661 is a reply to message #1684412] |
Wed, 18 March 2015 14:21 |
Eclipse User |
|
|
|
Hi Dirk,
we are currently experiencing the issue even if it appears less frequently (sometime when we change the view, and consequently when the nattable is disposed).
The error logged is the same as the previous:
!ENTRY org.eclipse.ui 4 0 2015-03-18 14:57:18.153
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.StackOverflowError
at java.util.HashMap.hash(Unknown Source)
at java.util.HashMap.getEntry(Unknown Source)
at java.util.HashMap.containsKey(Unknown Source)
at org.eclipse.nebula.widgets.nattable.layer.SizeConfig.getAggregateSize(SizeConfig.java:248)
at org.eclipse.nebula.widgets.nattable.layer.DataLayer.getStartXOfColumnPosition(DataLayer.java:446)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:32)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
at org.eclipse.nebula.widgets.nattable.layer.LayerUtil.findColumnPosition(LayerUtil.java:35)
...
This is the point of the SizeConfig.getAggregateSize() method where the application fails:
if (!this.aggregatedSizeCacheMap.containsKey(position)) {
...
}
Looking at this, we decided to remove the default column width (e.g.: bodyDataLayer.setDefaultColumnWidthByPosition(COLUMN_POSITION, 70)) from the DataLayer of the table and the issue seems to disappear.
Maybe there is something to adjust in the SizeConfig.getAggregateSize() method?
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1684782 is a reply to message #1684690] |
Wed, 18 March 2015 15:24 |
Eclipse User |
|
|
|
Hi Dirk,
I'm sorry because I was not clear: I wrote my last post after having applied the Gerrit Patch.
This is what I did:
- I updated the Nattable sources (exported the zip from the git repository and imported the Nattable projects in a Eclipse Galileo workspace);
- I applied the Gerrit patch (copy and paste from the webview to the LayerUtil.java file ... because I don't know other ways to do it! )
- I exported the projects as jar files and imported into our application
- launched our application and experienced the issue
- commented the bodyDataLayer.setDefaultColumnWidthByPosition()
- launched our application and didn't experience the issue.
So the issue is also present after having applied the Gerrit Patch.
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1686699 is a reply to message #1686484] |
Thu, 19 March 2015 10:03 |
Eclipse User |
|
|
|
Hi Dirk,
it seems to work!!!
We don't experience the issue even if we resize columns, we switch between views, etc. ...
At the end of our tests, we can say that the StackOverflowError issue is fixed!
The only issue we are still experiencing is that sometimes the "right end" of the table is not correctly rendered (I wrote something about it in the first post):
We thought that this issue was related with the StackOverflowError issue, but it seems to be a different kind of issue.
It seems to appear only when the Nattable is initially rendered and when all columns are visible. If, initially, the Nattable is partially rendered and we use the horizontal scrollbar to go to the last column, the issue does not appear.
We don't experience the issue for the "bottom" of the table.
I have to open a new forum topic for this?
Thank You so much!!!
Sergio Ferraresi
|
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1686968 is a reply to message #1686883] |
Thu, 19 March 2015 12:35 |
Eclipse User |
|
|
|
Yes, it's related to scaling (I forgot to write it in the previous post). The table is correctly rendered when no scaling is applied.
For example, in this table:
we have 6 columns and we have a default column width for the columns B (70px) and E (70px).
Also in this case, if we remove the bodyDataLayer.setDefaultColumnWidthByPosition(), the table is initially correctly rendered.
Maybe this could help you: we use the NatTableBorderOverlayPainter() as table overlay painter.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09165 seconds