<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Yes my machine was at 150% scaling.</div><div class=""><br class=""></div><div class="">If I force uiScale = 1, I see that:</div><div class=""><span style="color: rgb(0, 0, 0);" class="">LargeWindowPaintTest fails without patch and passes with patch.</span></div><div class=""><font color="#000000" class="">AlphaPrintTest shows <span style="caret-color: rgb(0, 0, 0);" class="">instructions without patch also.</span></font></div><div class=""><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><br class=""></span></font></div><div class="">@Phil : I think its better if we test at uiScale=1(larger memory footprint). Please clarify.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jay</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 11-Jun-2020, at 5:53 PM, Kevin Rushforth <<a href="mailto:kevin.rushforth@oracle.com" class="">kevin.rushforth@oracle.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
<div class="">
Do you have a Hi-DPI machine? I do, and had to run with
"-Dsun.java2d.uiScale=1" in order to see the failure with <font class="">LargeWindowPaintTest.<br class="">
<br class="">
For AlphaPrintTest, the test deliberately ensures that you print
before saying whether it passes or not. FWIW, I verified that the
printing test on my system was hitting the fallback code with the
patch, but it seemed to print correctly even without the patch.<br class="">
<br class="">
-- Kevin<br class="">
</font><br class="">
<br class="">
<div class="moz-cite-prefix">On 6/11/2020 1:58 AM, Jayathirth D v
wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:40C65E05-2AA8-4C4B-98B1-6A7F58BFFD22@ORACLE.COM" class="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
Typo : I tried tested -><span style="caret-color: rgb(0, 0, 0);" class=""> I tried </span>testing<br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 11-Jun-2020, at 2:27 PM, Jayathirth D v <<a href="mailto:JAYATHIRTH.D.V@ORACLE.COM" class="" moz-do-not-send="true">JAYATHIRTH.D.V@ORACLE.COM</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space;
line-break: after-white-space;" class="">Hi Phil,
<div class=""><br class="">
</div>
<div class="">I tried tested the fix in my Windows 10
machine with Intel integrated UHD Graphics 620.</div>
<div class=""><br class="">
</div>
<div class=""><font class="">LargeWindowPaintTest.java
passes with/without fix in my machine.</font></div>
<div class=""><font class="">AlphaPrintTest.java without
fix just opens up blank frame without any instructions
and with fix it shows instructions for the test.</font></div>
<div class=""><span style="caret-color: rgb(0, 0, 0);" class="">Is this expected behaviour?</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0);" class=""><br class="">
</span></div>
<div class=""><span style="caret-color: rgb(0, 0, 0);" class="">AlphaPrintTest.java w</span><font class="">ith
fix when it shows instructions if I click on
Pass(Since I don’t have printer right now) it doesn’t
pass/close the window. Only after I click on Print
button and then close print dialog it allows me to
click on Pass button.</font></div>
<div class=""><font class=""><span style="caret-color:
rgb(0, 0, 0);" class=""><br class="">
</span></font></div>
<div class=""><font class=""><span style="caret-color:
rgb(0, 0, 0);" class="">Also how does these tests
behave in our internal CI machines?</span></font></div>
<div class=""><br class="">
<div class="">Thanks,</div>
<div class="">Jay</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 11-Jun-2020, at 2:18 AM, Philip
Race <<a href="mailto:philip.race@oracle.com" class="" moz-do-not-send="true">philip.race@oracle.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" class="">
<div class=""> Bug: <a class="moz-txt-link-freetext" href="https://bugs.openjdk.java.net/browse/JDK-8240654" moz-do-not-send="true">https://bugs.openjdk.java.net/browse/JDK-8240654</a><br class="">
Webrev: <a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~prr/8240654/index.html" moz-do-not-send="true">http://cr.openjdk.java.net/~prr/8240654/index.html</a><br class="">
<br class="">
This is for JDK 15 so review ASAP please since
RDP 1 and the test cycle are looming.<br class="">
<br class="">
This is not a fix for a JDK bug. It is a bunch
of workarounds for a Microsoft Windows bug
affecting<br class="">
GDI in the context of ZGC (<a class="moz-txt-link-freetext" href="http://openjdk.java.net/jeps/333" moz-do-not-send="true">http://openjdk.java.net/jeps/333</a>).<br class="">
Some extra details about the Windows bug at the
end, but first the technical details of the fix.<br class="">
<br class="">
With ZGC's memory allocation requirement of
reserving memory in 2Mb chunks some Windows GDI<br class="">
functions, mostly involving some bitmaps APIs
may return a failure code (ie fail!)<br class="">
This typically occurs when Java heap memory is
used for a Java image and then in a JNI<br class="">
call we use GetPrimitiveArrayCritical so that
Java heap allocated memory is passed to a GDI<br class="">
function AND the Java heap memory spans one of
the 2Mb boundaries. <br class="">
This is very easy to trigger in almost any Java
UI app if the window is of a large enough (ie
typical) size.<br class="">
NB: if you have an Nvidia or ATI card, then you
won't see it, because the D3D pipeline doesn't<br class="">
call the affected method but if you have an
Intel chip as do 90% (?) of laptops you will see
it.<br class="">
There are also several other places we found
that are affected. Printing is the other one<br class="">
somewhat easy to trigger. The others : custom
cursors and tray icons are less common.<br class="">
The painful thing here is that there is no
definitive list (a list of the known ones is
below) of<br class="">
affected Windows GDI APIs and we are just
hunting around our code trying to see where it<br class="">
might be side-swiped by this bug.<br class="">
<br class="">
The basic approach in these workarounds is that
for cases where performance does not matter we
now copy <br class="">
and for cases where performance does matter or
larger amounts of memory is involved we check if<br class="">
the return value of the GDI function indicates
failure and then re-try with a copy of the heap
memory. <br class="">
Unless GDI was randomly failing already
(unlikely) this should be a no-risk solution in
the high profile cases. <br class="">
We have done performance measurements on the
important screen case and the failures<br class="">
happen fast so the penalty is then in the re-try
which is only if ZGC is enabled.<br class="">
Always copying the memory is slower (and memcpy
is the slow operation) than an alternative
approach<br class="">
that "knows" about the memory allocation of ZGC
but this coupling and the complexity seem like
they aren't<br class="">
worth it since I haven't seen any visible
performance consequence. That can be revisited<br class="">
some day if need be, but for now we have
correctness which is the key as well as
sufficient performance.<br class="">
<br class="">
I've created an automated test for the most
important on-screen case. <br class="">
Also a manual printing test case which invokes
ZGC is provided since there we also only<br class="">
conditionally copy. In the other cases we now
always copy so existing test cases should over
those.<br class="">
<br class="">
There is some clean up in this fix - one
completely unused (provably so because it was
#if'd out)<br class="">
JNI method in awt_PrintJob.cpp is removed since
it had code that looked like it needed a
workaround,<br class="">
which would be somewhat of a waste of effort.<br class="">
<br class="">
the doPrintBand code and its callee bitsToDevice
has code I think we can remove too since<br class="">
I don't see how it ever gets executed (the top
down case for browserPrint == true) but<br class="">
I think I'll save that for a P4 follow-on since
it does nothing that would be affected by this<br class="">
Windows bug.<br class="">
<br class="">
One oddity is the in the printing case I
observed that some times the rendering is
performed<br class="">
even if an error code is returned. I don't know
why, but in code we can't tell that it was
actually<br class="">
rendered and in any case there is no harm in
repeating the call with copied memory.<br class="">
<br class="">
We are right before the JDK15 stabilisation fork
and this fix needs to go there and will<br class="">
but the webrev is against jdk/client simply
because jdk15 does not exist yet !<br class="">
<br class="">
Please test and review ASAP.<br class="">
<br class="">
About the bug:<br class="">
Microsoft has acknowleged the bug and will
publish a knowledge base article about it<br class="">
but a fix may show up only in a future version
of Windows. Not, it seems, any time soon.<br class="">
Below is a list of potentially affected GDI
APIs. Per microsoft whether it actually
manifests in<br class="">
any specific case depends on "branching"<br class="">
<span style="font-family:"Courier
New",serif;color:#1F4E79" class=""></span><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wcs/checkbitmapbits" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wcs/checkbitmapbits</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wcs/createcolortransform" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/previous-versions/windows/desktop/wcs/createcolortransform</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setdibitstodevice" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setdibitstodevice</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchdibits" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-stretchdibits</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapbits" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getbitmapbits</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibitmap" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibitmap</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createdibsection</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-polydraw" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-polydraw</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-drawescape" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-drawescape</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmap" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-createbitmap</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setbitmapbits" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setbitmapbits</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><a href="https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdibits" class="" moz-do-not-send="true">https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-getdibits</a></span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class=""><br class="">
</span></p><p class="MsoNormal"><span style="font-family:"Courier
New",serif" class="">-phil.<br class="">
</span></p>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</blockquote>
<br class="">
</div>
</div></blockquote></div><br class=""></div></body></html>