Hi Krishna,

Usually these are caused by doing something on the wrong thread in my
experience. In our application we've had to be very careful about doing
things on the right thread. Mostly it's fine to create things off the app
thread and add them on the app thread, but that's not always the case.
Things that create popup windows like tooltips and context menus need to be
created on the app thread.

What you can do is set a conditional breakpoint in the parent class to
catch changes to the children list which happen off the application thread.

Something like: this.getScene() != null && !Platform.isApplicationThread()

If that's too slow, then you'll have to modify javafx itself with an assert
or an if statement in the children change listener:

if (this.getScene() != null && !Platform.isApplicationThread()) {
  System.out.println("Adding a node to the scene on the wrong
thread");//set break point on this line and view the stack to see what's
causing it
}

This might not be the cause of your problem, but if you have instances
where things are done in the wrong thread, you'll definitely hit sporadic
issues.

Dean

On Thu, Feb 29, 2024 at 9:16 AM Krishna Kumar <kumaran...@hotmail.com>
wrote:

> I am encountering the following Null Pointer exception during runtime,
> however the application keeps working as intended.
>
> Exception posted at the end to declutter the mail.
>
> Google search for this exception took me to this thread
>
> https://mail.openjdk.org/pipermail/openjfx-dev/2023-December/044343.html
>
> but in my case the JVM doesn't crash, neither does the application crash.
> The application continues to work as intended. I am unable to identify the
> node that causes this as the stack trace doesn't originate from the
> Application code, could anyone throw some light. I am running the code on
> /usr/lib/jvm/bellsoft-java21-full-amd64/bin/java
>
>
> tion in thread "JavaFX Application Thread" java.lang.NullPointerException:
> Cannot read field "advances" because "this.layoutCache" is null
>         at
> javafx.graphics/com.sun.javafx.text.PrismTextLayout.shape(PrismTextLayout.java:919)
>         at
> javafx.graphics/com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1113)
>         at
> javafx.graphics/com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:230)
>         at
> javafx.graphics/com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:256)
>         at
> javafx.graphics/javafx.scene.text.Text.getLogicalBounds(Text.java:432)
>         at
> javafx.graphics/javafx.scene.text.Text.doComputeLayoutBounds(Text.java:1137)
>         at
> javafx.graphics/javafx.scene.text.Text$1.doComputeLayoutBounds(Text.java:143)
>         at
> javafx.graphics/com.sun.javafx.scene.shape.TextHelper.computeLayoutBoundsImpl(TextHelper.java:95)
>         at
> javafx.graphics/com.sun.javafx.scene.NodeHelper.computeLayoutBounds(NodeHelper.java:108)
>         at
> javafx.graphics/javafx.scene.Node$13.computeBounds(Node.java:3474)
>         at
> javafx.graphics/javafx.scene.Node$LazyBoundsProperty.get(Node.java:9749)
>         at
> javafx.graphics/javafx.scene.Node$LazyBoundsProperty.get(Node.java:9740)
>         at
> javafx.graphics/javafx.scene.Node.getLayoutBounds(Node.java:3489)
>         at javafx.graphics/javafx.scene.Node.prefWidth(Node.java:2989)
>         at javafx.graphics/javafx.scene.Node.minWidth(Node.java:2930)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1898)
>         at
> javafx.graphics/javafx.scene.layout.HBox.getAreaWidths(HBox.java:462)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeContentWidth(HBox.java:549)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeMinWidth(HBox.java:409)
>         at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1049)
>         at
> javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1500)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1898)
>         at
> javafx.graphics/javafx.scene.layout.Region.getMaxAreaWidth(Region.java:2227)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeMaxMinAreaWidth(Region.java:2064)
>         at
> javafx.graphics/javafx.scene.layout.VBox.computeMinWidth(VBox.java:399)
>         at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1049)
>         at
> javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1500)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1898)
>         at
> javafx.graphics/javafx.scene.layout.HBox.getAreaWidths(HBox.java:462)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeContentWidth(HBox.java:549)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeMinWidth(HBox.java:409)
>         at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1049)
>         at
> javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1500)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1898)
>         at
> javafx.graphics/javafx.scene.layout.Region.getMaxAreaWidth(Region.java:2227)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeMaxMinAreaWidth(Region.java:2064)
>         at
> javafx.graphics/javafx.scene.layout.VBox.computeMinWidth(VBox.java:399)
>         at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1049)
>         at
> javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1500)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildMinAreaWidth(Region.java:1898)
>         at
> javafx.graphics/javafx.scene.layout.HBox.getAreaWidths(HBox.java:462)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeContentWidth(HBox.java:549)
>         at
> javafx.graphics/javafx.scene.layout.HBox.computeMinWidth(HBox.java:409)
>         at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1049)
>         at
> javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1500)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeChildPrefAreaWidth(Region.java:1959)
>         at
> javafx.graphics/javafx.scene.layout.Region.getMaxAreaWidth(Region.java:2228)
>         at
> javafx.graphics/javafx.scene.layout.Region.computeMaxPrefAreaWidth(Region.java:2092)
>         at
> javafx.graphics/javafx.scene.layout.VBox.computePrefWidth(VBox.java:420)
>         at javafx.graphics/javafx.scene.Parent.prefWidth(Parent.java:1021)
>         at
> javafx.graphics/javafx.scene.layout.Region.prefWidth(Region.java:1536)
>         at javafx.graphics/javafx.scene.Node.autosize(Node.java:3138)
>         at
> javafx.graphics/javafx.scene.Parent.layoutChildren(Parent.java:1239)
>         at javafx.graphics/javafx.scene.Parent.layout(Parent.java:1208)
>         at javafx.graphics/javafx.scene.Scene.doLayoutPass(Scene.java:594)
>         at
> javafx.graphics/javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2600)
>         at
> javafx.graphics/com.sun.javafx.tk.Toolkit.lambda$runPulse$2(Toolkit.java:401)
>         at
> java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
>         at
> javafx.graphics/com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:400)
>         at
> javafx.graphics/com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:430)
>         at
> javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:592)
>         at
> javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:572)
>         at
> javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:565)
>         at
> javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$11(QuantumToolkit.java:352)
>         at
> javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
>         at
> javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
>         at
> javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:263)
>         at java.base/java.lang.Thread.run(Thread.java:1583)
>
>
>

Reply via email to