FXMisc/Flowless

Exception during layout pass (seems to cause unresponsive GUI)

Closed this issue · 2 comments

This exception is from a use of RichTextFX, but the stack trace is solely from Flowless so I'm reporting it here:

Exception in thread "JavaFX Application Thread" java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at org.fxmisc.flowless.CellListManager.getPresentCell(CellListManager.java:56)
	at org.fxmisc.flowless.CellPositioner.getVisibleCell(CellPositioner.java:28)
	at org.fxmisc.flowless.Navigator.fillForwardFrom0(Navigator.java:231)
	at org.fxmisc.flowless.Navigator.fillForwardFrom0(Navigator.java:217)
	at org.fxmisc.flowless.Navigator.fillTowardsSkyFrom0(Navigator.java:323)
	at org.fxmisc.flowless.Navigator.fillViewportFrom(Navigator.java:284)
	at org.fxmisc.flowless.Navigator.visit(Navigator.java:161)
	at org.fxmisc.flowless.MinDistanceTo.accept(TargetPosition.java:148)
	at org.fxmisc.flowless.Navigator.layoutChildren(Navigator.java:67)
	at javafx.scene.Parent.layout(Parent.java:1087)
	at org.fxmisc.flowless.VirtualFlow.layoutChildren(VirtualFlow.java:165)
        at javafx.scene.Parent.layout(Parent.java:1087)
	at javafx.scene.Parent.layout(Parent.java:1093)
	...
	at javafx.scene.Scene.doLayoutPass(Scene.java:552)

The method getPresentCell does warn that it can throw, but I can't spot a relevant catch anywhere in the hierarchy. What's particularly problematic is that after this exception, the GUI stopped updating or responding. (That may be due to our surrounding code or something RichTextFX does, though -- it's hard to say.) I haven't yet been able to reproduce it consistently, unfortunately, but I've seen it twice now.

Hold that thought. I made the mistake of assuming that since none of my code was in the stack trace, it wasn't something I was doing. I managed to reproduce it slightly more often on a different machine, and I believe it was an action I was taking in a listener which was causing the issue. I have a listener on the visibleCells of the VirtualFlow living inside RichTextFX, and this was making a change which could cause the layout to be affected, which I think was probably the cause of the later exception shown above. I've added a Platform.runLater to delay the change, and the exception seems to no longer occur. I'll close this again, as I think that is the explanation for the exception.

Glad you figured it out!