RFR: 7903963: Fix "Run Configuration" Window Freeze Issue
Jorn Vernee
jvernee at openjdk.org
Fri Mar 7 17:17:43 UTC 2025
On Wed, 5 Mar 2025 16:15:46 GMT, Oleksii Sylichenko <duke at openjdk.org> wrote:
> # When the Problem Occurs
>
> The JTReg "Run Configuration" window freezes when the user selects a JRE that is not present in the project's SDK list.
>
> # Why the Problem Occurs
>
> There is a method `applyEditorTo` in the `JTRegConfigurable.java` class, which is called repeatedly while the "Run Configuration" window is open. Within this method, the method `jrePathEditor.getJrePathOrName()` is invoked. As a result, when this method is called for a JRE path not listed in IDEA, it attempts to determine the Java version. If the user has selected a raw JDK image, a Java process is launched, and the version is obtained from the process output (see [org.jetbrains.jps.model.java.impl.JdkVersionDetectorImpl#detectJdkVersionInfo](https://github.com/JetBrains/intellij-community/blob/baba77ecf93f44a2ccb34e5b206e03c60817d511/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JdkVersionDetectorImpl.java#L40)).
>
> This call is too resource-intensive to be executed on the UI thread, causing the window to freeze.
>
> # Steps to reproduce
>
> 1. Open a JDK project.
> 2. Open the "Project Structure" window.
> 3. Navigate to "Platform Settings → SDKs".
> 4. Remove the JDK that is used as the JRE for tests, or create a copy of this JDK on your file system.
> 5. Create a new "JTReg Run Configuration".
> 6. In the "JRE" field, select a JDK path that is not present in the Project SDK list (either the removed JDK or the copied one).
>
> ## Actual result
> - The window starts freezing, even after saving and reopening it.
>
> # Implemented Changes
>
> ## JTRegConfigurable.java
> - Fix Javadoc for the class.
> - Remove unused class field: `jtregDir`.
> - Add Javadoc to the methods: `createUIComponents`, `applyEditorTo`, `resetEditorFrom`
> - Fix window freeze caused by `jrePathEditor` in the method `applyEditorTo`.
> - Add method `applyEditorJrePathTo` to optimize data retrieval from `jrePathEditor`.
>
> Since I implemented changes in this file, I also took the opportunity to clean up the code a bit.
> Hi, I’ve created this pull request, but I don’t have the necessary permissions to create an issue for it. Could someone please create an issue to track this change? I’m not sure who to contact directly, so any help would be appreciated.
Typically your best bet is to send a message to one of the mailing lists: https://mail.openjdk.org/mailman/listinfo For this plugin, the right list would be ide-support-dev at openjdk.org or jtreg-dev at openjdk.org
For now I'll make a JBS issue for you.
I was able to reproduce the issue. I noticed that is was particularly noticeable when I select the JRE field, and then select another field. The UI seems to freeze for 1-2 seconds. Thank you for the excellent reproduction steps!
I've created the issue: https://bugs.openjdk.org/browse/CODETOOLS-7903963 Please change the PR title to:
7903963: Fix "Run Configuration" Window Freeze Issue
I've verified that the fix works on my machine as well.
plugins/idea/src/main/java/com/oracle/plugin/jtreg/configuration/ui/JTRegConfigurable.java line 147:
> 145:
> 146: final String alternativeJrePath;
> 147: final boolean alternativeJREPathEnabled;
I've discussed with my colleague, and in general we'd like to not have `final` on local variables, as it doesn't really add much value, but does introduce extra visual clutter. I know some parts of the plugin don't follow that rule, but we shouldn't add more of it.
Please remove `final` from local variables.
plugins/idea/src/main/java/com/oracle/plugin/jtreg/configuration/ui/JTRegConfigurable.java line 156:
> 154: if (JdkUtil.checkForJdk(alternativeJrePath)) {
> 155: // If the path is a valid JDK, add it to the ComboBox list.
> 156: jrePathEditor.setPathOrName(alternativeJrePath, true);
I'd like to better understand the effect that adding the path to the list is intended to have. I think the main point here is that the next time `applyEditorTo` is called, the path will be in the list, and we will take the `if` branch instead, which at that point is faster?
The custom JRE path doesn't seem to persist if I close and re-open the run configuration dialogue.
-------------
PR Comment: https://git.openjdk.org/jtreg/pull/250#issuecomment-2706582009
PR Comment: https://git.openjdk.org/jtreg/pull/250#issuecomment-2706615051
PR Comment: https://git.openjdk.org/jtreg/pull/250#issuecomment-2706665129
PR Review Comment: https://git.openjdk.org/jtreg/pull/250#discussion_r1985265885
PR Review Comment: https://git.openjdk.org/jtreg/pull/250#discussion_r1985217532
More information about the jtreg-dev
mailing list