-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8185862: AWT Assertion Failure in ::GetDIBits(hBMDC, hBM, 0, 1, 0, gpBitmapInfo, 0) 'awt_Win32GraphicsDevice.cpp', at line 185 #17614
Conversation
👋 Welcome back clanger! A progress list of the required criteria for merging this PR into |
@RealCLanger The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
This was my observation too, but is it always the case ? Unfortunately I couldn't find some documentation on this. |
Maybe add some comment about the monitor counting, that it only considers now certain monitors with 'good' capabilities ? |
I added a comment to explain that we skip monitors where CreateDC fails. The fix runs successfully through SAP's testing with no regressions spotted. Looks like it even fixes the problems of test/jdk/java/awt/font/GlyphVector/LayoutCompatTest.java on Windows that we reported in the comments of https://bugs.openjdk.org/browse/JDK-8318364. @prrace Want to take a look here (or assign somebody from client group)? Thanks! |
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Outdated
Show resolved
Hide resolved
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Outdated
Show resolved
Hide resolved
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Show resolved
Hide resolved
Hi @aivanov-jdk, thanks for your suggestions. I addressed them. Please have another look. |
/reviewers 2 |
@aivanov-jdk |
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.
Looks good to me…
except for comment on gpBitmapInfo
in AwtWin32GraphicsDevice::Initialize
.
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Show resolved
Hide resolved
This all looks reasonable initself but .. The 2nd thing is that this situation ought to clearly flag that this is a HEADLESS situation and the AWT should be in headless mode. |
I think that's hard to find out. At least our regression testing did not show issues. The change probably needs more testing. On the other hand, I think the risk with that change is low since the environment that is addressed by it seems to be rather unusual and the asserts show that something goes wrong in that case currently anyway.
That's a valid point. We could flag a system where we detect zero monitors as headless and then set the headless property. At the moment the default headless property would be false on Windows in any case, as per here. I guess we can wire the monitor detection in here and return true if no monitors were found. Would you want me to go that way? |
That seems like a good idea. Definitely worth a shot to see if it is sufficient and in time !
|
OK, I added code that would make GraphicsEnvironment::isHeadless() return true if we have no display devices. Please check 😄 |
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 change looks good but I'd like to run it through all our tests since if there's anything wrong with this code path we are in trouble :-)
Yes, please test thoroughly and let me know. I'll give it another spin in our testing as well. |
OK, yes, seems I can reproduce. I'll try to figure out what's going on... |
I think I've understood the problem behind the crashes now. The way I implemented |
Does this new version really work for you ?? I'm getting eg from It is at least 840 tests that fail .. Since I do see the method in your change .. and in my local copy too, I assume I correctly applied your patch .. so I wonder if awt.dll is not loaded in time ? It isn't on demand. |
You're right, the awt lib needs to be loaded before checking isHeadless(). I just looked at the crash in test test/jdk/javax/swing/plaf/windows/6921687/bug6921687.java and resolved it. But the test obviously is not concerned about the headless environment so it doesn't stress that code path. I reproduced the problem with a simple program that just calls GraphicsEnvironment.isHeadless() and fixed it. Please try the headless tests again. Thanks a lot for your help! |
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.
This now passes all my automated testing.
Have you tested manual apps like SwingSet ?
I doubt they'll have a problem but it would be good to be 100% sure.
The only thing I notice here is it adds one more place that we duplicate the code to load the AWT native library. Bizarrely Toolkit and WToolkit both do it.
The result is not just duplicated code but duplicated (now triplicated) effort at startup.
There might even be a fourth place - NativeLibLoader.
But fixing that might mean being extra careful about not introducing circularities at start up and since the impact should be negligible I think it is out of scope for this fix.
So just let me know about the manual testing.
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.
It looks good to me.
The only question I have is for the fallback in awt_Win32GraphicsDevice.cpp
.
Bailing out quickly makes the code cleaner. In this case, if ::GetDIBits
fails, we can bail out too.
If the fallback is needed, the code below the first call to ::GetDIBits
should be executed even if GetDC
and CreateCompatibleBitmap
fail.
Since testing didn't reveal any problems, the fallback is probably not as important, or not critical for a headless system.
src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java
Outdated
Show resolved
Hide resolved
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Show resolved
Hide resolved
I think the bailout is unlikely to happen after this fix. At least not for the headless environment where we won't jump into AwtWin32GraphicsDevice::Initialize() at all any more. And in headless environments with working monitors, we would never bail out, I guess. However, the method could be cleaned up I guess. But that should also be done in another issue and by somebody who is more into the details of what's going on there. |
I ran all of test/jdk/sanity/client/SwingSet now and everything passed. So from my end this should be ready. |
In this case, I think you should update the code to bail out if jdk/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp Lines 192 to 198 in 58a4044
At the moment the code is inconsistent. If this code isn't even run in headless environment, then it's better to make it consistent. Otherwise, it raises questions why it returns if either if |
src/java.desktop/windows/classes/sun/awt/PlatformGraphicsInfo.java
Outdated
Show resolved
Hide resolved
…ecessary private method for hasDisplays()
src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp
Outdated
Show resolved
Hide resolved
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 think we are done with this.
If a DEBUG build is used for HEADFUL then the new VERIFY calls might cause a different failure mode, but that's the only risk I see, and it seems a very, very small one.
@RealCLanger 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:
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 31 new 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 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 |
Thanks for the reviews. /integrate |
Going to push as commit 1ad3ebc.
Your commit was automatically rebased without conflicts. |
@RealCLanger Pushed as commit 1ad3ebc. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The assertions reported in the bug were observed spuriously and here and there broke tests in some Windows configurations.
For instance JDK-8266129, JDK-8269529 or JDK-8323664 came up due to this.
The problem is that in Windows environments without a valid display, e.g. started by system services or via PowerShell Remoting, one sees a Monitor with name 'Windisc' in
EnumDisplayMonitors
.However, it seems to be some kind of a pseudo device where you can not get a DC via
CreateDC
. This behavior/monitor type doesn't seem to be well documented, though.I hereby modify the device initialization code to only count/detect monitors where CreateDC returns non-NULL in Devices.cpp. I also add some more checking/error handling to AwtWin32GraphicsDevice::Initialize() for correctness.
Furthermore, I re-enable the test
javax/swing/reliability/HangDuringStaticInitialization.java
for Windows Debug VMs, which reverts the fix from JDK-8269529 that should not be necessary any more.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17614/head:pull/17614
$ git checkout pull/17614
Update a local copy of the PR:
$ git checkout pull/17614
$ git pull https://git.openjdk.org/jdk.git pull/17614/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17614
View PR using the GUI difftool:
$ git pr show -t 17614
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17614.diff
Webrev
Link to Webrev Comment