-
Bug
-
Resolution: Fixed
-
P4
-
jfx23, jfx24
-
b04
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
all methods in com.sun.javafx.scene.control.skin.Utils that use the static variable layout are not thread safe since they mutate a shared static object. This poisons all transitive calls of these methods. For example calling getBaselineOffset on controls that are not on the live scene graph can crash live UI controls; so does setting displayedYearMonth of a DatePickerContent object.
A possible way this crashes is as follows:
- Thread 1 control 1 (non scene graph) calls computeTextWidth with some string content
- JavaFX thread control 2 renders some control, calling computeBaselineOffset -> Utils.getAscent
- Thread 1 calls layout.setContent("some text"), which starts a computation and finally initializes layout.runs with some string array
- Thread 2 calls layout.setContent(""), which resets layout.runs to null
- Thread 1 crashes with NPE due to trying to access layout.runs
A fix could be to instantiate per method invocation instances of TextLayout instead of using a shared static instance.
If performance is the reason for the static single instance, please consider that creating multiple instances should have a negligible performance impact since the object does not instantiate a lot of fields and may even improve performance since no shared memory needs to be accessed.
FREQUENCY : occasionally
Root Cause:
Some text layout utility methods access a static Text and TextLayout instances, a practice which is neither thread-safe nor reentrant.
all methods in com.sun.javafx.scene.control.skin.Utils that use the static variable layout are not thread safe since they mutate a shared static object. This poisons all transitive calls of these methods. For example calling getBaselineOffset on controls that are not on the live scene graph can crash live UI controls; so does setting displayedYearMonth of a DatePickerContent object.
A possible way this crashes is as follows:
- Thread 1 control 1 (non scene graph) calls computeTextWidth with some string content
- JavaFX thread control 2 renders some control, calling computeBaselineOffset -> Utils.getAscent
- Thread 1 calls layout.setContent("some text"), which starts a computation and finally initializes layout.runs with some string array
- Thread 2 calls layout.setContent(""), which resets layout.runs to null
- Thread 1 crashes with NPE due to trying to access layout.runs
A fix could be to instantiate per method invocation instances of TextLayout instead of using a shared static instance.
If performance is the reason for the static single instance, please consider that creating multiple instances should have a negligible performance impact since the object does not instantiate a lot of fields and may even improve performance since no shared memory needs to be accessed.
FREQUENCY : occasionally
Root Cause:
Some text layout utility methods access a static Text and TextLayout instances, a practice which is neither thread-safe nor reentrant.
- blocks
-
JDK-8349255 TitledPane: exception initializing in a background thread
-
- Resolved
-
-
JDK-8348987 ☂ Thread safety in Node initialization
-
- In Progress
-
- relates to
-
JDK-8348423 [TestBug] stress test Nodes initialization from a background thread
-
- Resolved
-
-
JDK-8348100 Tooltips cannot be instantiated on background thread
-
- Resolved
-
- links to
-
Commit(master) openjdk/jfx/2cf9779b
-
Review(master) openjdk/jfx/1691
(1 links to)