-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359266: Delete the usage of AppContext in the GraphicsDevice #25818
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back serb! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@@ -303,23 +296,15 @@ public void setFullScreenWindow(Window w) { | |||
fullScreenWindow.setBounds(windowedModeBounds); | |||
} | |||
// Set the full screen window | |||
synchronized (fsAppContextLock) { |
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.
A synchronized
block has stronger memory consistency guarantees than a volatile
modifier.
Did you consider leaving the synchronized block but removing the usage of AppContext
?
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.
What do you mean by stronger in this use case?
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.
I mean that there's a happens before relation each time the synchronized block is reach whereas with volatile, the happens before relation is guaranteed only when the value of the variable changes.
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.
I mean that there's a happens before relation each time the synchronized block is reach whereas with volatile, the happens before relation is guaranteed only when the value of the variable changes.
I do not think that this is true "guaranteed only when the value of the variable changes".
A write to a volatile field (§8.3.1.4) happens-before every subsequent read of that field.
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.
Exactly! A write to a volatile field.
Yet entering and leaving a synchronized block gives a happens-before relation each time.
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.
What I mean is two threads that called GraphicsDevice.getFullScreenWindow
still established a happens-before relation for each call, which will be gone with the volatile modifier.
It may be fine… or may be not… this is why I'm asking.
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.
What I mean is two threads that called GraphicsDevice.getFullScreenWindow still established a happens-before relation for each call, which will be gone with the volatile modifier.
It may be fine… or may be not… this is why I'm asking.
That only affects the case where the second thread tries to read shared data (unrelated to GraphicsDevice) without synchronization, which was written before the first thread called getFullScreenWindow(). If visibility is required, it should be ensured by the caller. Depending on some internal and undocumented lock for that is not a good thing.
This PR removes the usage of AppContext from the GraphicsDevice class. The original use case was to store the full-screen window in some AppContext, which was necessary in the context of plugin/appletviewer environments. However, there is now effectively only one main AppContext, so this indirection can be eliminated.
Notes: GraphicsDevice provides two methods for handling full-screen windows:
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25818/head:pull/25818
$ git checkout pull/25818
Update a local copy of the PR:
$ git checkout pull/25818
$ git pull https://git.openjdk.org/jdk.git pull/25818/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25818
View PR using the GUI difftool:
$ git pr show -t 25818
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25818.diff
Using Webrev
Link to Webrev Comment