-
Notifications
You must be signed in to change notification settings - Fork 541
8241840: Memoryleak: Closed focused Stages are not collected with Monocle. #153
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
Conversation
Closed focused Stages are not collected with Monocle This commit adds a unit-test and a fix for collecting focused closed stages.
|
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
Webrevs
|
|
/reviewers 2 |
|
@kevinrushforth |
|
@arapte can you also review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested some changes and query. I still need to verify the fix in detail.
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/glass/ui/Window.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
Some code cleanups
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
modules/javafx.graphics/src/main/java/com/sun/glass/ui/monocle/MonocleWindowManager.java
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTest.java
Outdated
Show resolved
Hide resolved
small cleanup based on code review
removed change to the window class, because it wasn't required for the fix.
The tests are now reused for native and monocle tests.
|
I don't think the class MeshManagerCacheLeakTest is a good base to write monocle + native tests. In my latest commit, I've added a simple solution to how the test can be reused. If one of the tests is unstable on windows, then it would be great if we could consider it as 2 bugs, so this PR can be finished. Afterwards it would be great if someone else could continue the windows-bug because I don't have a very productive setup to work on it and I also don't really understand the native windows code. |
| if (this.isFocused != focused) { | ||
| this.isFocused = focused; | ||
| if (this.isFocused) { | ||
| if (this.isFocused && this.isVisible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my Window10 machine, with this change, Window.focusedWindow remains null even after the first window (I have not verified with multiple windows though) is shown onto the screen and is focused. And It continues to remain null until some mouse or key action is performed on the window.
I am not sure if this causes any side effects. It looks like the Window.focusedWindow is mostly(only) used for Monocle.
Can you please confirm the behavior that Window.focusedWindow remain null and check for any side effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned - I don't have a good setup to test this code on Windows.
But I've checked where focusedWindow/getFocusedWindow is used, and I can verify your assumption. I've searched through the whole project and the variable is only used in the MonocleCode.
The fact that focusedWindow get's sometimes set is probably the cause of the irregular happening memoryleak on Window.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reading the comments, I thought you were going to revert the changes to Window.java? Or did I misinterpret what you said earlier?
I can confirm that focusedWindow is no longer correctly set to the focused window when that Window is first shown (I tried this on Windows). This is true for apps with multiple windows as well as single Stage apps. I can also confirm that focusedWindow isn't used on any platform other than Monocle. Even so, since this change isn't needed it seems best to revert it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The motivation for this change was, that I've seen a similar bug on native-windows without monocle.
In this case a leak happened related to the focusedWindow variable.
Sadly I don't have a test for this bug, because it is undeterministic.
For that reason, I thought it would make sense to keep this change, because I think it fixes it.
If I remember correctly, it was related to Stages which were focused but closed at the same time, which only weren't collected because of the focusedWindow variable.
Because the variable also isn't used on NativeWindows it doesn't seem to do much harm.
I've now removed it, but it might be considered to be readded.
|
Any updates about this PR? |
|
Once the last of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix to Monocle looks good. So does the test (I left some minor comments). I can confirm that the test catches the leak (it passes with your fix and fails without it).
My only question is regarding the change to Window.java.
| if (this.isFocused != focused) { | ||
| this.isFocused = focused; | ||
| if (this.isFocused) { | ||
| if (this.isFocused && this.isVisible) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In reading the comments, I thought you were going to revert the changes to Window.java? Or did I misinterpret what you said earlier?
I can confirm that focusedWindow is no longer correctly set to the focused window when that Window is first shown (I tried this on Windows). This is true for apps with multiple windows as well as single Stage apps. I can also confirm that focusedWindow isn't used on any platform other than Monocle. Even so, since this change isn't needed it seems best to revert it.
tests/system/src/test/java/test/javafx/stage/FocusedWindowMonocleTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowNativeTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
Minor cleanups
Removed unnecessary change.
fixed tests
There was a problem hiding this 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 now. I'll file a follow-up issue for the potential leak on the other platforms.
My thinking is that if focusedWindow is only used in Monocle, we should push the tracking down to the platform rather than tracking it in the base class. Alternatively, we could have a platform-specific attribute that indicates whether to track (and leave it null otherwise).
tests/system/src/test/java/test/javafx/stage/FocusedWindowMonocleTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowNativeTest.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
tests/system/src/test/java/test/javafx/stage/FocusedWindowTestBase.java
Outdated
Show resolved
Hide resolved
|
I filed JDK-8251555 to track the follow-on issue. |
small formatting changes based on codereview
|
Great, I've added the changes and commented on the now ticket. |
|
@FlorianKirmaier This change now passes all automated pre-integration checks. When the change also fulfills all project specific requirements, type
Since the source branch of this PR was last updated there have been 140 commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge As you do not have Committer status in this project, an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@arapte, @kevinrushforth) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/integrate |
|
@FlorianKirmaier |
|
/sponsor |
|
@kevinrushforth @FlorianKirmaier The following commits have been pushed to master since your change was applied:
Your commit was automatically rebased without conflicts. Pushed as commit 1c54e61. |
Closed focused Stages are not collected with Monocle
This commit adds a unit-test and a fix for collecting focused closed stages.
ticket: https://bugs.openjdk.java.net/browse/JDK-8241840
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jfx pull/153/head:pull/153$ git checkout pull/153