RFR: 8185862: AWT Assertion Failure in ::GetDIBits(hBMDC, hBM, 0, 1, 0, gpBitmapInfo, 0) 'awt_Win32GraphicsDevice.cpp', at line 185 [v9]

Christoph Langer clanger at openjdk.org
Wed Mar 6 07:52:50 UTC 2024


On Wed, 6 Mar 2024 07:50:08 GMT, Christoph Langer <clanger at openjdk.org> wrote:

>> The assertions reported in the bug were observed spuriously and here and there broke tests in some Windows configurations.
>> For instance [JDK-8266129](https://bugs.openjdk.org/browse/JDK-8266129), [JDK-8269529](https://bugs.openjdk.org/browse/JDK-8269529) or [JDK-8323664](https://bugs.openjdk.org/browse/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.
>
> Christoph Langer has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 14 additional commits since the last revision:
> 
>  - declare variable hasDisplays final
>  - Merge branch 'master' into JDK-8185862
>  - load awt.dll before display check
>  - Change implementation of headless determination on Windows
>  - Merge branch 'master' into JDK-8185862
>  - Reflect display detection in java.awt.GraphicsEnvironment::isHeadless()
>  - Merge branch 'master' into JDK-8185862
>  - Get rid of global variables and restore old handling wrt calling ::GetDIBits
>  - Merge branch 'master' into JDK-8185862
>  - Little cleanup
>  - ... and 4 more: https://git.openjdk.org/jdk/compare/7f595d03...002fba2d

> 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.

I ran all of test/jdk/sanity/client/SwingSet now and everything passed. So from my end this should be ready.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17614#issuecomment-1980272271


More information about the client-libs-dev mailing list