Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8349098: TabPane: exception initializing in a background thread #1699

Conversation

andy-goryachev-oracle
Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle commented Feb 6, 2025

Root Cause

Animation gets started in a background thread, which causes the animation handler to run in the FX application thread, thus creating simultaneous access to the control's fields (list of children in this case).

Solution

Skip the animation.

The fix is similar to #1698


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8349098: TabPane: exception initializing in a background thread (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1699/head:pull/1699
$ git checkout pull/1699

Update a local copy of the PR:
$ git checkout pull/1699
$ git pull https://git.openjdk.org/jfx.git pull/1699/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1699

View PR using the GUI difftool:
$ git pr show -t 1699

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1699.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 6, 2025

👋 Welcome back angorya! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 6, 2025

@andy-goryachev-oracle This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8349098: TabPane: exception initializing in a background thread

Reviewed-by: arapte, kcr

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 6 new commits pushed to the master branch:

  • 53fe8f1: 8349256: Update PipeWire to 1.3.81
  • 167e1ee: 8349756: Memory leak in PaginationSkin when setting page count / index
  • 1e69157: 8340322: Update WebKit to 620.1
  • 50dbedb: 8349679: build.gradle: increase system test memory limit to 1GB
  • 8818ccf: 8344367: Fix mistakes in FX API docs
  • 3ce3af0: 8348100: Tooltips cannot be instantiated on background thread

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@andy-goryachev-oracle andy-goryachev-oracle marked this pull request as ready for review February 6, 2025 23:28
@openjdk openjdk bot added the rfr Ready for review label Feb 6, 2025
@mlbridge
Copy link

mlbridge bot commented Feb 6, 2025

Webrevs

@kevinrushforth
Copy link
Member

Reviewer: @arapte

/reviewers 2

@openjdk
Copy link

openjdk bot commented Feb 7, 2025

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

Copy link
Member

@arapte arapte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -522,7 +520,7 @@ private void removeTabs(List<? extends Tab> removedList) {
}
};

if (closeTabAnimation.get() == TabAnimation.GROW) {
if (Platform.isFxApplicationThread() && (closeTabAnimation.get() == TabAnimation.GROW)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this check, non Application thread cannot play the animation but in else block the cleanup is executed on the same thread.
Can there still be a situation when, this non-Application thread and Application thread be concurrently modifying the tab?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean two threads accessing this same TabPaneSkin instance, then that's not a valid case. JavaFX objects are not thread-safe when accessed from multiple threads. This bug (and the other related bugs fixed or under review) is about making sure that multiple threads, including the JavaFX application thread, each concurrently accessing their own instance, don't interfere with each other.

So it would only be a problem if "cleanup" attempted some animation or touched static state or similar, which is doesn't look like it does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, having said that, the purpose of the cleanup is to clean up after the animation. So a better fix might be to put the entire if-else inside an if (Platform.isFxApplicationThread()) test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, no. It also calls requestLayout. I think the fix is correct as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. The change prevents from starting the animation if these code paths are entered in a background thread. With the change, the code follows an animation-off path.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good. I confirm that the newly-enabled test fails without the fix and passes with the fix.

@openjdk openjdk bot added the ready Ready to be integrated label Feb 14, 2025
@andy-goryachev-oracle
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 14, 2025

Going to push as commit d1f5ea8.
Since your change was applied there have been 7 commits pushed to the master branch:

  • b267340: 8348095: [Linux] Menu shows up in wrong position when using i3 windows manager in full screen mode
  • 53fe8f1: 8349256: Update PipeWire to 1.3.81
  • 167e1ee: 8349756: Memory leak in PaginationSkin when setting page count / index
  • 1e69157: 8340322: Update WebKit to 620.1
  • 50dbedb: 8349679: build.gradle: increase system test memory limit to 1GB
  • 8818ccf: 8344367: Fix mistakes in FX API docs
  • 3ce3af0: 8348100: Tooltips cannot be instantiated on background thread

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 14, 2025
@openjdk openjdk bot closed this Feb 14, 2025
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels Feb 14, 2025
@openjdk
Copy link

openjdk bot commented Feb 14, 2025

@andy-goryachev-oracle Pushed as commit d1f5ea8.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@andy-goryachev-oracle andy-goryachev-oracle deleted the 8349098.thread.safe.tabpane branch February 14, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants