Bug #3305
broken widget references management
0%
History
#1 Updated by Ovidiu Maxiniuc almost 7 years ago
While testing a medium-large GUI application I noticed that at some time (I was not able to pinpoint the exact trigger), a lot of messages like these get printed into console log:
WARNING: Unable to get the screen buffer for frame ID: 673. The frame with given ID is missing in widget registry. Jun 28, 2017 1:15:14 PM com.goldencode.p2j.ui.chui.ThinClient getScreenBuffer
I did a short investigation and I see that on client side, WidgetRegistry.widgetList
container does not reflect the widgets shown on the screen. Apparently there are some widgets that are not listed there, while a lot of other got left behind. Statistically, at some point, ~1500 widgets were stored, while only a a couple of tens were really on screen.
Of the grand total, about 660 were ScrollBarGuiButtons
, 330 ScrollBarGuiImpl
, 240 ButtonGuiImpl
, 170 ScrollPaneGuiImpl
. Other widgets I could spot in the list with less occurrences (<30): MenuItemGuiImpl
, BrowseColumnGuiImpl
.
Of course, the reason for the messages, if not the fact that the widgets don't get removed, it's exactly the reverse, but for the moment, I am thinking that these might be related.
A little help for the person who will further investigate this, I used the following piece of code for dumping WidgetRegistry.widgetList
:
if (debug) { Map<Class, Integer> map = new HashMap<>(); for (Map.Entry<WidgetId, Widget<O>> wid : widgetList.entrySet()) { Class<? extends Widget> c = wid.getValue().getClass(); Integer cnt = map.get(c); if (cnt == null) { cnt = 1; } else { cnt = cnt + 1; } map.put(c, cnt); } System.out.println("WidgetRegistry.widgetList dump (" + widgetList.size() + " -> " + map.size() + ")"); for (Map.Entry<Class, Integer> iter : map.entrySet()) { System.out.println(iter.getKey() + "\t" + iter.getValue()); } System.out.println("WidgetRegistry.widgetList dump ended."); }
As a side note, I think that for widgetList
and generally, all places where WidgetId
is used as key for a map, the indexing key used should be replaced with int
/Integer
. I think that the autoboxing of Java5 is a better solution than having to create temporary new WidgetId
objects for accessing these maps.