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

2025-03-05 Thread Kevin Rushforth
On Wed, 5 Mar 2025 15:47:30 GMT, Andy Goryachev wrote: >> Yes, using a custom property, or a wrapper, would solve this particular >> synchronization problem, although that wouldn't solve all of the problems. >> >> We would then be left with the problem that if the accessibility change >> list

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

2025-03-05 Thread Andy Goryachev
On Wed, 5 Mar 2025 00:26:12 GMT, Kevin Rushforth wrote: >> Of course for a generic solution, we could provide a wrapper for properties, >> or custom synchronized properties. > > Yes, using a custom property, or a wrapper, would solve this particular > synchronization problem, although that woul

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

2025-03-04 Thread Kevin Rushforth
On Tue, 4 Mar 2025 23:00:01 GMT, John Hendrikx wrote: >> Yes, but that's because there is no synchronization. Here is a version that >> does do synchronization; I see no more exceptions (and it runs just as fast >> really): >> >> >> public class PropTest { >> public static void main(String

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

2025-03-04 Thread John Hendrikx
On Tue, 4 Mar 2025 19:28:29 GMT, John Hendrikx wrote: >> There is an even more fundamental problem: JavaFX properties are not >> thread-safe. You cannot safely add a listener or binding to a property in >> one thread while another thread modifies that property's value. >> >> So I think that de

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

2025-03-04 Thread John Hendrikx
On Tue, 4 Mar 2025 22:59:15 GMT, John Hendrikx wrote: >> The listener callbacks will always be on the thread that mutates the >> property being listened to, so that isn't the problem. The problem in this >> case is that adding or removing a listener while another thread is modifying >> the pro

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

2025-03-04 Thread John Hendrikx
On Tue, 4 Mar 2025 21:24:46 GMT, Kevin Rushforth wrote: >> I think the problem is in the callbacks themselves, as they'd be on the >> wrong thread. I vaguely remember experimenting with a system where you can >> provide an Executor for callbacks (like `Platform::runLater`) to mitigate >> this

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

2025-03-04 Thread Kevin Rushforth
On Tue, 4 Mar 2025 19:34:11 GMT, John Hendrikx wrote: >> @kevinrushforth I don't know, I would think it should be possible to create >> a property or property wrapper to make it thread-safe. Just having a >> version with all its methods synchronized is probably sufficient. If that >> saves a

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

2025-03-04 Thread John Hendrikx
On Tue, 4 Mar 2025 16:27:05 GMT, Kevin Rushforth wrote: >> unrelated, but I would rather disallow background access to any platform >> properties. >> >> _per the earlier email_, this might (read: will) create concurrent access >> when the node is not yet attached to the scene graph: >> >> >>

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

2025-03-04 Thread Kevin Rushforth
On Fri, 28 Feb 2025 18:24:38 GMT, Andy Goryachev wrote: >> modules/javafx.controls/src/main/java/javafx/scene/chart/Chart.java line 106: >> >>> 104: >>> 105: // SimpleBooleanProperty or ObjectBinding >>> 106: private volatile Object accessibilityActive; >> >> You can use `ObservableVal

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

2025-03-04 Thread Kevin Rushforth
On Mon, 3 Mar 2025 21:42:26 GMT, Andy Goryachev wrote: >> 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 >>

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

2025-03-03 Thread John Hendrikx
On Mon, 3 Mar 2025 19:58:08 GMT, Andy Goryachev wrote: >> I don't know how to use Subscription in this case. >> This does not work: >> >> >> ObservableValue winProp = >> sceneProperty().flatMap(Scene::windowProperty); >> accessibilityActive = winProp; // keep

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

2025-03-03 Thread Andy Goryachev
On Mon, 3 Mar 2025 21:30:42 GMT, John Hendrikx wrote: >> Was this solution considered: >> >> ObservableValue partOfSceneGraph = this.sceneProperty() >> .flatMap(Scene::windowProperty) >> .flatMap(Window::showingProperty) >> .orElse(false); >> >> symbol.focusTrave

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

2025-03-03 Thread John Hendrikx
On Tue, 25 Feb 2025 22:33:40 GMT, Andy Goryachev wrote: >> Root Cause: >> (Multiple) properties are getting bound to the global >> `Platform.accessibilityActive` property. Binding (and I say, accessing) of >> properties is not thread-safe. >> >> I also changed the design a bit. Originally, ev

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

2025-03-03 Thread Andy Goryachev
On Mon, 3 Mar 2025 21:23:47 GMT, John Hendrikx wrote: >> Andy Goryachev has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 25 commits: >> >> - Merge remote-tracking branch 'origin/master' into >> 8349091.charts.thread.safety >> -

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

2025-03-03 Thread John Hendrikx
On Mon, 3 Mar 2025 21:28:13 GMT, John Hendrikx 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 ex

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

2025-03-03 Thread John Hendrikx
On Mon, 3 Mar 2025 21:10:39 GMT, Andy Goryachev wrote: >> modules/javafx.controls/src/main/java/javafx/scene/chart/AreaChart.java line >> 546: >> >>> 544: symbol.setAccessibleRole(AccessibleRole.TEXT); >>> 545: symbol.setAccessibleRoleDescription("Point"); >>> 546:

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

2025-03-03 Thread John Hendrikx
On Tue, 25 Feb 2025 22:33:40 GMT, Andy Goryachev wrote: >> Root Cause: >> (Multiple) properties are getting bound to the global >> `Platform.accessibilityActive` property. Binding (and I say, accessing) of >> properties is not thread-safe. >> >> I also changed the design a bit. Originally, ev

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

2025-03-03 Thread Andy Goryachev
On Mon, 3 Mar 2025 21:01:58 GMT, John Hendrikx wrote: >> Andy Goryachev has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 25 commits: >> >> - Merge remote-tracking branch 'origin/master' into >> 8349091.charts.thread.safety >> -

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

2025-03-03 Thread John Hendrikx
On Mon, 3 Mar 2025 20:44:08 GMT, Andy Goryachev wrote: >> I haven't been tracking these fixes for allowing initialization in >> background threads, but it seems to me that basically anything should be >> allowed as long as you're not part of a visible scene graph -- and I think >> there's also

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

2025-03-03 Thread Andy Goryachev
On Mon, 3 Mar 2025 20:35:21 GMT, John Hendrikx wrote: >> @hjohn could you help here please? How could we use Subscription in a >> situation when it has to be unsubscribed from within the lambda? > > I haven't been tracking these fixes for allowing initialization in background > threads, but it

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

2025-03-03 Thread Andy Goryachev
On Fri, 28 Feb 2025 18:34:31 GMT, Andy Goryachev wrote: >> modules/javafx.controls/src/main/java/javafx/scene/chart/Chart.java line 561: >> >>> 559: accessibilityActive = winProp; // keep the reference >>> so it won't get gc >>> 560: >>> 561: // lambda cannot be

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

2025-02-28 Thread Andy Goryachev
On Wed, 26 Feb 2025 14:34:50 GMT, Kevin Rushforth wrote: >> Andy Goryachev has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 25 commits: >> >> - Merge remote-tracking branch 'origin/master' into >> 8349091.charts.thread.safety >>

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

2025-02-28 Thread Andy Goryachev
On Wed, 26 Feb 2025 14:40:16 GMT, Kevin Rushforth wrote: >> Andy Goryachev has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 25 commits: >> >> - Merge remote-tracking branch 'origin/master' into >> 8349091.charts.thread.safety >>

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

2025-02-28 Thread Kevin Rushforth
On Tue, 25 Feb 2025 22:33:40 GMT, Andy Goryachev wrote: >> Root Cause: >> (Multiple) properties are getting bound to the global >> `Platform.accessibilityActive` property. Binding (and I say, accessing) of >> properties is not thread-safe. >> >> I also changed the design a bit. Originally, ev

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

2025-02-25 Thread Andy Goryachev
> Root Cause: > (Multiple) properties are getting bound to the global > `Platform.accessibilityActive` property. Binding (and I say, accessing) of > properties is not thread-safe. > > I also changed the design a bit. Originally, every symbol in a chart had its > `focusTraversableProperty` boun