RFR: 8349091: Charts: exception initializing in a background thread [v6]

John Hendrikx jhendrikx at openjdk.org
Mon Mar 3 21:32:58 UTC 2025


On Mon, 3 Mar 2025 21:28:13 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> The reason we `should not` be binding in this PR is because in part it's **bad design(tm)**: we are creating a zillion of listeners (one per plot data point); a better solution would be to create one listener and use (already existing series) to toggle the data points.
>> 
>> The other reason is https://bugs.openjdk.org/browse/JDK-8351067 - the `Platform::accessibilityActive` property getter is not thread safe, but even if was, registering a listener with it may cause the change to come in **before** the node becomes a part of the scene graph, leading to unsynchronized multi-threaded access.
>
> Was this solution considered:
> 
>     ObservableValue<Boolean> partOfSceneGraph = this.sceneProperty()
>       .flatMap(Scene::windowProperty)
>       .flatMap(Window::showingProperty)
>       .orElse(false);
>       
>     symbol.focusTraversableProperty()
>         .bind(Platform.accessibilityActiveProperty().when(partOfSceneGraph));
>         
> What the above code does is create a binding on the `when` statement (a listener is added on the `when` result).  However, the `when` property will not add a listener on `Platform.accessibilityActiveProperty()` until `partOfSceneGraph` is `true`.  As soon as it does though, a listener is installed on  `Platform.accessibilityActiveProperty()` and its latest value is set to `focusTraversableProperty` via the bind.

The above does require though that `Platform.accessibilityActiveProperty()` is properly synchronized.  I think it may be a good idea to fix that first.  Perhaps all platform provided properties (if there are more) should ensure they're only initialized once.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1697#discussion_r1978267599


More information about the openjfx-dev mailing list