java.lang.StackOverflowError when pressing FX Comb

2019-01-12 12:20发布

问题:

When using JavaFXPorts on Android (Android 4.1.1 on Asus Transformer Prime TF201 tablet), a java.lang.StackOverflowError is thrown when pressing on a ComboBox (see below the top stacks of the stacktrace).

It happens in a ComboBox in my FX application and is also 100% reproducible with the ComboBox example that is in Ensemble. In other words: can't use JavaFX ComboBox.

I'm aware of the Android stack size limit posted in many forums and there are various suggestions on what to do when it happens with Android UI and Android APIs. However, can't find a relevant idea to apply when using JavaFX UI and JavaFXPorts.

Any idea for a fix\tweak\workaround would be much appreciated.

E/AndroidRuntime(32212): FATAL EXCEPTION: JavaFX Application Thread
E/AndroidRuntime(32212): java.lang.StackOverflowError
E/AndroidRuntime(32212):        at javafx.scene.Node.getTransformedBounds(Node.java:3422)
E/AndroidRuntime(32212):        at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
E/AndroidRuntime(32212):        at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
E/AndroidRuntime(32212):        at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
E/AndroidRuntime(32212):        at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
E/AndroidRuntime(32212):        at javafx.scene.Node.updateGeomBounds(Node.java:3577)
E/AndroidRuntime(32212):        at javafx.scene.Node.getGeomBounds(Node.java:3530)

回答1:

You can create the java.custom.properties file, and include in it this property:

monocle.stackSize=128000

You can override other system properties as well by including them with their new values.

Put the file at the root of your classpath, e.g. in the folder src/android/resources of your project.

You can find this FAQ here here and all the documentation for JavaFXPorts here.

Check if this solves your exception.