Bug #3371
NPE in AbstractGuiDriver in client log
100%
History
#1 Updated by Ovidiu Maxiniuc over 6 years ago
- Status changed from New to WIP
Found following exception in client log:
Caused by: java.lang.NullPointerException at com.goldencode.p2j.ui.client.gui.driver.AbstractGuiDriver.getTextWidths(AbstractGuiDriver.java:1665) at com.goldencode.p2j.ui.client.gui.driver.AbstractGuiDriver.getTextWidths(AbstractGuiDriver.java:1688) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.computeLineWidths(EditorGuiImpl.java:3329) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.maxLineWidthNative(EditorGuiImpl.java:3079) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.access$2500(EditorGuiImpl.java:129) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl$EditorScrollContainer.getScrollDimension(EditorGuiImpl.java:3842) at com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl.adjustScrollLayoutImpl(ScrollPaneGuiImpl.java:728) at com.goldencode.p2j.ui.chui.ThinClient.eventBracket(ThinClient.java:15416) at com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl.adjustScrollLayout(ScrollPaneGuiImpl.java:226) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.processScrollPane(EditorGuiImpl.java:2972) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.afterConfigUpdate(EditorGuiImpl.java:1409) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.afterConfigUpdate(EditorGuiImpl.java:129) at com.goldencode.p2j.ui.ConfigSyncManager.markScopeEnd(ConfigSyncManager.java:298) at com.goldencode.p2j.ui.ConfigManager.syncConfigChanges(ConfigManager.java:549) at com.goldencode.p2j.ui.ConfigManager.replaceConfig(ConfigManager.java:436) at com.goldencode.p2j.ui.client.Frame.applyConfig(Frame.java:5530) at com.goldencode.p2j.ui.client.WidgetRegistry.reconstructWidget(WidgetRegistry.java:246) at com.goldencode.p2j.ui.client.WidgetRegistry.pushDefinition(WidgetRegistry.java:647) at com.goldencode.p2j.ui.chui.ThinClient.lambda$pushOneDef$22(ThinClient.java:8617) at com.goldencode.p2j.ui.chui.ThinClient.eventBracket(ThinClient.java:15416) at com.goldencode.p2j.ui.chui.ThinClient.eventDrawingBracket(ThinClient.java:15360) at com.goldencode.p2j.ui.chui.ThinClient.pushOneDef(ThinClient.java:8608) at com.goldencode.p2j.ui.chui.ThinClient.pushScreenDefinition(ThinClient.java:8551) at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) [...]
The client is returned to login screen.
Investigations:¶
The ews
is null
when we are not in drawing bracket. If we look in the stack trace, there is one eventDrawingBracket
in stack.
Solution:¶
I forced a dedicated eventDrawingBracket
in ScrollPaneGuiImpl.adjustScrollLayout
so the code looks now like this:
ThinClient tc = ThinClient.getInstance(); tc.eventBracket(true, () -> tc.eventDrawingBracket(this, this::adjustScrollLayoutImpl));
The screen does not crashes any more. Yet, I am not sure of the correctness of this patch.
#2 Updated by Greg Shah over 6 years ago
Code Review Task Branch 3369a Revision 11211
I generally OK with the changes. The one thing that is not clear to me is that the TC.eventDrawingBracket()
already uses TC.eventBracket()
in its core implementation. I wonder what is going on here that requires this approach.
Constantin: thoughts?
#3 Updated by Constantin Asofiei over 6 years ago
Ovidiu, I would rather ensure that EditorGuiImpl.computeLineWidths
has a window selected (i.e. is bracketed in gd.selectWindow
and gd.releaseWindow
calls). The locations from where ScrollPaneGuiImpl.adjustScrollLayout
is called doesn't necessary need an explicit draw. Also, there are two methods computeLineWidths
, I think both require the changes.
#4 Updated by Ovidiu Maxiniuc over 6 years ago
I tried to move the code in a withSelectedWindow()
, but the widget is not fully reconstructed so the parent is not yet set. I'm getting this:
java.lang.IllegalStateException: Widget 995 is not attached to a Window instance. at com.goldencode.p2j.ui.client.widget.AbstractWidget.window(AbstractWidget.java:361) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.computeLineWidths(EditorGuiImpl.java:3310) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.maxLineWidthNative(EditorGuiImpl.java:3079) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.access$2500(EditorGuiImpl.java:129) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl$EditorScrollContainer.getScrollDimension(EditorGuiImpl.java:3846) at com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl.adjustScrollLayoutImpl(ScrollPaneGuiImpl.java:728) at com.goldencode.p2j.ui.chui.ThinClient.eventBracket(ThinClient.java:15416) at com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl.adjustScrollLayout(ScrollPaneGuiImpl.java:226) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.processScrollPane(EditorGuiImpl.java:2972) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.initialize(EditorGuiImpl.java:259) at com.goldencode.p2j.ui.client.gui.EditorGuiImpl.initialize(EditorGuiImpl.java:129) at com.goldencode.p2j.ui.client.WidgetRegistry.reconstructWidget(WidgetRegistry.java:264) at com.goldencode.p2j.ui.client.WidgetRegistry.pushDefinition(WidgetRegistry.java:647) at com.goldencode.p2j.ui.chui.ThinClient.lambda$pushOneDef$22(ThinClient.java:8617) at com.goldencode.p2j.ui.chui.ThinClient.eventBracket(ThinClient.java:15416) at com.goldencode.p2j.ui.chui.ThinClient.eventDrawingBracket(ThinClient.java:15360) at com.goldencode.p2j.ui.chui.ThinClient.pushOneDef(ThinClient.java:8608) at com.goldencode.p2j.ui.chui.ThinClient.pushScreenDefinition(ThinClient.java:8551)
I can abort line widths computation if parent is not yet set, but in this case the line widths remain unset?
#5 Updated by Constantin Asofiei over 6 years ago
Ovidiu, please try something: is EditorGuiImpl.processScrollPane
called when i.e. the editor is drawn? I wonder if we just need to bypass this until the editor is realized.
#6 Updated by Ovidiu Maxiniuc over 6 years ago
Constantin Asofiei wrote:
Ovidiu, please try something: is
EditorGuiImpl.processScrollPane
called when i.e. the editor is drawn? I wonder if we just need to bypass this until the editor is realized.
Yes, processScrollPane()
is called at the end of each afterConfigUpdate()
and this time the parent is already set. I suppose it's not an issue if line width are not computed at initialization. Also, from my quick investigations, parsedText
is quite late set, after calling processScrollPane
a dozen times (I guess this will be fixed by coalescing the config updates in a single message between server and client).
I am going to commit this change to 3369a.
#7 Updated by Ovidiu Maxiniuc over 6 years ago
- Assignee set to Ovidiu Maxiniuc
- % Done changed from 0 to 90
The revision 11212 of 3369a makes sure the window is selected in EditorGuiImpl.computeLineWidths()
. The exceptions are not visible in log any more.
#8 Updated by Greg Shah over 6 years ago
- % Done changed from 90 to 100
- Status changed from WIP to Closed
Branch 3369a was merged to trunk as revision 11206.